soc: xtensa: espressif_esp32: add SPIRAM heap offset and size
The existing heap starts at the beginning of SPIRAM which is also occupied by the WiFi stack if CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM is enabled. This results in memory corruption. Update the linker description to add a _spiram_heap_start symbol and add a KConfig size option to allow the SPIRAM stack to be correctly located and sized. Requires matching commit in hal_espressif. Fixes: 61359 Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
This commit is contained in:
parent
d9fe63b188
commit
526ff047cc
6 changed files with 37 additions and 7 deletions
|
@ -37,6 +37,14 @@ config ESP_HEAP_SEARCH_ALL_REGIONS
|
|||
regions. If the region of desired capability is exhausted,
|
||||
memory will be allocated from other available region.
|
||||
|
||||
config ESP_SPIRAM_HEAP_SIZE
|
||||
int "Size of SPIRAM heap"
|
||||
default 262134 if SYS_HEAP_SMALL_ONLY
|
||||
default 1048576 if !SYS_HEAP_SMALL_ONLY
|
||||
depends on ESP_SPIRAM
|
||||
help
|
||||
Specify size of SPIRAM heap.
|
||||
|
||||
menu "SPI RAM config"
|
||||
depends on ESP_SPIRAM
|
||||
|
||||
|
|
|
@ -453,9 +453,12 @@ SECTIONS
|
|||
*libsubsys__net__ip.a:(.noinit .noinit.*)
|
||||
*libsubsys__net.a:(.noinit .noinit.*)
|
||||
#endif
|
||||
_spiram_heap_start = ABSOLUTE(.);
|
||||
. = . + CONFIG_ESP_SPIRAM_HEAP_SIZE;
|
||||
|
||||
*(.ext_ram.bss*)
|
||||
_ext_ram_data_end = ABSOLUTE(.) + CONFIG_ESP_SPIRAM_SIZE;
|
||||
|
||||
_ext_ram_data_end = ABSOLUTE(.);
|
||||
} GROUP_LINK_IN(ext_ram_seg)
|
||||
#endif
|
||||
|
||||
|
@ -581,3 +584,8 @@ _heap_sentry = 0x3ffe3f20;
|
|||
|
||||
ASSERT(((_iram_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
|
||||
"IRAM0 segment data does not fit.")
|
||||
|
||||
#if defined(CONFIG_ESP_SPIRAM)
|
||||
ASSERT(((_ext_ram_data_end - _ext_ram_data_start) <= CONFIG_ESP_SPIRAM_SIZE),
|
||||
"External SPIRAM overflowed.")
|
||||
#endif /* CONFIG_ESP_SPIRAM */
|
||||
|
|
|
@ -333,6 +333,7 @@ SECTIONS
|
|||
#if defined(CONFIG_ESP_SPIRAM)
|
||||
.ext_ram.bss (NOLOAD):
|
||||
{
|
||||
_ext_ram_data_start = ABSOLUTE(.);
|
||||
_ext_ram_bss_start = ABSOLUTE(.);
|
||||
|
||||
#if defined(CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM)
|
||||
|
@ -342,10 +343,14 @@ SECTIONS
|
|||
*libsubsys__net__ip.a:(.noinit .noinit.*)
|
||||
*libsubsys__net.a:(.noinit .noinit.*)
|
||||
#endif
|
||||
_spiram_heap_start = ABSOLUTE(.);
|
||||
. = . + CONFIG_ESP_SPIRAM_HEAP_SIZE;
|
||||
|
||||
*(.ext_ram.bss*)
|
||||
. = ALIGN(4);
|
||||
_ext_ram_bss_end = ABSOLUTE(.) + CONFIG_ESP_SPIRAM_SIZE;
|
||||
_ext_ram_bss_end = ABSOLUTE(.);
|
||||
|
||||
_ext_ram_data_end = ABSOLUTE(.);
|
||||
} > ext_ram_seg
|
||||
#endif
|
||||
|
||||
|
@ -555,3 +560,8 @@ ASSERT(((__bss_end - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)),
|
|||
|
||||
ASSERT(((_iram_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
|
||||
"IRAM0 segment data does not fit.")
|
||||
|
||||
#if defined(CONFIG_ESP_SPIRAM)
|
||||
ASSERT(((_ext_ram_data_end - _ext_ram_data_start) <= CONFIG_ESP_SPIRAM_SIZE),
|
||||
"External SPIRAM overflowed.")
|
||||
#endif /* CONFIG_ESP_SPIRAM */
|
||||
|
|
|
@ -231,6 +231,7 @@ SECTIONS
|
|||
/* This section holds .ext_ram.bss data, and will be put in PSRAM */
|
||||
.ext_ram.bss (NOLOAD) :
|
||||
{
|
||||
_ext_ram_data_start = ABSOLUTE(.);
|
||||
_ext_ram_bss_start = ABSOLUTE(.);
|
||||
*(.ext_ram.bss*)
|
||||
. = ALIGN(4);
|
||||
|
@ -246,6 +247,10 @@ SECTIONS
|
|||
*libsubsys__net__ip.a:(.noinit .noinit.*)
|
||||
*libsubsys__net.a:(.noinit .noinit.*)
|
||||
#endif
|
||||
_spiram_heap_start = ABSOLUTE(.);
|
||||
. = . + CONFIG_ESP_SPIRAM_HEAP_SIZE;
|
||||
|
||||
_ext_ram_data_end = ABSOLUTE(.);
|
||||
} > ext_ram_seg
|
||||
#endif
|
||||
|
||||
|
@ -678,6 +683,6 @@ ASSERT(((_iram_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
|
|||
"IRAM0 segment data does not fit.")
|
||||
|
||||
#if defined(CONFIG_ESP_SPIRAM)
|
||||
ASSERT(((ORIGIN(ext_ram_seg)) > _image_rodata_end),
|
||||
"External RAM segment does not fit.")
|
||||
#endif
|
||||
ASSERT(((_ext_ram_data_end - _ext_ram_data_start) <= CONFIG_ESP_SPIRAM_SIZE),
|
||||
"External SPIRAM overflowed.")
|
||||
#endif /* CONFIG_ESP_SPIRAM */
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
CONFIG_ESP_SPIRAM=y
|
||||
CONFIG_ESP_HEAP_MIN_EXTRAM_THRESHOLD=2048
|
||||
CONFIG_HEAP_MEM_POOL_SIZE=98304
|
||||
CONFIG_ESP_HEAP_MEM_POOL_REGION_1_SIZE=100000
|
||||
CONFIG_ESP_HEAP_SEARCH_ALL_REGIONS=n
|
||||
CONFIG_FLASH=y
|
||||
CONFIG_ENTROPY_GENERATOR=y
|
||||
|
|
2
west.yml
2
west.yml
|
@ -152,7 +152,7 @@ manifest:
|
|||
groups:
|
||||
- hal
|
||||
- name: hal_espressif
|
||||
revision: ec90f3c49e3826ef2c56c5381aa068c4f482b31f
|
||||
revision: 80d910ca89eab9bce03f59a4ade33f1fc30ce0ad
|
||||
path: modules/hal/espressif
|
||||
west-commands: west/west-commands.yml
|
||||
groups:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue