cpu/esp32: fix heap definition for ESP32-S2 and ESP32-S3 #19956
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
For ESP32-S2 and ESP32-S3 the symbol
_heap_end
must not be used as_eheap
for the newlibcmalloc
and functionsbrk
._heap_end
is used by the ESP-IDF heap implementationesp-idf-heap
and points to the highest possible address (0x40000000) that could be used for the heap in ESP-IDF. It doesn't point to the top address of the unused SRAM area that can be used in newlibcmalloc
and functionsbrk
. Instead, the origin and the length ofdram0_0_seg
must be used to calculate the end of the heap_eheap
.The problem only occurs for the newlibc
malloc
when thesbrk
function is used but not for the ESP-IDF heap implementationesp_idf_heap
.Testing procedure
Use any ESP32-S2 or ESP32-S3 board and flash
tests/sys/malloc
, e.g.Without the PR the
nm
command will give the wrong addressThe test will stuck, i.e. the allocation of memory stops when the top of unused SRAM is reached and the board restarts when the watchdog timer expires. With the PR it should work as expected
With this PR the
nm
command should give a address in unused SRAM address spaceand the test should pass.
Issues/PRs references