How to use custom partition tables on ESP32 | by Pedro Minatel | The ESP Journal | Feb, 2021

Spread the love


To show the usage of custom partition tables, we will create a quite simple demo with an extended NVS partition and one partition for SPIFFS alongside the default partitions and OTA.

ESP32-DevKitC V4
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags

nvs,
data, nvs, 0x9000, 0x6000,
otadata,
data, ota, 0xf000, 0x2000,
ota_0,
app, ota_0, 0x20000, 0x200000,
ota_1,
app, ota_1, 0x220000, 0x200000,
storage,
data, spiffs, 0x420000, 0x200000,
nvs_ext,
data, nvs, 0x620000, 0x10000,
idf.py -p <COM_PORT> flash monitor
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
otadata, data, ota, 0xf000, 0x2000,
ota_0, app, ota_0, 0x20000, 0x200000,
ota_1, app, ota_1, 0x220000, 0x200000,
storage, data, spiffs, 0x420000, 0x200000,
nvs_ext, data, nvs, 0x620000, 0x10000,
I (380) example: ----------------Find partitions---------------
I (390) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype ESP_PARTITION_SUBTYPE_DATA_NVS, label NULL (unspecified)...
I (400) example: found partition 'nvs' at offset 0x9000 with size 0x6000
I (410) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype ESP_PARTITION_SUBTYPE_DATA_PHY, label NULL (unspecified)...
E (420) example: partition not found!
I (430) example: Find partition with type ESP_PARTITION_TYPE_APP, subtype ESP_PARTITION_SUBTYPE_APP_FACTORY, label NULL (unspecified)...
E (440) example: partition not found!
I (450) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype ESP_PARTITION_SUBTYPE_DATA_FAT, label NULL (unspecified)...
E (460) example: partition not found!
I (460) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype UNKNOWN_PARTITION_SUBTYPE, label NULL (unspecified)...
I (480) example: found partition 'storage' at offset 0x420000 with size 0x200000
I (480) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype ESP_PARTITION_SUBTYPE_APP_FACTORY, label NULL (unspecified)...
I (500) example: found partition 'otadata' at offset 0xf000 with size 0x2000
I (500) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype UNKNOWN_PARTITION_SUBTYPE, label NULL (unspecified)...
E (520) example: partition not found!
I (520) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype UNKNOWN_PARTITION_SUBTYPE, label NULL (unspecified)...
E (530) example: partition not found!
I (540) example: Find second FAT partition by specifying the label
I (540) example: Find partition with type ESP_PARTITION_TYPE_DATA, subtype ESP_PARTITION_SUBTYPE_DATA_NVS, label nvs_ext...
I (560) example: found partition 'nvs_ext' at offset 0x620000 with size 0x10000
I (560) example: ----------------Iterate through partitions---------------
I (570) example: Iterating through app partitions...
I (580) example: found partition 'ota_0' at offset 0x20000 with size 0x200000
I (590) example: found partition 'ota_1' at offset 0x220000 with size 0x200000
I (590) example: Iterating through data partitions...
I (600) example: found partition 'nvs' at offset 0x9000 with size 0x6000
I (610) example: found partition 'otadata' at offset 0xf000 with size 0x2000
I (610) example: found partition 'storage' at offset 0x420000 with size 0x200000
I (620) example: found partition 'nvs_ext' at offset 0x620000 with size 0x10000
I (630) example: Example end

There is another way to work with the partition table CSV file, instead of editing in text mode. The ESP-IDF VS Code Extension allows you to install ESP-IDF, manage and create projects directly on the Microsoft Visual Studio Code IDE.

Partition Table Editor UI
Partition Table Editor UI
Build and Flash Partition binary
Quick User Guide for the ESP-IDF VS Code Extension

Some of the most common issues when dealing with partitions are about the alignment and overlapping.

idf.py -p <COM_PORT> erase_flash

Failed to find X partition…

This issue means that the partition is not found or missing in your partition tables. This could be due to some wrong value on the CSV file, like the wrong type or subtype.

Partition overlapping issue

If your partition offset points into an area that belongs to another partition, you will see an error like the following:

Memory size issue

The most common issue about the partition size stands for the size alignment.

ota_0, app, ota_0, 0x12000, 0x200000,

Creating custom partition tables in your project can be advantageous as you reuse available flash memory for extended data storage by customizing the partitions. This technique can avoid usage of external SDCard for extra data storage.

Reference for Partition Table

Docs: API Guide — Partition Tables



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *