Hi,
My goal is to use a dedicated flash partition to store data persistently.
According to the documentation, a esp_partition_write() call must be after we first esp_partition_erase_range() the relevant sections in the partition. So if it is the "first run" erasing the entire partition is easy.
On consecutive runs I need to way to update the data in the partition, but writing must be done after erasing. And indeed trying to write without erase does nothing (although esp_partition_write() report ESP_OK).
How should I overcome this?
Thanks
Writing to a flash partition without erasing first
-
- Posts: 8
- Joined: Sun Jun 21, 2020 3:12 pm
-
- Posts: 9770
- Joined: Thu Nov 26, 2015 4:08 am
Re: Writing to a flash partition without erasing first
Assuming you do not use flash encryption: You can actually write multiple times to a (region in a) partition, but you need to realize that a write operation can only make bits go from 1 to 0, and never from 0 back to 1. (So if you write for example 0xAA and then 0xA5 to the same address, the result will be 0xAF.) If you need bits to go back to 1, you need to erase the corresponding erase block or the entire partition.
-
- Posts: 8
- Joined: Sun Jun 21, 2020 3:12 pm
Re: Writing to a flash partition without erasing first
I looking it up in the web - your answer sums it up pretty well. So I'll need a mechanism to assure that a clean write is done only after erasing. Thanks.
Who is online
Users browsing this forum: No registered users and 50 guests