ESP32 Memory Layout and Usage

CodeWithM
Posts: 2
Joined: Mon Jul 25, 2022 8:00 am

ESP32 Memory Layout and Usage

Postby CodeWithM » Mon Jul 25, 2022 1:32 pm

Hi,
I am looking at the memory usage of my project and I find it a bit strange. You can see the following photo:
esp32 memory usage .PNG
esp32 memory usage .PNG (9.51 KiB) Viewed 1326 times
The esp32 should have the following RAM memory: SRAM0 (192KB), SRAM1(128KB) and SRAM2 (200KB).

From what I can see in the documentation and the linker script the first 64KB of SRAM0 are used for caching and the remainder 128KB is IRAM and this is the memory region iram0_0_seg. This looks fine.

What I find strange is the iram0_2_seg which is huge. I don't get why it is so big and for what it is used. Also there was a comment in the linker script that says
"Even though the segment name is iram, it is actually mapped to flash."
Can somebody explain what is the intention behind this?

I would expect both SRAM1 and SRAM2 to be used for the DRAM.
And if we take out the 8KB used by ROM it should come to 320KB however seems like this section is only around 121.6KB in my case.
For dram0_0_seg in the linker script the following is mentioned
"Shared data RAM, excluding memory reserved for ROM bss/data/stack.

Enabling Bluetooth & Trace Memory features in menuconfig will decrease the amount of RAM available
Note: Length of this section *should* be 0x50000 = 320KB, and this extra DRAM is available in heap at runtime. However due to static ROM memory usage at this 176KB mark, the additional static memory temporarily cannot be used."
I don't quite understand the bolded part. Does this mean that 320 - 176 = 144KB of memory is used for the ROM, bss, data and stack?
I suppose that I only have 121KB for this region that will be used for the heap because I am using the BT stack which should be 54KB so we get 176KB - 54KB = 122KB.. But I am not sure because in the newer documentation it's mentioned that 64KB are used for the BT stack (maybe that's just a typo). Can anyone share his thoughts on this?

Who is online

Users browsing this forum: No registered users and 100 guests