Page 1 of 1
Does EEPROM automatically perform wear leveling?
Posted: Sat Oct 28, 2023 1:28 am
by ghostvisitor
The EEPROM of ESP32S3 is virtualized by FLASH. Does erasing EEPROM directly in Arduino IDE automatically perform wear leveling at the underlying level?
When using ESP32S3 to create a device with a counter function, I want to save data during power-off, so I need to save it once when a counting event occurs. Approximately 2000 saves per day. Using EEPROM with the Arduino framework + FreeRTOS development will be much more convenient. If wear leveling can be automatically performed at the underlying level, it will save a lot of trouble.
Re: Does EEPROM automatically perform wear leveling?
Posted: Sun Oct 29, 2023 12:25 am
by ESP_Sprite
Probably better to use the Preferences library, EEPROM is a bit clunky. That maps to the NVS functionality of ESP-IDF, which indeed implements wear-leveling
ref.
Re: Does EEPROM automatically perform wear leveling?
Posted: Sun Oct 29, 2023 1:06 am
by lbernstone
Both EEPROM and Preferences will use wear levelling, since they both use nvs as their backend. Preferences is faster, easier to use, and overall more suitable if you don't need arduino portable code.
Note that using the IDE to erase the flash is one way that specifically sidesteps wear levelling. You are wiping the disk and writing back to it in exactly the same place. With the rate that I code, I don't find that to be an issue.
Re: Does EEPROM automatically perform wear leveling?
Posted: Mon Oct 30, 2023 6:38 am
by ghostvisitor
lbernstone wrote: ↑Sun Oct 29, 2023 1:06 am
Both EEPROM and Preferences will use wear levelling, since they both use nvs as their backend. Preferences is faster, easier to use, and overall more suitable if you don't need arduino portable code.
Note that using the IDE to erase the flash is one way that specifically sidesteps wear levelling. You are wiping the disk and writing back to it in exactly the same place. With the rate that I code, I don't find that to be an issue.
Thank you, I will go learn about the Preferences library.
Re: Does EEPROM automatically perform wear leveling?
Posted: Mon Oct 30, 2023 6:38 am
by ghostvisitor
ESP_Sprite wrote: ↑Sun Oct 29, 2023 12:25 am
Probably better to use the Preferences library, EEPROM is a bit clunky. That maps to the NVS functionality of ESP-IDF, which indeed implements wear-leveling
ref.
Thank you, I will go learn about the Preferences library.
Re: Does EEPROM automatically perform wear leveling?
Posted: Mon Oct 30, 2023 8:03 pm
by lbernstone
Just one more comment about wear leveling. You are writing into a partition with a fixed size. You get a finite amount of writes to each sector in that space. If you make the space larger, you get more writes. You can make a custom partition scheme (
https://docs.espressif.com/projects/ard ... ion-scheme) with an expanded nvs partition if you need increased disk durability.