Unlocking entire FLASH for ESP32

Hello everyone,

I have an ESP32 that is advertising as having 4MB of Flash. However, when I go to build and upload, the max size is just a little over 1 MB.

How can I unlock the entire 4MB of Flash for use? I understand that some it may be used for system variables and what not.

Just for reference, I have a program that does use the Flash to store files (basically EEPROM emulator). Both files are 100 kb max. What I want to do is implement firmware OTA updates. From the libraries that I am looking to use, it appears that what they do is that they download the new firmware to a separate partition and then swap old firmware with the new one and reboot. According to the output, my program is taking up almost 70% of flash. But it lists the max size as just shy of 1 MB.

I know that I have more but I want to know how I can unlock to use more.

The flash memory of the ESP32 is divided into several partitions.
The standard partition table divides the flash memory as follows:


# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x140000,
app1,     app,  ota_1,   0x150000,0x140000,
spiffs,   data, spiffs,  0x290000,0x160000,
coredump, data, coredump,0x3F0000,0x10000,

Meanings and size in kB:

NVS data      20 kB (nvs storage)
OTA data       8 kB (ota configuration)
APP0        1280 kB (this is where your app goes)
APP1        1280 kB (this is where your app goes)
SPIFFS      1408 kB (data partition)
COREDUMP      64 kB (coredump goes here)
sum         4060 kB

The first 36 kB of the flash memory are reserved and cannot be used.
For this reason, the first partition starts at offset 0x9000.
36 kB + 4060 kb make up the 4 MB of your ESP32.

This means that 1280 kB (1310720 bytes) are available for your app.
The 70% refers to this size.

Two app partitions of the same size are required to use OTA.
One partition is active and an update is saved to the other.
If an update is successful, the system switches between the partitions.

You can create your own partition table that works with a different partitioning. See Espressif 32 — PlatformIO latest documentation

For example, you can reduce the size of the SPIFFS partition and increase the size of the two app partitions. Details on the structure of the partition table can be found at Partition Tables - ESP32 - — ESP-IDF Programming Guide latest documentation

Please note the information on the offset and sizes of the various partitions at Partition Tables - ESP32 - — ESP-IDF Programming Guide latest documentation

Great Thank you for the detailed and thorough explanation!