Droidboot API
ABM version 0.3 introduced a universal api to have single gui, lvgl, config parser etc. across all devices. That is achieved by having a separated droidboot_gui, bootloader, and HAL (hardware abstraction layer) that implements common functionality needed to use ABM. Here is the list of function you should implement to get ABM running on your bootloader.
Display
droidboot_internal_get_display_height
int droidboot_internal_get_display_height()
Should return display height in pixels
droidboot_internal_get_display_width
int droidboot_internal_get_display_width()
Should return display width in pixels
droidboot_internal_get_disp_buffer_height
int droidboot_internal_get_disp_buffer_height()
Should return int that represents number of horizontal lines in lvgl image buffer, usually is same as droidboot_internal_get_display_height.
droidboot_internal_use_double_buffering
bool droidboot_internal_use_double_buffering()
Should return true if you want to have double image buffer for lvgl, if you have planty of free RAM should be just hardcoded return true; It do make display refrash faster in some cases.
droidboot_internal_fb_flush
void droidboot_fb_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
Should draw color_p buffer on screen, coordinates are stored in area->x1, area->y1, area->x2, area->y2 after doing so should call lv_disp_flush_ready(disp_drv); Example implementations: If you have adress of fb in memory:
lv_coord_t w = (act_x2 - act_x1 + 1); long int location = 0; long int byte_location = 0; unsigned char bit_location = 0; int32_t y; for(y = act_y1; y <= act_y2; y++) { location = (act_x1 + 0) + (y + 0) * upriv->line_length / 4; memcpy(&fbp32[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 4); color_p += w; } lv_disp_flush_ready(disp_drv);
Where fbp32 is pointer to framebuffer. If you have function to change pixel color:
time_t t; int32_t x, y; for(y = area->y1; y <= area->y2; y++) { for(x = area->x1; x <= area->x2; x++) { fbcon_draw_pixel(x, y, 0xff << 24 | color_p->ch.red << 16 | color_p->ch.green << 8 | color_p->ch.blue ); /* Put a pixel to the display.*/ color_p++; } } // Update display fbcon_flush(); // Inform the graphics library that we are ready with the flushing lv_disp_flush_ready(disp_drv);
Where fbcon_draw_pixel is function to update single pixel and fbcon_flush is function to flush whole display.
Storage
droidboot_internal_sd_read_block
ssize_t droidboot_internal_sd_read_block(void *buf, uint32_t block, uint count)
Is a function to read block(s) from storage device, it takes pointer to buffer (buf) where you should put reading result, "block" is a number of first block to read and count is amount of blocks to read. Buffer is pre-allocated. Should return amount of block that were read from storage device (if everything is successful should be same as count).
droidboot_internal_sd_write_block
ssize_t droidboot_internal_sd_write_block(const void *buf, uint32_t block, uint count)
Is a function to write block(s) to storage device, it takes pointer to buffer (buf) where new block content is stored, "block" is a number of first block to write and count is amount of blocks to write.Should return amount of block that were written to storage device (if everything is successful should be same as count).
droidboot_internal_sd_blklen
uint32_t droidboot_internal_sd_blklen()
Shoul return block size (usually is 512 or 4096) it is good idea not to hardcode it but rather get dynamically.
droidboot_internal_sd_blkcnt
uint64_t droidboot_internal_sd_blkcnt()
Should return amount of blocks on storage device.
droidboot_internal_sd_exists
bool droidboot_internal_sd_exists()
Should return true if storage device do exist.