ESP32/Storage/39. Partition tables and flash size
Your chip
Your language
Storage · 39 of 81

Partition tables and flash size

A menu item most people pick without reading decides whether OTA is possible, how big a sketch may be, and how much room is left for files. It is written into the flash when you upload, and changing it later erases everything.

/esp32/partition-tables-and-flash-size · arduino · S3

What each scheme gives you

Default 4MB with spiffs
OTA possible
Compiled sketch1.10 MB
Files you need to store0.30 MB
App slot
1.25 MB
Filesystem
1.44 MB
OTA
yes
Everything fits, and there is a second app slot for updates. Remember the cost of changing your mind: reflashing with a different table moves every boundary, so stored preferences and uploaded files do not survive it. Decide this before the device leaves your desk.

Decide it once, at the start

The table is written by the uploader, so changing it moves every boundary. NVS moves, the filesystem moves, and everything stored in either is gone. That is fine on day one and expensive on day two hundred.

Pick a scheme that leaves headroom for the libraries you have not added yet. BLE, HTTPS and a display driver together are well over a megabyte before your own code exists.

When the default is not enough

  • BLE plus OTA on 4 MB — tight. Use NimBLE, or buy an 8 MB board.
  • A camera — you want PSRAM more than flash, but also a big app slot.
  • A web interface with real assets — a bigger filesystem, or serve them from a microSD card.

Custom tables are a CSV file next to your sketch, and easier than they look. The IDE picks up partitions.csv from the sketch folder automatically.

On your S3
ChipXtensa LX7 · 2 × 240 MHz
Board settingESP32S3 Dev Module
Default I2CSDA 8 · SCL 9
Watch out forThe port vanishes after upload

The code

Print the table the board is actually running. It takes ten seconds and settles arguments about what scheme got flashed, which the IDE menu will not tell you after the fact.

report_partitions.ino
#include <esp_partition.h>
#include <esp_ota_ops.h>

void setup() {
  Serial.begin(115200);
  delay(200);

  esp_partition_iterator_t it =
    esp_partition_find(ESP_PARTITION_TYPE_ANY,
                       ESP_PARTITION_SUBTYPE_ANY, nullptr);
  while (it) {
    const esp_partition_t *p = esp_partition_get(it);
    Serial.printf("%-10s type %d sub %2d at 0x%06X size %7u\n",
                  p->label, p->type, p->subtype, p->address, p->size);
    it = esp_partition_next(it);
  }

  const esp_partition_t *run = esp_ota_get_running_partition();
  Serial.printf("running from %s, sketch uses %u of %u\n",
                run->label, ESP.getSketchSize(), run->size);
}

void loop() {}

getSketchSize against the app partition size is the number behind Sketch too big. Watch it as you add libraries rather than discovering it at the end.

When it does not work

Sketch too big, and the board has 4 MB

Half of it is the second OTA slot and a chunk is the filesystem. The app partition is what your code has to fit in, not the flash size.

Files and settings disappeared after a firmware update

The partition scheme changed, so every boundary moved. Fix the scheme at the start of a project and never change it in the field.

The IDE says my board has 4 MB and esptool says 16

The Flash Size menu item is a claim, not a detection. Set it to what the board actually has, or you get a table that ends before the flash does.

OTA fails with not enough space

You are on a no-OTA scheme. There is no second slot to write into, and the error arrives at the end of the download rather than the start.

Where this goes next

Storage sorted. The next chapter is the reason most people bought this chip: getting it onto a network.

Wi-Fi station mode

Edit this page — content/esp32/partition-tables-and-flash-size.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse ESP32 on the forum