Hi, I'm working on an application (Zephyr) that uses nvs storage and it's been working just great for awhile (months) without any major issues. Today I noticed that when reading or writing using nvs_read or nvs_write, I am suddenly getting a return code of -22 which is for an invalid argument.
I've tried re-flashing the nrf9160 several times but no luck. I ended up trying out the nvs sample (ncs/zephyr/samples/subsys/nvs) and it's working just fine. I adjusted the read IDs in the sample code to match a few of the addresses I was using in my custom application and it it still appears to work just fine (verified being able to read/write the contents just fine). After finishing testing the sample code, I switched back to my custom app and those addresses I tested out started working again and the addresses I didn't test still had the same issue.
I've matched the sample application nvs initialization to be almost identical (I've increased the sector_count but that's that only notable difference). I found that once I went back to the sample app and adjusted the read and writes to the remaining IDs I was using and swapped back, everything was working just fine which is strange.
Technically the issue is 'resolved' now but now I'm not sure why it was even happening in the first place or why I needed to run the sample app to fix the issue. Since the issue seems to get resolved whenever I use the sample application, I'm lead to believe I'm doing something wrong or missing something in my custom app but I'm failing to see what it could be since everything matches (except the sector_count). The project configuration file has all of the same defines and everything had been working just fine before without a hitch.
Maybe unrelated but I had recently updated the nrf9160 modem firmware but I didn't think that would have affected this.
Any insight would be much appreciated.