Stack vs Heap in RAM
RP2350 SRAM: Data, BSS, Heap, Stack
SRAM Layout
0x2008_2000 (top)
STACK
Grows DOWN
SP = top of stack
FREE SPACE
HEAP
Grows UP
heap_base = __end__
.data + .bss
0x2000_0000 (base)
How To Read Sizes Quickly
1) .data size
__data_end__ - __data_start__
init non-zero globals/statics
2) .bss size
__bss_end__ - __bss_start__
zero/uninit globals/statics
3) Heap starts at
__end__ (aka __HeapBase)
4) Stack starts at
vector_table[0] (initial SP)
typical: 0x20082000 on RP2350
5) Safety rule
Heap must never collide with stack