-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Storage Area: a new subsystem for storage #79661
Comments
@Laczen Before I dive into code review, I would like to better understand your motivation behind introducing a new API instead of extending the existing
Is this only because
This is a valid point though Despite of these concerns, what I like about |
@Damian-Nordic the main reason to introduce a new API is that it is completely different from the |
Yes, but that is due to lack of recognition that flash devices are just eeprom devices with additional functions. and there is a plan to slowly change it, though not blocking for this issue: #71270 b. It inherits and uses the flash erase-block-size that limits support for building bootloaders that use a combination of internal and external flash that do not have equivalent erase-block-sizes, That is actually no true, that is current limitation of MCUboot, which also is not capable of working with device without erase due to lack of any mechanisms that allow to recognize validity of data without assuming erase happened. Also the problem is far more complicated and this is very superficial description of the problem, verging into the snake-oil advertisement area. c. Forces users to create (flash) devices for more enhanced areas that would consist of a combination of flash and ram, That is actually true. d. Forces users to create (flash) devices to support zephyr images that are stored on disk, That is true and was attempted indeed for MCUBoot, and there is still PR (Find TODO), the problem was though that MCUboot, prepared to work with devices with small write-block, was many times re-writing last sectors of image. The bootloader is supposed to be small and have as low number of layers as possible, causing tenths of rewrites per boot cycle.. e. The api only allows to write data directly that leads to high stack usage when a combination of data needs to be written to storage (an example of this can be found in secure storage where a combination of data properties, data and validity check need to be written). That is true, partially, and should be fixed the same way SPI transactions work. |
This limitation is in no way related to devices without and with erase: At the moment there are For devices with small erase-block-size like the
While it might be able to be fixed with spi transactions (this takes more or less the same approach), the solution proposed here does not involve any changes to the user-space (flash) API and directly enables use on other backends like eeprom, ram, disk, ... |
The problem of bundling erase pages together is solvable for MCUboot, specifically if sizes of erase-blocks, between devices, differ by some multiply of N (and actually should have been approached long time ago, but was not). The problem with ST devices is where layout is completely non-uniform and that could also been fixed by bundling pages, on uniform external device to reflect layout of stm - still move will here require moving by largest block in range, which basically means that mcuboot may have an option to just move/swap by configurable highest possible page size, set at compile time.
NXP devices have wrtie-block-size problem in context of mcuboot not erase-write-block. The problem is that tracking swap would mean multiple rewrites of blocks that store swap log, which will break last sectors quicker then others, or require more of them, taking away image size. |
Introduction
For years zephyr has been using the flash_area API to work with images and storage solutions. This API has limited the development of zephyr because:
a. It is limited to flash, that resulted in not being able to use eeproms as a means for (settings, data, ...) storage,
b. It inherits and uses the flash erase-block-size that limits support for building bootloaders that use a combination of internal and external flash that do not have equivalent erase-block-sizes,
c. Forces users to create (flash) devices for more enhanced areas that would consist of a combination of flash and ram,
d. Forces users to create (flash) devices to support zephyr images that are stored on disk,
e. The api only allows to write data directly that leads to high stack usage when a combination of data needs to be written to storage (an example of this can be found in secure storage where a combination of data properties, data and validity check need to be written).
This all makes that an alternative to the flash_area API is needed.
Problem description
To solve the issues from the introduction a new subsystem for working with storage is required. This new subsystem should solve the above problems and also be easy extendable for storage devices that are not yet supported. The subsystem should allow us to work with data on flash, eeprom, rram, mram, ram, disk, (file ?), ...
Proposed change
A new subsystem:
storage_area
is proposed. Astorage_area
is no more than a definition of how a storage backend will be used and provides the required API to be able to read/write/erase the backend. Thestorage_area
api also provides a means to read and write chunks of data. It is a simple construct that allows simple addition of future extensions.The new subsystem from the start supports
storage_area
on flash, eeprom, ram and diskTogether with the
storage_area
astorage_area_store
is proposed that is a basic building block for storage solutions. In astorage_area_store
the storage area is divided into sectors and data is stored as simple records that are validated by a crc32.Each sector is started with a sector
cookie
that allows differentiating between severalstorage_area_stores
and allows version and/or data format description to be added by the storage solution. Thestorage_area_store
supports solution with and without persistence requirements, it can be used as a direct replacement offcb
, is an ideal base for id-value (nvs
) and/or key-value storage solutions. Present limitations imposed by e.g.nvs
regarding write-block-size or erase-block-size are removed. The ability to use write and read in chunks also makes it an ideal base for thesecure_storage
subsystem.Dependencies
The new subsystem has no dependencies.
@nashif, @butok, @andrisk-dev, @dleach02, @erwango, @FRASTM, @brix, @de-nordic
The text was updated successfully, but these errors were encountered: