From 648bfe090c48fa92c37e6889aa8062838603e751 Mon Sep 17 00:00:00 2001 From: Marek Matej Date: Thu, 5 Jun 2025 15:42:03 +0200 Subject: [PATCH] soc: espressif: Support large buffers in custom PSRAM sections Several subsystems have configuration options that allow large buffers to be placed in specialized memory sections. When PSRAM is enabled, the MBEDTLS heap and LVGL heap and buffer can be relocated to custom sections within the PSRAM segment. Enabling `CONFIG_ESP_SPIRAM` together with any of the following options: * `CONFIG_MBEDTLS_HEAP_CUSTOM_SECTION` * `CONFIG_LV_Z_MEMORY_POOL_CUSTOM_SECTION` * `CONFIG_LV_Z_VDB_CUSTOM_SECTION` will place the corresponding buffers into the `.mbedtls_heap`, `.lvgl_heap`, and `.lvgl_buf` sections, respectively. If none of these custom section options are enabled, the buffers will fall back to the `.ext_ram.bss` section. Signed-off-by: Marek Matej --- soc/espressif/esp32/default.ld | 9 +++++++++ soc/espressif/esp32s2/default.ld | 9 +++++++++ soc/espressif/esp32s3/default.ld | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/soc/espressif/esp32/default.ld b/soc/espressif/esp32/default.ld index e4e95668004..061cb73a3a5 100644 --- a/soc/espressif/esp32/default.ld +++ b/soc/espressif/esp32/default.ld @@ -845,6 +845,15 @@ SECTIONS _ext_ram_bss_start = ABSOLUTE(.); *(.ext_ram.bss*) . = ALIGN(16); + + /* Custom modules sections list */ + KEEP(*(.lvgl_buf*)) + . = ALIGN(16); + KEEP(*(.lvgl_heap*)) + . = ALIGN(16); + KEEP(*(.mbedtls_heap*)) + . = ALIGN(16); + _ext_ram_bss_end = ABSOLUTE(.); _ext_ram_heap_start = ABSOLUTE(.); diff --git a/soc/espressif/esp32s2/default.ld b/soc/espressif/esp32s2/default.ld index 623e061f8a9..957cd8eb203 100644 --- a/soc/espressif/esp32s2/default.ld +++ b/soc/espressif/esp32s2/default.ld @@ -810,6 +810,15 @@ SECTIONS _ext_ram_bss_start = ABSOLUTE(.); *(.ext_ram.bss*) . = ALIGN(16); + + /* Custom modules sections list */ + KEEP(*(.lvgl_buf*)) + . = ALIGN(16); + KEEP(*(.lvgl_heap*)) + . = ALIGN(16); + KEEP(*(.mbedtls_heap*)) + . = ALIGN(16); + _ext_ram_bss_end = ABSOLUTE(.); _ext_ram_heap_start = ABSOLUTE(.); diff --git a/soc/espressif/esp32s3/default.ld b/soc/espressif/esp32s3/default.ld index bba2fc40c4a..dfb7d4c159a 100644 --- a/soc/espressif/esp32s3/default.ld +++ b/soc/espressif/esp32s3/default.ld @@ -1018,8 +1018,18 @@ SECTIONS _ext_ram_bss_start = ABSOLUTE(.); *(.ext_ram.bss*) . = ALIGN(16); + + /* Custom modules sections list */ + KEEP(*(.lvgl_buf*)) + . = ALIGN(16); + KEEP(*(.lvgl_heap*)) + . = ALIGN(16); + KEEP(*(.mbedtls_heap*)) + . = ALIGN(16); + _ext_ram_bss_end = ABSOLUTE(.); + /* Used by Shared Multi Heap */ _ext_ram_heap_start = ABSOLUTE(.); . += CONFIG_ESP_SPIRAM_HEAP_SIZE; . = ALIGN(16);