Open hawkw opened 1 year ago
the memory region used for the stack and heap is 300KB.
That's for now.
The region is also used for statics, and I have no idea if code size factors into it. Since heap + stack is "whatever you didn't use for other stuff", that size is likely to decrease as time goes on.
Something we COULD do is figure out how to modify/extend the esp32c3 linker scripts, in particular to:
Until we have something like cargo-call-stack, the minimum stack size is going to be a best estimate, but that is better than the current "lol cross your fingers" approach.
Where are statics placed in this region? Does more statics bring the heap start towards the stack start, or the stack start towards the heap start?
All links from chat yesterday:
The full layout is here (if we are using mb
mode?):
https://github.com/esp-rs/esp-hal/blob/main/esp32c3-hal/ld/mb-riscv-link.x#L41-L204
But tl;dr:
.data
and .bss
)
we currently have the heap hardcoded to 32KB. this is quite small, especially for async, because each async task is essentially moving a bit of stack into the heap.
@jamesmunns looked at the
esp32c3-hal
crate's linker script and determined that the memory region used for the stack and heap is 300KB.we could probably get away with at least a 64KB heap before we have a significant danger of getting clobbered by a rogue stack frame. even 100KB is probably fine...