Open AntoineSX opened 1 year ago
@AntoineSX Thanks for reporting this!
We'll take a look at it.
Any update ?
Sorry for the delay! We'll prioritize closing this one next week.
Unfortunately I dont think the proposed change will work, since as far as I can see the trace memory blocks on ESP32 are fixed, so just reserving a different memory are wont work.
I think the fix will be to not allow these to be used together (like we already did for ESP32_TRAX
)
Answers checklist.
IDF version.
v5.1-dev-4900-g56677dabe8
Operating System used.
Linux
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
What is the expected behavior?
No assertions, no memory region collision
What is the actual behavior?
Panic abort caused by overlapping memory regions during heap init
Steps to reproduce.
Build or installation Logs.
More Information.
I'm using an ESP32-WROVER-E module.
I did some digging around and found that in the linker script for the ESP32 family and the c file memory_layout.c contain some errors. The commit in question is
34fea0d38faec37df4492835e7d4ebf6aee55b8a
memory.ld.in:
if SRAM1_IRAM_LEN is 0xA000, _sram1_iram_len will be:
_sram1_iram_len = 0x40080000 + 0x20000 + 0xA000 - 0x400A0000
_sram1_iram_len = 0xA000
and so:
_heap_end = ALIGN(0x40000000 - 0xA000 - 3,4)
_heap_end = 0x3FFF5FFC
But when JTAG is enabled (without TRAX) tracemem_reserver_dram is 0x8000 bytes (32KB). which mean _heap_end will be redefined as:
_heap_end = 0x40000000 - 0x8000
_heap_end = 0x3FFF8000
It seems like that line doesn't take into account the offset caused by the _sram1_iram_len so I changed that part of the linker script to:
I'm not sure why an ALIGN was added in that same commit, as both sram1_iram_len and 0x40000000 are already 32bit aligned, and I'm also not sure why it wasn't also used for the _heap_end assignment when
CONFIG_ESP32_TRACEMEM_RESERVE_DRAM != 0
. In my case I just didn't use ALIGN, but it might be a mistake on my part.Then I had to redefine the memory regions for tracemem in the
memory_layout.c
file of the esp32 taking that offset into account.Before:
After:
Here's a diagram that helped me visualize the sram segments: