Open amrsoll opened 8 months ago
I fixed a memory leak in the original example.
However, the NVS partition does not want to allocate space for 2x 6KB blobs. I updated the example
* // Example of nvs_get_stats() to get the number of used entries and free entries:
* nvs_stats_t nvs_stats;
* nvs_get_stats(NULL, &nvs_stats);
* printf("Count: UsedEntries = (%d), FreeEntries = (%d), AllEntries = (%d)\n",
nvs_stats.used_entries, nvs_stats.free_entries, nvs_stats.total_entries);
So you're saying I should check for available space before committing? How does that explain the bahaviour I am seeing?
Hi @amrsoll,
Please look at the documentation of nvs_stats_t returned by nvs_get_stats. This structure was extended by the member available_entries (not shown in @AxelLin 's example) which indicates useable space for data. Please note, that (over)writing blobs requires extra entries for blob data (one entry per 32 bytes of data) and 2 entries for overhead data (index and key). If you are overwriting existing blob (re-using same key), the data occupied by the old value will be returned to the pool of available entries first after successful writing of the new value. It effectively means, that during the write operation, you will need space for both old and new versions (data as well as overhead).
Answers checklist.
IDF version.
b4268c874a4cf8fcf7c0c4153cffb76ad2ddda4e
ESP-IDF v5.2-dev-3775-gb4268c874a
Espressif SoC revision.
ESP32-S3
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32 S3 mini
Power Supply used.
USB
What is the expected behavior?
I try saving multiple blobs to the NVS. The NVS partition is 16KB, and the blob sizes are 6 KB and 6 KB respectively.
What is the actual behavior?
The NVS dos not have enough memory.
Steps to reproduce.
git clone git@github.com:amrsoll/nvs_rw_blobs.git
cd nvs_rw_blobs
idf.py flash monitor
Debug Logs.
More Information.
See my repository for the source files to reproduce error
https://github.com/amrsoll/nvs_rw_blobs