From cf73e90acd198207b7d41e25b7b1a59cbbd12254 Mon Sep 17 00:00:00 2001 From: Marek Matej Date: Wed, 11 Dec 2024 20:55:38 +0100 Subject: [PATCH] soc: esp32: Fix WiFi allocations to SPIRAM Fix allocations of large buffers if SPIRAM and WiFi alloc to SPIRAM are both enabled. Signed-off-by: Marek Matej --- soc/espressif/esp32/default.ld | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/soc/espressif/esp32/default.ld b/soc/espressif/esp32/default.ld index d084228f1aa7c4..4c18043ca33f23 100644 --- a/soc/espressif/esp32/default.ld +++ b/soc/espressif/esp32/default.ld @@ -680,10 +680,27 @@ SECTIONS .dram0.noinit (NOLOAD) : { - . = ALIGN (8); + . = ALIGN (4); + __dram_noinit_start = ABSOLUTE(.); +#ifdef CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM + *(EXCLUDE_FILE( + *libdrivers__wifi.a:* + *libsubsys__net__l2__ethernet.a:* + *libsubsys__net__lib__config.a:* + *libsubsys__net__ip.a:* + *libsubsys__net.a:* ) .noinit) + *(EXCLUDE_FILE( + *libdrivers__wifi.a:* + *libsubsys__net__l2__ethernet.a:* + *libsubsys__net__lib__config.a:* + *libsubsys__net__ip.a:* + *libsubsys__net.a:* ) .noinit.*) +#else *(.noinit) *(.noinit.*) - . = ALIGN (8); +#endif /* CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM */ + __dram_noinit_end = ABSOLUTE(.); + . = ALIGN (4); } GROUP_LINK_IN(RAMABLE_REGION) /* Provide total SRAM usage, including IRAM and DRAM */ @@ -700,7 +717,8 @@ SECTIONS #ifdef CONFIG_ESP_SPIRAM .ext_ram.bss (NOLOAD): { - _ext_ram_data_start = ABSOLUTE(.); + _ext_ram_start = ABSOLUTE(.); + _ext_ram_noinit_start = ABSOLUTE(.); #ifdef CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM *libdrivers__wifi.a:(.noinit .noinit.*) @@ -709,14 +727,19 @@ SECTIONS *libsubsys__net__ip.a:(.noinit .noinit.*) *libsubsys__net.a:(.noinit .noinit.*) #endif /* CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM */ + . = ALIGN(16); + _ext_ram_noinit_end = ABSOLUTE(.); _ext_ram_bss_start = ABSOLUTE(.); *(.ext_ram.bss*) + . = ALIGN(16); _ext_ram_bss_end = ABSOLUTE(.); + _spiram_heap_start = ABSOLUTE(.); . = . + CONFIG_ESP_SPIRAM_HEAP_SIZE; + . = ALIGN(4); - _ext_ram_data_end = ABSOLUTE(.); + _ext_ram_end = ABSOLUTE(.); } GROUP_LINK_IN(ext_ram_seg) #endif /* CONFIG_ESP_SPIRAM */ @@ -900,6 +923,6 @@ SECTIONS /* --- XTENSA GLUE AND DEBUG END --- */ #ifdef CONFIG_ESP_SPIRAM -ASSERT(((_ext_ram_data_end - _ext_ram_data_start) <= CONFIG_ESP_SPIRAM_SIZE), +ASSERT(((_ext_ram_end - _ext_ram_start) <= CONFIG_ESP_SPIRAM_SIZE), "External SPIRAM overflowed.") #endif /* CONFIG_ESP_SPIRAM */