boards/risc-v/esp32p4: add sram_high as second heap region for rev < v3

On ESP32-P4 rev < v3, the 768KB HP L2MEM is split into two
non-contiguous regions: sram_low and sram_high. Previously only
sram_low was used for the heap, wasting 384KB of sram_high.

Export _sram_high_heap_start and _sram_high_heap_end symbols from
the linker script and add sram_high to the heap via kumm_addregion()
in riscv_addregion() when MM_REGIONS > 1.

Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
likun17
2026-03-18 19:39:01 +08:00
committed by simbit18
parent 81602e16a2
commit b606180da9
2 changed files with 19 additions and 0 deletions
@@ -102,6 +102,21 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
#if CONFIG_MM_REGIONS > 1
void riscv_addregion(void)
{
#if defined(CONFIG_ESP32P4_SELECTS_REV_LESS_V3)
/* ESP32-P4 rev < v3 has non-contiguous SRAM: sram_low + sram_high.
* The primary heap is in sram_low. Add sram_high as a second region.
*/
extern uint8_t _sram_high_heap_start[];
extern uint8_t _sram_high_heap_end[];
size_t region_size = _sram_high_heap_end - _sram_high_heap_start;
if (region_size > 0)
{
kumm_addregion(_sram_high_heap_start, region_size);
}
#endif
}
#endif
@@ -690,6 +690,10 @@ SECTIONS
_bss_end_high = ABSOLUTE(.);
} > sram_high
/* Heap region for sram_high: from end of bss to end of sram_high segment */
_sram_high_heap_start = _bss_end_high;
_sram_high_heap_end = ORIGIN(sram_high) + LENGTH(sram_high);
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }