Does EEPROM automatically perform wear leveling?

ghostvisitor
Posts: 5
Joined: Tue Sep 26, 2023 6:40 am

Does EEPROM automatically perform wear leveling?

Postby ghostvisitor » Sat Oct 28, 2023 1:28 am

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.

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: Does EEPROM automatically perform wear leveling?

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

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Does EEPROM automatically perform wear leveling?

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

ghostvisitor
Posts: 5
Joined: Tue Sep 26, 2023 6:40 am

Re: Does EEPROM automatically perform wear leveling?

Postby ghostvisitor » Mon Oct 30, 2023 6:38 am

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.

ghostvisitor
Posts: 5
Joined: Tue Sep 26, 2023 6:40 am

Re: Does EEPROM automatically perform wear leveling?

Postby ghostvisitor » Mon Oct 30, 2023 6:38 am

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.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Does EEPROM automatically perform wear leveling?

Postby lbernstone » Mon Oct 30, 2023 8:03 pm

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.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 38 guests