At times when developing embedded applications, you may want to store unique values in non-volatile memory, values that cannot be set during compilation. Many microcontrollers have a small amount of EEPROM memory for this purpose, but it is usually limited when supplied. Even if you have some space on an EEPROM, it can be a bit of a hassle to actually deal with the complex problem of formatting your values in memory and leveling wear (parameters that need to be changed frequently).
Lucky for us, [Marcelo Barros] Its own implementation, Kved (Key / Value Database) decided to share which uses flash memory instead of this type of storage. Kved uses a dictionary type data structure, using numeric keys and values, to support several integer types. Using the library should be straightforward enough, e.g. [Marcelo] That said, all you need is a pair of additional flash sectors and the ability to port flash the read, write and eras function of the sector. There are plenty of examples of this type of code for virtually any microcontroller, so there are no barriers. For those who want to play with it right now, the repo currently has ports for STM32L433RC and STM32F411CE, as well as a simulated version that you can compile and run on your computer.
From an implementation standpoint, the writing algorithm uses a COW (copy on write) method. Storage locations are overwritten with All-Zero, and the changed value is discarded by rewriting it to a new location, cycling through unused locations until the sector is full. The data-integrity process is implemented, preventing data structure corruption due to power failure, so incorrectly written values will be corrected at start-up and will not affect the integrity of the configuration.
While searching around, we came across this article on hackaday.IO about a similar project, Embedis, as well as the embedded filesystem.