Skip to content

Commit

Permalink
zephyr: allow placing LVGL rendering buffers into custom section
Browse files Browse the repository at this point in the history
Some applications may want to locate LVGL rendering buffers in a custom
memory location, such as tightly coupled or external memory. To
facilitate this, add a Kconfig CONFIG_LV_Z_VBD_CUSTOM_SECTION, which
when set will locate the LVGL rendering buffers in a section labelled as
".lvgl_buf". This section can then be located in a custom memory region
by the application.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
  • Loading branch information
danieldegrasse committed May 9, 2023
1 parent 231ab54 commit c41dbc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions zephyr/Kconfig.memory
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ config LV_Z_VDB_ALIGN
buffer may be accessed as a uint8_t *, uint16_t *, or uint32_t *,
so buffer must be aligned to prevent unaligned memory access

config LV_Z_VBD_CUSTOM_SECTION
bool "Link rendering buffers to custom section"
depends on LV_Z_BUFFER_ALLOC_STATIC
help
Place LVGL rendering buffers in custom section, with tag ".lvgl_buf".
This can be used by custom linker scripts to relocate the LVGL
rendering buffers to a custom location, such as tightly coupled or
external memory.
choice
prompt "Rendering Buffer Allocation"
default LV_Z_BUFFER_ALLOC_STATIC
Expand Down
13 changes: 11 additions & 2 deletions zephyr/lvgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,19 @@ static lv_disp_draw_buf_t disp_buf;
* uint16_t * or uint32_t *, therefore buffer needs to be aligned accordingly to
* prevent unaligned memory accesses.
*/
static uint8_t buf0[BUFFER_SIZE] __aligned(CONFIG_LV_Z_VDB_ALIGN);
static uint8_t buf0[BUFFER_SIZE]
#ifdef CONFIG_LV_Z_VBD_CUSTOM_SECTION
Z_GENERIC_SECTION(.lvgl_buf)
#endif
__aligned(CONFIG_LV_Z_VDB_ALIGN);

#ifdef CONFIG_LV_Z_DOUBLE_VDB
static uint8_t buf1[BUFFER_SIZE] __aligned(CONFIG_LV_Z_VDB_ALIGN);
static uint8_t buf1[BUFFER_SIZE]
#ifdef CONFIG_LV_Z_VBD_CUSTOM_SECTION
Z_GENERIC_SECTION(.lvgl_buf)
#endif
__aligned(CONFIG_LV_Z_VDB_ALIGN);
#endif /* CONFIG_LV_Z_DOUBLE_VDB */

#endif /* CONFIG_LV_Z_BUFFER_ALLOC_STATIC */

Expand Down

0 comments on commit c41dbc7

Please sign in to comment.