diff --git a/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h747i_disco_stm32h747xx_m7.defconfig b/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h747i_disco_stm32h747xx_m7.defconfig index f7cdddf0944bb..7c46c8d538ff8 100644 --- a/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h747i_disco_stm32h747xx_m7.defconfig +++ b/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h747i_disco_stm32h747xx_m7.defconfig @@ -11,9 +11,12 @@ config STM32_LTDC_FB_NUM config LV_Z_DOUBLE_VDB default y -config LV_Z_VDB_CUSTOM_SECTION +config LV_Z_VDB_ZEPHYR_REGION default y +config LV_Z_VDB_ZEPHYR_REGION_NAME + default "SDRAM2" + config LV_Z_FULL_REFRESH default y diff --git a/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h757i_eval_stm32h757xx_m7.defconfig b/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h757i_eval_stm32h757xx_m7.defconfig index a48bcaf437d3e..6aba190e9acca 100644 --- a/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h757i_eval_stm32h757xx_m7.defconfig +++ b/boards/shields/st_b_lcd40_dsi1_mb1166/boards/stm32h757i_eval_stm32h757xx_m7.defconfig @@ -13,9 +13,12 @@ config STM32_LTDC_FB_NUM config LV_Z_DOUBLE_VDB default y -config LV_Z_VDB_CUSTOM_SECTION +config LV_Z_VDB_ZEPHYR_REGION default y +config LV_Z_VDB_ZEPHYR_REGION_NAME + default "SDRAM2" + config LV_Z_FULL_REFRESH default y diff --git a/boards/st/stm32h747i_disco/CMakeLists.txt b/boards/st/stm32h747i_disco/CMakeLists.txt deleted file mode 100644 index 7601729738961..0000000000000 --- a/boards/st/stm32h747i_disco/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright 2023 BrainCo Inc. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# Add custom linker section to relocate framebuffers to PSRAM -zephyr_linker_sources_ifdef(CONFIG_LV_Z_VDB_CUSTOM_SECTION - SECTIONS dc_ram.ld) diff --git a/boards/st/stm32h747i_disco/dc_ram.ld b/boards/st/stm32h747i_disco/dc_ram.ld deleted file mode 100644 index bd1565960d517..0000000000000 --- a/boards/st/stm32h747i_disco/dc_ram.ld +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2023 BrainCo Inc. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay) -GROUP_START(SDRAM2) - - SECTION_PROLOGUE(_STM32_SDRAM2_SECTION_NAME, (NOLOAD),) - { - *(.lvgl_buf) - } GROUP_LINK_IN(SDRAM2) - -GROUP_END(SDRAM2) -#endif diff --git a/boards/st/stm32h757i_eval/CMakeLists.txt b/boards/st/stm32h757i_eval/CMakeLists.txt deleted file mode 100644 index 5b63ce05f245a..0000000000000 --- a/boards/st/stm32h757i_eval/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# -# Copyright (c) 2023 BrainCo Inc. -# Copyright (c) 2025 Foss Analytical A/S -# -# SPDX-License-Identifier: Apache-2.0 -# - -# Add custom linker section to relocate framebuffers to PSRAM -zephyr_linker_sources_ifdef(CONFIG_LV_Z_VDB_CUSTOM_SECTION - SECTIONS dc_ram.ld) diff --git a/boards/st/stm32h757i_eval/dc_ram.ld b/boards/st/stm32h757i_eval/dc_ram.ld deleted file mode 100644 index 56db3a2b997da..0000000000000 --- a/boards/st/stm32h757i_eval/dc_ram.ld +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2023 BrainCo Inc. - * Copyright (c) 2025 Foss Analytical A/S - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay) -GROUP_START(SDRAM2) - - SECTION_PROLOGUE(_STM32_SDRAM2_SECTION_NAME, (NOLOAD),) - { - *(.lvgl_buf) - } GROUP_LINK_IN(SDRAM2) - -GROUP_END(SDRAM2) -#endif diff --git a/boards/st/stm32h7b3i_dk/CMakeLists.txt b/boards/st/stm32h7b3i_dk/CMakeLists.txt deleted file mode 100644 index 67def763643c7..0000000000000 --- a/boards/st/stm32h7b3i_dk/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright (c) Charles Dias -# -# SPDX-License-Identifier: Apache-2.0 -# - -# Add custom linker section to relocate framebuffers to PSRAM -zephyr_linker_sources_ifdef(CONFIG_LV_Z_VDB_CUSTOM_SECTION - SECTIONS dc_ram.ld) diff --git a/boards/st/stm32h7b3i_dk/Kconfig.defconfig b/boards/st/stm32h7b3i_dk/Kconfig.defconfig index 66ba0bbfb810a..54b2cbb20a7b6 100644 --- a/boards/st/stm32h7b3i_dk/Kconfig.defconfig +++ b/boards/st/stm32h7b3i_dk/Kconfig.defconfig @@ -31,9 +31,12 @@ config LV_Z_DOUBLE_VDB config LV_Z_FULL_REFRESH default y -config LV_Z_VDB_CUSTOM_SECTION +config LV_Z_VDB_ZEPHYR_REGION default y +config LV_Z_VDB_ZEPHYR_REGION_NAME + default "SDRAM2" + config LV_Z_FLUSH_THREAD default y diff --git a/boards/st/stm32h7b3i_dk/dc_ram.ld b/boards/st/stm32h7b3i_dk/dc_ram.ld deleted file mode 100644 index 3f67ed559cb65..0000000000000 --- a/boards/st/stm32h7b3i_dk/dc_ram.ld +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Charles Dias - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(sdram2), okay) -GROUP_START(SDRAM2) - - SECTION_PROLOGUE(_STM32_SDRAM2_SECTION_NAME, (NOLOAD),) - { - *(.lvgl_buf) - } GROUP_LINK_IN(SDRAM2) - -GROUP_END(SDRAM2) -#endif diff --git a/modules/lvgl/Kconfig.memory b/modules/lvgl/Kconfig.memory index 50a14addf3096..ce4f82503ec3c 100644 --- a/modules/lvgl/Kconfig.memory +++ b/modules/lvgl/Kconfig.memory @@ -52,6 +52,21 @@ config LV_Z_MEMORY_POOL_CUSTOM_SECTION memory pool to a custom location, such as tightly coupled or external memory. +config LV_Z_MEMORY_POOL_ZEPHYR_REGION + bool "Place LVGL memory pool in a Zephyr memory-region" + depends on LV_Z_MEM_POOL_SYS_HEAP + depends on !LV_Z_MEMORY_POOL_CUSTOM_SECTION + help + Place LVGL memory pool in a section, automatically + created from a 'zephyr,memory-region' compatible node, + whose name is specified in LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME. + +config LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME + string "Name of the zephyr memory-region for memory pool" + depends on LV_Z_MEMORY_POOL_ZEPHYR_REGION + help + Name of the Zephyr memory-region where LVGL memory pool is placed. + config LV_Z_VDB_SIZE int "Rendering buffer size" default 100 if LV_Z_FULL_REFRESH @@ -92,6 +107,21 @@ config LV_Z_VDB_CUSTOM_SECTION rendering buffers to a custom location, such as tightly coupled or external memory. +config LV_Z_VDB_ZEPHYR_REGION + bool "Place LVGL rendering buffers in a Zephyr memory-region" + depends on LV_Z_BUFFER_ALLOC_STATIC + depends on !LV_Z_VDB_CUSTOM_SECTION + help + Place LVGL rendering buffers in a section, automatically + created from a 'zephyr,memory-region' compatible node, + whose name is specified in LV_Z_VDB_ZEPHYR_REGION_NAME. + +config LV_Z_VDB_ZEPHYR_REGION_NAME + string "Name of the Zephyr memory-region for rendering buffers" + depends on LV_Z_VDB_ZEPHYR_REGION + help + Name of the Zephyr memory-region where LVGL rendering buffers are placed. + config LV_Z_MONOCHROME_CONVERSION_BUFFER bool "Use intermediate conversion buffer for monochrome displays" default y diff --git a/modules/lvgl/lvgl.c b/modules/lvgl/lvgl.c index 014140daebc5d..79a6e1338fb94 100644 --- a/modules/lvgl/lvgl.c +++ b/modules/lvgl/lvgl.c @@ -78,22 +78,27 @@ static uint8_t *mono_vtile_buf_p[DT_ZEPHYR_DISPLAYS_COUNT] = {NULL}; /* uint16_t * or uint32_t *, therefore buffer needs to be aligned accordingly to */ /* prevent unaligned memory accesses. */ +#if defined(CONFIG_LV_Z_VDB_CUSTOM_SECTION) +#define LV_BUF_SECTION Z_GENERIC_SECTION(.lvgl_buf) +#elif defined(CONFIG_LV_Z_VDB_ZEPHYR_REGION) +#define LV_BUF_SECTION Z_GENERIC_SECTION(CONFIG_LV_Z_VDB_ZEPHYR_REGION_NAME) +#else +#define LV_BUF_SECTION +#endif + /* clang-format off */ #define LV_BUFFERS_DEFINE(n) \ static DISPLAY_BUFFER_ALIGN(LV_DRAW_BUF_ALIGN) uint8_t buf0_##n[BUFFER_SIZE(n)] \ - IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \ - __aligned(CONFIG_LV_Z_VDB_ALIGN); \ + LV_BUF_SECTION __aligned(CONFIG_LV_Z_VDB_ALIGN); \ \ IF_ENABLED(CONFIG_LV_Z_DOUBLE_VDB, ( \ static DISPLAY_BUFFER_ALIGN(LV_DRAW_BUF_ALIGN) uint8_t buf1_##n[BUFFER_SIZE(n)] \ - IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \ - __aligned(CONFIG_LV_Z_VDB_ALIGN); \ + LV_BUF_SECTION __aligned(CONFIG_LV_Z_VDB_ALIGN); \ )) \ \ IF_ENABLED(ALLOC_MONOCHROME_CONV_BUFFER, ( \ static uint8_t mono_vtile_buf_##n[BUFFER_SIZE(n)] \ - IF_ENABLED(CONFIG_LV_Z_VDB_CUSTOM_SECTION, (Z_GENERIC_SECTION(.lvgl_buf))) \ - __aligned(CONFIG_LV_Z_VDB_ALIGN); \ + LV_BUF_SECTION __aligned(CONFIG_LV_Z_VDB_ALIGN); \ )) FOR_EACH(LV_BUFFERS_DEFINE, (), LV_DISPLAYS_IDX_LIST); diff --git a/modules/lvgl/lvgl_mem.c b/modules/lvgl/lvgl_mem.c index eb7c1ddf19984..c8d18e9fbff90 100644 --- a/modules/lvgl/lvgl_mem.c +++ b/modules/lvgl/lvgl_mem.c @@ -15,6 +15,9 @@ LOG_MODULE_DECLARE(lvgl, CONFIG_LV_Z_LOG_LEVEL); #ifdef CONFIG_LV_Z_MEMORY_POOL_CUSTOM_SECTION #define HEAP_MEM_ATTRIBUTES Z_GENERIC_SECTION(.lvgl_heap) __aligned(8) +#elif defined(CONFIG_LV_Z_MEMORY_POOL_ZEPHYR_REGION) +#define HEAP_MEM_ATTRIBUTES Z_GENERIC_SECTION(CONFIG_LV_Z_MEMORY_POOL_ZEPHYR_REGION_NAME) + __aligned(8) #else #define HEAP_MEM_ATTRIBUTES __aligned(8) #endif /* CONFIG_LV_Z_MEMORY_POOL_CUSTOM_SECTION */