NVS Speed via Preferences

Snipeye
Posts: 5
Joined: Fri Mar 08, 2019 4:30 am

NVS Speed via Preferences

Postby Snipeye » Sun Nov 06, 2022 5:36 am

Hello!

I am working on a project that uses NVS and deep sleep, and I've noticed that the size of the nvs partition makes a huge difference in the wakeup time - I think the default "nvs" partition is opened whenever the chip wakes up from deep sleep.

Unfortunately, I need a lot of storage (currently set aside 2M) and I need to access it right on wakeup - the data is too large to store in the RTC memory 8KB. When the partition is set to 2M, the wakeup time (before setup is even called) takes ~1.6s. If I change the "nvs" partition to be small (default 12K) and then make a new partition of 2M for my data, the actual wakeup time is fast, but when I try to open the Preferences library on my partition, it takes that same ~1.6s. All subsequent accesses to the partition are fast, but something about mapping it the first time takes a while.

Is there a way to accelerate the initial load of the nvs partition after wakeup? Alternatively, is there a way to hold the partition map in RTC memory so I only have to suffer that 1.6s penalty once, then don't have to do it after wakeup?

Thank you!

lbernstone
Posts: 793
Joined: Mon Jul 22, 2019 3:20 pm

Re: NVS Speed via Preferences

Postby lbernstone » Sun Nov 06, 2022 3:40 pm

I suspect the issue is that nvs has to scan all the pages and do some consistency checks on init. A larger partition therefore means a longer start time. Have you tried using multiple nvs partitions, so the data required at startup (the saved phy data) can be accessed quickly?

Snipeye
Posts: 5
Joined: Fri Mar 08, 2019 4:30 am

Re: NVS Speed via Preferences

Postby Snipeye » Mon Nov 07, 2022 4:20 pm

I think that's my next attempt - I was hoping there would be a way to store the partition map in the RTC memory or something so I only had to take that hit once on initial boot, but it seems like it's wrapped too deeply for that.

Who is online

Users browsing this forum: No registered users and 84 guests