partition erase and partition write DOES NOT WORK [SOLVED]

dmaxben
Posts: 108
Joined: Thu Nov 16, 2017 6:04 pm

partition erase and partition write DOES NOT WORK [SOLVED]

Postby dmaxben » Wed May 06, 2020 11:44 pm

Im at a loss here...ive been messing around with this for 7 hours and I cant figure out why esp_partition_erase_range and esp_partition_write do not work.

All they do is return either "invalid size" or "invalid argument" errors.

ESP32-wroom32, 16MB flash.

My partition table is setup for a SPIFFS partition size 0xAF0000, starting address 0x510000, partition name is "spiffs".

esp_partition_erase_range("spiffs", 0, 0xAF0000); returns invalid argument.

0xAF0000 is divisible by 4096, so that should not be a problem.

esp_partition_write also always returns either "invalid argument" or "invalid size".

According to the IDF documentation, if invalid size is returned following a partition erase, it means "if erase would go out of bounds of the partition". Thats impossible! The partition is 0xAF0000 in length, im telling it to erase 0xAF0000.

For testing, I tried telling it to erase a shorter length (that was divisible by 4096), and it still says invalid size.

Is there some other magic involved in using esp_partition_write and esp_partition_erase_range that the IDF documents dont mention!!??
Last edited by dmaxben on Thu May 07, 2020 2:14 pm, edited 1 time in total.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: partition erase and partition write DOES NOT WORK

Postby WiFive » Thu May 07, 2020 2:41 am

esp_partition_find_first

dmaxben
Posts: 108
Joined: Thu Nov 16, 2017 6:04 pm

Re: partition erase and partition write DOES NOT WORK

Postby dmaxben » Thu May 07, 2020 3:45 am

WiFive wrote:
Thu May 07, 2020 2:41 am
esp_partition_find_first
Why does partition-find have to be called? I already know the proper offset, size, and name based on what I put into my partition file?

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: partition erase and partition write DOES NOT WORK

Postby ESP_Angus » Thu May 07, 2020 3:58 am

dmaxben wrote:
Wed May 06, 2020 11:44 pm
esp_partition_erase_range("spiffs", 0, 0xAF0000); returns invalid argument.
The first argument of esp_partition_erase_range() takes a pointer to a partition structure. I'm surprised this didn't fail with a compiler error, but maybe it only issues a warning? Recommend always checking for compiler warnings if something isn't working like you expect.

There are a few partition API examples included with ESP-IDF, this one shows the sequence of function calls to erase part of a partition:
https://github.com/espressif/esp-idf/bl ... main.c#L27

(Note this is master branch, but this API is the same in ESP-IDF v4.0 & v3.3.)

There is some more information about the partition table API here:
https://docs.espressif.com/projects/esp ... -table-api

dmaxben
Posts: 108
Joined: Thu Nov 16, 2017 6:04 pm

Re: partition erase and partition write DOES NOT WORK

Postby dmaxben » Thu May 07, 2020 2:14 pm

Well I feel like a complete idiot!!

I was indeed not using the pointer to the partition struct correctly.... :lol:

Im surprised it compiled and let me build it...

but once I did find partition to get the pointer, then it worked!

Thanks so much for the help everyone, much appreciated!

Who is online

Users browsing this forum: Baidu [Spider], ESP_Roland, Google [Bot] and 130 guests