Calculating ESP32 Custom Partitions

If you find you need more space for your sketch, SPIFFS/FATFS/LittleFS Data, EEPROM or other NVS data, you can customize the partitions in Visual Micro.

Note IconCompatability Note:

Your chip will need to have enough total available space for the entire partition table, many ESP32 Chips are only 4MB, but are available in 8MB and 16MB flavours.

See the Checking Your Chip Size section further down this page.

Useful Tools

ESP32 Partition Documentation: https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/tutorials/partition_table.html

ESP32 Calculator (Google Sheets): https://www.esp32.com/viewtopic.php?f=18&t=18575

Hex Calculator: https://www.calculator.net/hex-calculator.html

 

Example: Adapting a Partition Table for 1920KB of Application with OTA

Imagine we have the below partition Table for an ESP32:

    
# Name,   Type, SubType, Offset,  Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 180000,
app1, app, ota_1, 0x1F0000,180000,
eeprom, data, 0x99, 0x3D0000,0x1000,
spiffs, data, spiffs, 0x3D1000,0x2F000,

Total Size: 337000 (Hex), 3371008b (Dec) => 3,292KB

 

This allows for 1536KB of Program code, along with OTA Upload, 4KB of EEPROM Data, 188KB of SPIFFS Data and 20KB of NVS data.

If we want to grow the total amount of program (and OTA) space, we will need to adjust the app0 and app1 partitions:

Current: 180000 (Hex) => 1572864b (Dec) => 1536KB

So in reverse we can calculate our Hex value for our new Partitions:

1920KB => 1966080 (Dec) => 1400000b (Hex)

This would give us the below parititon table:

    
# Name,   Type, SubType, Offset,  Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1E0000,
app1, app, ota_1, 0x1F0000,0x1E0000,
eeprom, data, 0x99, 0x3D0000,0x1000,
spiffs, data, spiffs, 0x3D1000,0x2F000,

Total Size: 3F7000 (Hex), 4157440b (Dec) => 4,060KB

 

Using Custom Partitions Files

Simply save your partitions scheme to a file called partitions.csv in your sketch folder (next to your ino file).  It will automatically used in your next compilation and upload.

 

Checking your Chip Size

To find out how much space you have avialable on your ESP32, you can use the esptool.exe which is included in the board package.

If you installed the ESP32 board package via Board Manager, it will be in the %LOCALAPPDATA%\Arduino15\packages\esp32\tools\esptool_py\<Version>\esptool.exe folder.

If you connect your board to your machine, and check which COM port it is on, you can then run the below command to report the chip size:

esptool.exe --chip auto --port COM15 flash_id

 

Example Output: