Page 1 of 2

ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Mon May 28, 2018 9:29 am
by nooooooob
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!

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Mon May 28, 2018 12:27 pm
by chegewara
How is your partition table looks like?
https://esp-idf.readthedocs.io/en/lates ... -of-a-page

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Wed May 30, 2018 1:28 am
by nooooooob
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 :(

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Wed May 30, 2018 1:55 am
by nooooooob
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.

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Thu May 31, 2018 4:05 pm
by kolban
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.

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Thu May 31, 2018 4:52 pm
by WiFive
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.

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Fri Jun 01, 2018 2:09 am
by nooooooob
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!

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Fri Jun 01, 2018 2:10 am
by nooooooob
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? :?:

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Fri Jun 01, 2018 3:10 am
by kolban
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.

Re: ESP_ERR_NVS_NOT_ENOUGH_SPACE when using set_nvs_bolb

Posted: Fri Jun 01, 2018 3:13 am
by WiFive
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.