Hi All,
I'm quite new at all this but am loving it and learning a ton. I'm still using arduino IDE with my esp32 projects but some day I'll graduate. I made smart roller shades using motors with encoders, esp32, and two l98ns (there are 3 shades connected). Rather than using endstop switches, I'm using this NVS library that ports nvs functions to the arduino platform.
https://github.com/rpolitex/ArduinoNvs
My code writes the relevant encoder position when it arrives at its targeted location and writes the target location when it gets a command to move. What I can't figure out is whether this library is capitalizing on Wear Leveling, or if it would need to be modified in some way to improve longevity by wear leveling. My current feeling is that wear leveling is built into the api that the library is using by default and thus I'm covered without doing anything further. I'm doing about 24 writes of integers per day, so I should be set for a while, but it'd still be dumb to keep hitting the same space every time if I could avoid it as replacing the board is a big pain! Any thoughts?
NVS Arduino Library Wear Leveling?
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: NVS Arduino Library Wear Leveling?
clearlynotstefan wrote: ↑Sun Oct 25, 2020 3:31 pm...
My current feeling is that wear leveling is built into the api that the library is using by default and thus I'm covered without doing anything further. I'm doing about 24 writes of integers per day, so I should be set for a while, but it'd still be dumb to keep hitting the same space every time if I could avoid it as replacing the board is a big pain! Any thoughts?
Your feeling is correct, the underlying NVS API uses wear levelling. Especially with only 24 writes a day, flash wear should not be an issue in this use case.
Re: NVS Arduino Library Wear Leveling?
As far as I remember it works about like this: nvs stores sequential key value pairs in blocks. New pairs are always added to the end. If the value associated with an existing key gets updated it will *not* be stored in the same old location, but a new pair is added to the end and the old one is marked as deleted. When a block is full a new one is used. If there are too many invalid (deleted) pairs in a given block the remaining valid key value pairs will be copied to the end of the block where new entries are currently written and the old block is marked as free. This avoids wear leveling.
-
- Posts: 9757
- Joined: Thu Nov 26, 2015 4:08 am
Re: NVS Arduino Library Wear Leveling?
Yes, sorry my wording ("This avoids wear leveling") was wrong. I wanted to say that this avoids problems with wearing. Thank you for correcting that.
Who is online
Users browsing this forum: Google [Bot] and 291 guests