From an ESP32 example code, I extracted the following part, that just prints the flash partition list to the console.
#include <string.h>
#include <assert.h>
#include "esp_partition.h"
#include "esp_log.h"
static const char *TAG = "example";
void setup(void)
{
Serial.begin(115200);
delay(200); // Otherwise, the first log entries get lost
ESP_LOGI(TAG, "Start test");
esp_partition_iterator_t iter = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL);
ESP_LOGI(TAG, "Name, type, subtype, offset, length");
while (iter != nullptr)
{
const esp_partition_t *partition = esp_partition_get(iter);
ESP_LOGI(TAG, "%s, app, %d, 0x%x, 0x%x (%d)", partition->label, partition->subtype, partition->address, partition->size, partition->size);
iter = esp_partition_next(iter);
}
esp_partition_iterator_release(iter);
iter = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL);
while (iter != nullptr)
{
const esp_partition_t *partition = esp_partition_get(iter);
ESP_LOGI(TAG, "%s, data, %d, 0x%x, 0x%x (%d)", partition->label, partition->subtype, partition->address, partition->size, partition->size);
iter = esp_partition_next(iter);
}
esp_partition_iterator_release(iter);
}
void loop()
{
}
In the project folder, I also have a custom partitions.csv
file as follows:
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 512k,
storage, data, , , 0x40000,
If I run the code, it correctly shows the custom partitions with the above sizes, everything like it should be.
However, the build output says the program uses 207278 Bytes from a maximum of 1310720. If I change the partition scheme selection in the tools menu, the second number changes. I would expect the maximum size to be equal to the size of the factory
partition from the custom partition scheme.
If I change the factory partition to be only 100k in size, the ESP32 fails to boot and enters a core-dump-restart-loop.
Is this a compiler bug or am I overlooking something?