ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

nooooooob
Posts: 10
Joined: Mon May 28, 2018 4:44 am

ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby nooooooob » Mon May 28, 2018 9:29 am

hi, I got a problem when using NVS set_nvs_blob function. I want to store 1000 sets of key-value pairs and each value is 20 bytes. The storage is supposed to be sufficient but actually it can only store 314 sets and when I try to set another bolb error showed up:
ESP_ERR_NVS_NOT_ENOUGH_SPACE. All the 314 sets are properly stored and can be read correctly. the reset of them just won't get stored. Any idea? Thanks!

chegewara
Posts: 2376
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby chegewara » Mon May 28, 2018 12:27 pm

How is your partition table looks like?
https://esp-idf.readthedocs.io/en/lates ... -of-a-page

nooooooob
Posts: 10
Joined: Mon May 28, 2018 4:44 am

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby nooooooob » Wed May 30, 2018 1:28 am

I used the default settings from esp-idf/example/nvs_rw_blobs. Actually I don't know how to check my partition table or how to set my partition table, Can you give me some hints? I checked menu config several times but I just can't find any settings about page or partition table :(

nooooooob
Posts: 10
Joined: Mon May 28, 2018 4:44 am

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby nooooooob » Wed May 30, 2018 1:55 am

I checked the menuconfig, I chose single app no OTA in the partition table colum. Should I choose Custom partition table CSV to load my own partition table? I'm really puzzled cause I can't find any help in the esp-idf, there's no examples and I can't find any help from AIP reference or in the DataSheet.

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

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby kolban » Thu May 31, 2018 4:05 pm

Sadly I don't have info on your puzzle ... but I did want to add a thought. The NVS is ( I believe ) supposed to hold persistent settings. A simple way to set a configuration property and have it available on next boot. When you say that you are going to have 1000 name/value pairs ... I'm curious what those "are"? What is the nature of the data you are saving there?

Depending on what we find, you may find that you will be better served by an alternate persistent storage story. For example, the ESP32 comes with a couple of file system stories (SPIFFS and FatFS). Both of these allow you save persistent data to "file" that are backed by flash and hence persistent across restarts. The file APIs are high level (Posix) and pretty easy to use. You also get concepts like directories as well as file names which might add more function to your solution. It may be that the puzzle you pose is solved by simply not using NVS but instead choosing a flash based file system.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby WiFive » Thu May 31, 2018 4:52 pm

Default nvs partition size is 6 pages, 1 page is reserved. Each page holds 126 entries so if a 20 byte blob takes 2 entries 126*5/2 = 315.

nooooooob
Posts: 10
Joined: Mon May 28, 2018 4:44 am

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby nooooooob » Fri Jun 01, 2018 2:09 am

kolban wrote:Sadly I don't have info on your puzzle ... but I did want to add a thought. The NVS is ( I believe ) supposed to hold persistent settings. A simple way to set a configuration property and have it available on next boot. When you say that you are going to have 1000 name/value pairs ... I'm curious what those "are"? What is the nature of the data you are saving there?

Depending on what we find, you may find that you will be better served by an alternate persistent storage story. For example, the ESP32 comes with a couple of file system stories (SPIFFS and FatFS). Both of these allow you save persistent data to "file" that are backed by flash and hence persistent across restarts. The file APIs are high level (Posix) and pretty easy to use. You also get concepts like directories as well as file names which might add more function to your solution. It may be that the puzzle you pose is solved by simply not using NVS but instead choosing a flash based file system.

Hi thanks for the reply, My program is designed to keep deep sleep when the power is low, it wakes up every minute to monitor the temperature and time then store them in NVS. This low power situation may keep 1 day or two. So, if I need to solve this I need to test if it can store 1000 or more sets of 20 bytes data. I created a structure which is composed of several long int data and then I put the structure in the Union with an array . When I'm using the set_nvs_blob I passed the pointer of the array as parameter. It seems the pages of the NVS is fixed and that's why I can't store all of my data in NVS. I will check FAT system soon, It will be a good approach. It's so kind of you to write a free book to help others. I think I will get a lot of help from your book, thanks a million!

nooooooob
Posts: 10
Joined: Mon May 28, 2018 4:44 am

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby nooooooob » Fri Jun 01, 2018 2:10 am

WiFive wrote:Default nvs partition size is 6 pages, 1 page is reserved. Each page holds 126 entries so if a 20 byte blob takes 2 entries 126*5/2 = 315.
Thanks for replying, Is there any way for me to get more pages to store more sets of data? :?:

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

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby kolban » Fri Jun 01, 2018 3:10 am

If we look here:

http://esp-idf.readthedocs.io/en/latest ... ables.html

We find the documentation on the partitions table mechanism. Looking further, we find a partition called "nvs". This appears to be where in flash the NVS data is kept. It appears we could increase the size of the partition ... but beware it must not overlap other partitions. You may have to declare the NVS partitions is being somewhere else in flash space if you need a large amount of storage.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Postby WiFive » Fri Jun 01, 2018 3:13 am

You can resize nvs partition but it's probably better to just store as raw binary data because using 64 bytes to store 20 bytes is not efficient.

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 90 guests