Hi,
During some FW testing, a colleague of mine managed to break the NVS filesystem. I am using the MX25 Flash device with NVS library. I have no idea what exactly happened and would like to understand the reasons for the following error.
During the nvs_init() function, nvs_startup() was returning -EDEADLK, which looking through the code seams to mean that all the sectors were closed and therefore it is not an NVS Filesystem.
if (closed_sectors == fs->sector_count) {
rc = -EDEADLK;
goto end;
}
After this the unit was never able to access the flash. At first I though this was a hardware issue, but couldn't see anything wrong the the IC. Whilst debugging, I commented out the "goto end;" line and let it continue going through the init process, which to my surprise actually passed. I erased all the flash and uncommented the "goto end;" function and the next time I ran it, it passed with no issue.
What I would like to know is what must have happened for this error to happen? I am guessing it somehow wrote over some of the nvs metadata?
As for flash information I am using:
Flash Size 0x800000 (8388608)
Sector Size 0x8000 (32768)
Sector Count 0x100 (256)
Page Size 0x1000 (4096)
When I use nvs_write() I am only ever saving in my own defined "Flash Block" which is 4088 bytes long (which allows the 8 bytes of nvs metadata - I assume this is the correct way to do it?). With the amount of storage, this leaves a potential of 2048 flash blocks that can be saved, I wonder if actually more space need to be reserved for the NVS filesystem?
I am using SDK version 1.6.1.
Thanks,
Damien