NVS and wear leveling

kostyan5
Posts: 50
Joined: Mon Mar 06, 2017 3:16 pm

NVS and wear leveling

Postby kostyan5 » Fri Oct 20, 2017 2:25 pm

Does NVS use wear leveling? If not, any plans to support it?

In our use case, we update a value in NVS every few mins and would hit 100,000 in about a year.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: NVS and wear leveling

Postby kolban » Sat Oct 21, 2017 4:30 am

Assuming NVS doesn't support wear leveling (and I don't believe it does), have you considered saving your data as records in one or more SPIFFS or FATFS files which do support wear leveling? It doesn't feel like it would be that difficult to create a wrapping API that would look/behave just like NVS but instead use a file system to hold your data.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: NVS and wear leveling

Postby ESP_igrr » Sun Oct 22, 2017 6:06 am

NVS keeps key-value pairs in a log-based structure, which works well for minimizing flash wear. It works best when you use small values, i.e. 8-64 bit integers. For blobs and strings, especially large ones (1k and above), performance is worse.
With integers, you can expect one flash sector to be erased once per every 125 updates of a value in key-value pair.

Who is online

Users browsing this forum: No registered users and 109 guests