Getting partition size
Posted: Wed May 24, 2017 1:52 pm
Hi,
I'm trying to initialise a partition by erasing it before i write to it but when I use esp_partition_find, the size field of the esp_partition_t structure is being set to 0.
Subsequently, I used this size in esp_partition_erase_range and it throws an invalid size error.
Any thoughts on why the esp_partition_find call isn't returning the size of my partition from the partition table?
P.S, The partition size is 0xF0000 and occupies the remaining flash memory from offset 0x310000.
I'm trying to initialise a partition by erasing it before i write to it but when I use esp_partition_find, the size field of the esp_partition_t structure is being set to 0.
Subsequently, I used this size in esp_partition_erase_range and it throws an invalid size error.
Any thoughts on why the esp_partition_find call isn't returning the size of my partition from the partition table?
P.S, The partition size is 0xF0000 and occupies the remaining flash memory from offset 0x310000.
Code: Select all
bool otaWebInit()
{
esp_err_t err;
const esp_partition_t *website_partition = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, "website");
assert(website_partition != NULL);
memset(&operate_partition, 0, sizeof(esp_partition_t));
err = esp_partition_erase_range(website_partition, 0, website_partition->size);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_partition_erase_range failed err=0x%x!", err);
return false;
}
else {
memcpy(&operate_partition, website_partition, sizeof(esp_partition_t));
ESP_LOGI(TAG, "esp_ota_begin init OK");
return true;
}
return false;
}