Page 1 of 1

Flash memory size, compared to compiled size

Posted: Sat Mar 29, 2025 2:15 pm
by k4kvglen

Code: Untitled.txt Select all

Hello,
First post. Long time assembly and C programmer. Fairly new to ESP32 chips.
I have bought a variety of ESP32 development boards, 8266, S2, and C3 type.

I have been confused on the specs saying 384k of flash rom, but my compiled code says 1.85Mb (for example).
I see a chip says 384k of flash rom, but then says 4Mb.

Can someone provide a link that explains the internal flash vs external flash? How can one execute code from external
flash, seeing that it is probably serial rom memory?

I am amazed so far to see how many hundreds(thousands) of modules get compiled to produce the code. I am almost exclusively using esphome now and yaml.
Thanks in advance
Glen K4KV

Re: Flash memory size, compared to compiled size

Posted: Sun Mar 30, 2025 6:54 am
by Sprite
The 384K is not flash ROM, it's ordinary ROM: the contents are set in the factory and you can never ever erase or reprogram it (without physically changing the die). It contains e.g. the bootloader. ESP32 chips have their user program in a SPI flash chip or die. This chip can be internal to the ESP32 package or an external part and they tend to be 2MiB or larger.

ESP32 chips execute code from external flash using a cache which allows the entire flash to be accessed like it were any other ordinary memory (like RAM). It's got a few quirks but otherwise works mostly transparent.

Re: Flash memory size, compared to compiled size

Posted: Tue Apr 15, 2025 6:51 pm
by Aria James
The ESP32 uses external flash (typically 4MB or more) for storing firmware, while the internal ROM is used for boot and essential operations. The code executes from external flash via the SPI interface, with the bootloader managing loading it into memory.