Flash memory size, compared to compiled size

k4kvglen
Posts: 1
Joined: Sat Mar 29, 2025 2:01 pm

Flash memory size, compared to compiled size

Postby k4kvglen » Sat Mar 29, 2025 2:15 pm

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

Sprite
Espressif staff
Espressif staff
Posts: 10596
Joined: Thu Nov 26, 2015 4:08 am

Re: Flash memory size, compared to compiled size

Postby Sprite » Sun Mar 30, 2025 6:54 am

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.

Aria James
Posts: 10
Joined: Tue Mar 11, 2025 6:42 pm

Re: Flash memory size, compared to compiled size

Postby Aria James » Tue Apr 15, 2025 6:51 pm

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.

Who is online

Users browsing this forum: No registered users and 4 guests