Skip to main content
  1. Blogs/

ESP32 Partition Calculations

·284 words·2 mins
Owen O'Hehir
Author
Owen O’Hehir
Dublin-based embedded Linux, IoT and Matter consultant. Helping startups and product teams design, prototype and ship connected devices.

ESP32 Partition Size Calculations
#

How to calculate and configure ESP32 flash partitions for OTA updates, NVS and SPIFFS. A practical walkthrough from an embedded engineering consultancy.

ESP32 modules come in various flash memory sizes, the most common being 4MB, but 8MB & 16MB modules are available. The flash memory needs to be partitioned depending on requirements & constraints.

The requirements include:

  • Is over the air (OTA) updating feature required?
  • Is the main application (app) substantial in size?
  • Is a basic file system (e.g. SPIFFS) required?

Constraints include:

  • Offset must be a multiple of 4 KB / 0x1000
  • Type app partitions have to be placed at offsets aligned to 0x10000 (64 K)
  • The bootloader & partition table occupy the region 0x0 to 0x9000

Some ‘standard’ partition schemes for the 4MB module are:

“Single factory app, no OTA”

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 1M,

“Factory app, two OTA definitions” configuration

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x4000,
otadata,  data, ota,     0xd000,  0x2000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000,  1M,
ota_0,    app,  ota_0,   0x110000, 1M,
ota_1,    app,  ota_1,   0x210000, 1M,

Tables can be further complicated with multiple OTA partitions.

Creating your own table to support a different layout or different sized module can require some tedious calculations. To save time, use the following tool — just input the module size & required SPIFFS size and the table will be generated for you:

Download ESP32 Partition Generator

TODO: image description

If you need help with production-grade ESP32 firmware or partitioning, take a look at our Software Development services.