Non-Volatile-Storage management
Overview
The NVSettings
feature is ported from Oasis implementations, and is configurable through Kconfig options.
-
FEAT_NVS
enables traditional non-volatile settings. Each settings is assigned with a fixed offset of a 256-words settings block. The set operation does incremental update of the settings block which prevents flash from wear-off. -
FEAT_NVS_EXTENDED
enables extended non-volatile settings that compiles key information as metadata. The extended settings require more RAM and ROM resources. For RAM/ROM constraint applications, extended feature is usually disabled.
Unlike being implemented as global instance in Oasis design, both traditional and extended settings can have many instances as eventually limited by flash/RAM resources. The default NVSettings
instance is created as a member of Platform accessed through platform.GetNVS()
.
Allocation
The allocation of NVsettings
is required before accessing the key. This is accomplished in Object::CreateNVSettings() or Object::FinishConfiguration() if CFG/CAL
system is enabled. Currently supported built-in types are int
, int64
and float
. For custom data settings, corresponding type information that describes size of the structure is required.
Storage
The underlying media of NVSettings
storage (back-end) only supports flash device now. For the near future, persistent RAM needs to be supported. Both traditional and extended settings (front-end rendering) need to be decoupled from implementation of back-end storages. For the long term, more back-end storages can be implemented, e.g. local or remote files/database.
Internal Flash
Both traditional and extended NVS contents update on word-boundaries, i.e. byte counts of flash write is multiple of 4. This is not a problem on external spi-nor or simulated flash, as write-block-size
attribute is 1 or 4 respectively. However, write-block-size
of internal flash of MCU is usually larger 4 (STM32G0 = 8, STM32H7 = 32). This means NVS support on internal flash needs special treatment at driver level.