cannot create 4K partition

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

cannot create 4K partition

Postby mzimmers » Thu Nov 08, 2018 5:28 pm

Hi all...according to the docs:

https://docs.espressif.com/projects/esp ... n_gen.html

I'd expect to be able to generate a partition (.bin) file of 4096 bytes. When I run this command, however:

Code: Select all

nvs_partition_gen.py --version v2 --keygen False --encrypt False serial.csv serial.bin 0x1000
I get an error "Size parameter is insufficient."

Is this a bug in the python script, or am I missing something?

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

Re: cannot create 4K partition

Postby WiFive » Thu Nov 08, 2018 6:49 pm

Needs at least 2 sectors so 8k but it would be nice if support for read-only single sector nvs was added

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cannot create 4K partition

Postby mzimmers » Thu Nov 08, 2018 9:54 pm

Thanks for the explanation. That is disappointing, though, particularly given the apparent overhead associated with the NVS library. I mentioned in another post that I tried to store a ~1000 byte blob in a 0x2000 NVS partition, and got the error ESP_ERR_NVS_NOT_ENOUGH_SPACE, even though this was a freshly created partition. I too will look forward to the reduction of this minimum size.

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

Re: cannot create 4K partition

Postby ESP_igrr » Fri Nov 09, 2018 1:52 am

Two sectors is the minimum possible size because NVS needs to provide power off safety (data should not be lost if device is powered off during flash operation). Flash sector size is 4kB. We need one spare sector when performing flash operations, it acts as an area where data will be temporarily written while another sector is being erased.

Regarding the failure to store a 1000 byte blob, please check NVS available size before storing the blob. If you have been using Wi-Fi or Bluetooth, then PHY calibration data has also been stored in NVS, and it is about 2kB large. Wi-Fi also stores a few other configuration values. So it might be that the entire data did not fit into one sector (4K). Remember, one sector is used as a "spare" when NVS needs to erase something, so in the case when you have N sectors in NVS partition, N-1 will be actually used for data storage.

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cannot create 4K partition

Postby mzimmers » Fri Nov 09, 2018 3:49 pm

Hi Igrr...thanks for the explanation; that makes sense. I'll just not bother with a second partition, but will use "nvs" for my serialization data.

How do I go about checking the available space in the partition? I couldn't find that information on the page about the NVS library.

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

Re: cannot create 4K partition

Postby ESP_igrr » Fri Nov 09, 2018 4:03 pm

Use nvs_get_stats: https://docs.espressif.com/projects/esp ... vs_stats_t

Regarding available space, do you indeed have so little of it? You could move the beginning of app partition by 64kB, and make the size 64kB smaller. This would free up more than enough space for the second NVS partition...

User avatar
mzimmers
Posts: 211
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: cannot create 4K partition

Postby mzimmers » Mon Nov 12, 2018 5:35 pm

I'd already looked at nvs_get_stats...the nvs_stats_t struct has 4 elements that refer to "entries."

Code: Select all

I (336) nvs: c'tor(): stats.total_entries = 504 I (336) nvs: c'tor(): stats.used_entries = 178 I (346) nvs: c'tor(): stats.free_entries = 326 I (346) nvs: c'tor(): stats.namespace_count = 4
So, do I correctly understand that the entries are 32 bytes?

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

Re: cannot create 4K partition

Postby ESP_igrr » Mon Nov 12, 2018 5:46 pm

Yes, entries are 32 bytes. Key-value pairs with integer values require 1 entry each; strings require 1 entry plus size of string divided by 32 bytes; blobs require two entries plus size of the blob divided by 32 bytes.

https://docs.espressif.com/projects/esp ... -of-a-page

Who is online

Users browsing this forum: No registered users and 11 guests