How much of NVS Data can we really use?

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

How much of NVS Data can we really use?

Postby dhananjay.sutariya » Mon Mar 18, 2019 1:47 pm

Hi all,
I'm checking my NVS storage capacity. This is my output when i do make partition.


olchain path: /home/dhananjay/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a
Compiler version: 5.2.0
Python requirements from /home/dhananjay/esp/esp-idf/requirements.txt are satisfied.
Partition table binary generated. Contents:
*******************************************************************************
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
ota_0,app,ota_0,0x110000,1M,
ota_1,app,ota_1,0x210000,1M,
*******************************************************************************
Partition flashing command:
python /home/dhananjay/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 115200 --before default_reset --after hard_reset write_flash 0x8000 /home/dhananjay/esp/Homebridge/build/partitions_two_ota.bin
dhananjay


Which shows that i can use 16k of nvs storage, yet when i write into nvs through namespace "storage" and keys "a"-"p" with each key containing 1022 bytes of data.
i get this output.


Done
String written successfully
Namespace a Completed
Done
String written successfully
Namespace b Completed
Done
String written successfully
Namespace c Completed
Done
String written successfully
Namespace d Completed
Done
String written successfully
Namespace e Completed
Done
String written successfully
Namespace f Completed
Done
String written successfully
Namespace g Completed
Done
String written successfully
Namespace h Completed
Done
String written successfully
Namespace i Completed
Done
Not enough Storage space
Wrongfull termination in Writing String

i Can only store 10220 kb of data please help.

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

Re: How much of NVS Data can we really use?

Postby WiFive » Mon Mar 18, 2019 3:10 pm

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

1 sector (4kB) is reserved so you have 10220/12288 = 83% data, 17% overhead.

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Re: How much of NVS Data can we really use?

Postby dhananjay.sutariya » Tue Mar 19, 2019 5:23 am

and what is that 4Kb reserved for also.. what does overhead mean?

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

Re: How much of NVS Data can we really use?

Postby WiFive » Tue Mar 19, 2019 5:31 am

The way nvs is designed to support writing and erasing and the fact flash can only be erased in 4k pages means there will always be an extra blank page. Read the link, in addition to storing data it has to store keys and indices. There will never be perfect use of the partition space to store data. The entry size is 32 bytes so even storing 1 byte of data takes 32 bytes.

dhananjay.sutariya
Posts: 41
Joined: Thu Feb 28, 2019 12:21 pm

Re: How much of NVS Data can we really use?

Postby dhananjay.sutariya » Tue Mar 19, 2019 6:18 am

Thanks a lot for your time and enlightening those facts Wifive :D

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 103 guests