Getting partition size

aaquilina
Posts: 43
Joined: Fri Jan 20, 2017 3:10 pm

Getting partition size

Postby aaquilina » 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.

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;
}

aaquilina
Posts: 43
Joined: Fri Jan 20, 2017 3:10 pm

Re: Getting partition size

Postby aaquilina » Thu May 25, 2017 7:23 am

Just a follow up in case anyone comes across this problem. The esp_partition_find returns a partition iterator not a partition pointer. esp_partition_find_first returns a partition pointer so that solved the issue.

Who is online

Users browsing this forum: grantb and 56 guests