zephyr icon indicating copy to clipboard operation
zephyr copied to clipboard

storage: Storage area

Open Laczen opened this issue 4 months ago • 9 comments

The PR introduces a new way of working with storage for zephyr.

A storage_area is an area on flash, eeprom, ram, disk that describes how this area will be used. It defines the write block size, erase block size and size of the area and provides methods to read, write, erase and a ioctl fuction. The write block and erase block sizes that are specified are not limited to the sizes of the underlying device but they can be a multiple. A verification option is available to avoid defining area properties that are not supported by the backing device.

The storage_area provides a simple way of working with images and allows the creation of "matching" images on different devices with different properties (e.g. erase-block sizes).

The storage_area definitions can be extended to provide e.g. an encrypted storage_area or a storage_area that is a mix of flash and ram.

The reading and writing routines not only support a classical direct write, but also a writing in chunks that allows stack saving when writing or reading data (e.g. when data that consists of multiple elements need to be written).

On top of the storage_area a storage_area_store is introduced that divides the storage_area into sectors and stores data as records in a simple and space saving format and ensures data integrity by using a crc32. The storage_area_store is not a storage solution, but rather it is a building block for storing id-data, key-data, ... solutions. The storage_area_store adds a configurable "cookie" at the beginning of each sector that can be used to describe what information can be found in the store as well as a version, ... The storage_area_store provides support for a storage solution with or without persistence requirements. The storage_area_store also provides support for modifying the first part of data in a record that is excluded from the crc32 calculation. This can be used to invalidate records.

Solves #79661

Laczen avatar Oct 10 '24 13:10 Laczen