How to Specify the Partition Table for Writing to ESP32
This article introduces an advanced topic (how to specify the partition table of the flash area).
If you use the partition table settings included by default in the ESP32 Arduino Core (e.g., Default 4MB with spiffs), you can ignore this article.
Creating the Definition File
The partition table is defined in a csv file.
In the example below, out of the 16MB flash area, 8MB is allocated for the file system.
# TWELITE SPOT 16MB with 8MB LittleFS
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xE000, 0x2000,
app0, app, ota_0, 0x10000, 0x7F0000,
spiffs, data, spiffs, 0x800000, 0x800000,
TWELITE SPOT 16MB with 8MB LittleFS
is the name displayed in the Arduino IDE.nvs
is the area used by the system. Do not change.otadata
is the area used when using OTA. Do not change.app0
is the area where the firmware is written.spiffs
is the area used by the LittleFS file system.
The units of the Offset
and Size
columns in the csv file are bytes, expressed in hexadecimal.
Therefore, the usable sizes for firmware and file system in the above example can be calculated as follows:
- Size of
app0
:0x7F0000 = 8323072
, approximately7.875MB
- Size of
spiffs
:0x800000 = 8388608
, exactly8MB
Registering the Definition File
Open the Arduino15 folder and add the csv file to the following path:
Arduino15/packages/esp32/hardware/esp32/x.x.x/tools/partitions
x.x.x
is the version of Arduino core for the ESP32
Applying the Partition Table
From the Arduino IDE toolbar, open Tools -> Partition Scheme and select the added partition table.
The selected partition table will be applied to subsequent firmware and file system writes.
partitions.csv
is placed in the same location as the sketch file, that file takes precedence. However, the display in the Arduino IDE does not change, which may cause confusion.