nvs vs spiff vs wear_levelling

User avatar
Gfast2
Posts: 182
Joined: Fri Aug 11, 2017 1:52 am

nvs vs spiff vs wear_levelling

Postby Gfast2 » Sun Oct 29, 2017 8:33 pm

Hi ESP-IDF,

I love what you are working on! I've learned tons stuff from my 6€ ESP32 board. It's the most bang for each buck I've ever experienced! :lol:

Right now I'm working on a project that need to read/write some parameters from/into spi Flash:
Firstly, I'd burn some default setting parameters for my App into spi flash. After start-up, If the device can't find the file "newSetting.cfg" from sd card, it will use default setting parameters that written in spi flash. If "newSetting.cfg" did exist, it will read it, use them and update these parameters in spi flash.
Secondly, I will update device "oldmeter" (run time of hours in total) every one hour and a "power-up counter" which will be +1 for each power-up.

For both parts, "nvs" library looks pretty the thing designed for this perpose. But according to the doc, it does the job, (but not in "classical poxis way" though). But I have these worry/questions:
1. the API of nvs looks pretty handy. Does it do the Wear Leveling as well? How would it deal with dead block? It's pretty critical if I'd update the oldmeter every one hours for the long term.
2. Why there are paralle so many librarys for data storage? Are they really the same? If not, what are their emphasises?
3. Each example from "storage" folder from ESP-IDF showed the data from their different directory.
1. wear_leveling -> "./spiflash"
2. spiff -> "./spiffs"
3. nvs -> "storage"
Are these spi flash related directorys pointing to the same "nvs" named partition of the "Espressif ESP32 Partition Table"? If it is so. Are these names the "subdirectory" in partition "nvs"?
4. Has somebody the experience of spi flash with its read/write lifetime? (Abs safe I/O time)

Thanks!

mjmorrison
Posts: 26
Joined: Thu Nov 03, 2016 9:06 pm

Re: nvs vs spiff vs wear_levelling

Postby mjmorrison » Thu Nov 02, 2017 1:04 am

The "wear leveling" library is a layer that is applied to fatfs, which can help to avoid dead blocks. fatfs and spiffs are two different types of file structure. As I understand it, SPIFFS already does wear leveling. You can read more here, the FAQ has some info about lifetime. https://github.com/pellepl/spiffs/wiki/Configure-spiffs

NVS is a key value store, so it doesn't have the same kind of metadata that either fatfs or spiffs will have. You simply put and get keys and nvs will search along the whole partition that you have reserved for nvs. Not sure whether or not NVS does wear leveling, though I would assume not.

User avatar
Gfast2
Posts: 182
Joined: Fri Aug 11, 2017 1:52 am

Re: nvs vs spiff vs wear_levelling

Postby Gfast2 » Sun Nov 05, 2017 5:15 pm

mjmorrison wrote:The "wear leveling" library is a layer that is applied to fatfs, which can help to avoid dead blocks. fatfs and spiffs are two different types of file structure. As I understand it, SPIFFS already does wear leveling. You can read more here, the FAQ has some info about lifetime. https://github.com/pellepl/spiffs/wiki/Configure-spiffs

NVS is a key value store, so it doesn't have the same kind of metadata that either fatfs or spiffs will have. You simply put and get keys and nvs will search along the whole partition that you have reserved for nvs. Not sure whether or not NVS does wear leveling, though I would assume not.
Hi jmjorrison,

Thanks for these tipps! SPIFFS is a very impressive & powerful library. Since I've implemented "wear-leveling library + fatfs" I'd going on stuck on it for a while. But I do will try SPIFFS if my right now solution has problems and planning to implement more SPIFF in up comming projects.

Cheers

Su

Who is online

Users browsing this forum: No registered users and 339 guests