Skip to content

kernel::nvs

The nvs partition, as a key/value store.

lib/kvstore has the format and recovery; the board selects and opens the physical flash driver. This adapter joins them through NorFlash, without making the portable format depend on a chip or a physical driver depend on a storage format.

The flash trait takes word-aligned addresses and word counts. kvstore reads at whatever offset an entry happens to start at, for whatever length a key or a value happens to be. [FlashStorage] is where those two facts are reconciled: reads are widened to the enclosing words and the result sliced back out.

Writes need no such treatment, and that is by construction rather than by luck — kvstore aligns every entry to four bytes so the tail stays word-aligned, which it does for the benefit of exactly this layer.

struct FlashStorage;

A FlashRegion that speaks [Storage].

Implements: Storage