-
Notifications
You must be signed in to change notification settings - Fork 21
doc: nrf-bm: libraries: add bm_storage documentation #426
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
Open
MirkoCovizzi
wants to merge
2
commits into
nrfconnect:main
Choose a base branch
from
MirkoCovizzi:storage-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
.. _lib_storage: | ||
|
||
Storage Library | ||
############### | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
The Storage library provides abstractions for reading, writing, and erasing non-volatile memory (NVM). | ||
|
||
Overview | ||
******** | ||
|
||
The library supports multiple storage instances, each bound to a specific memory region, and reports operation results through user-defined event handlers. | ||
Depending on the backend and runtime state, operations may be synchronous or asynchronous. | ||
|
||
Configuration | ||
************* | ||
|
||
The library is enabled and configured entirely using the Kconfig system. | ||
Set the :kconfig:option:`CONFIG_BM_STORAGE` Kconfig option to enable the library. | ||
|
||
Select a storage backend by enabling one of the following Kconfig options: | ||
|
||
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_RRAM` – RRAM backend. The events reported are synchronous. | ||
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD` – SoftDevice backend. The events reported are asynchronous. | ||
|
||
SoftDevice backend options: | ||
|
||
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD_QUEUE_SIZE` – Queue size for pending operations. | ||
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD_MAX_RETRIES` – Maximum retries if the SoftDevice is busy. | ||
|
||
Initialization | ||
============== | ||
|
||
Each storage instance is represented by a :c:struct:`bm_storage` structure. | ||
|
||
To initialize a storage instance, use the :c:func:`bm_storage_init` function, providing the following information: | ||
|
||
* :c:member:`bm_storage.evt_handler` – Event callback. | ||
* :c:member:`bm_storage.start_addr` and :c:member:`bm_storage.end_addr` – Accessible address range. | ||
|
||
You can uninitialize a storage instance with the :c:func:`bm_storage_uninit` function. | ||
|
||
Usage | ||
***** | ||
|
||
The following is a list of operations you can perform with this library. | ||
|
||
Read | ||
==== | ||
|
||
Use the :c:func:`bm_storage_read` function to copy data from NVM into RAM. | ||
The data length must be a multiple of the backend’s program unit and within the configured region. | ||
|
||
Write | ||
===== | ||
|
||
Use the :c:func:`bm_storage_write` function to write data to NVM. | ||
Writes are validated against alignment and range, and completion is reported through :c:member:`bm_storage.evt_handler`. | ||
|
||
Erase | ||
===== | ||
|
||
Use the :c:func:`bm_storage_erase` function to erase a region in NVM. | ||
``len`` must be a multiple of the erase unit. | ||
If not supported by the backend, the call may return ``NRF_ERROR_NOT_SUPPORTED``. | ||
This means that the backend does not require the region to be erased before another write operation. | ||
|
||
Busy state | ||
========== | ||
|
||
Use the :c:func:`bm_storage_is_busy` function to check whether a backend is executing an operation. | ||
|
||
Events | ||
====== | ||
|
||
The following events may be reported to the user callback: | ||
|
||
* :c:enum:`BM_STORAGE_EVT_WRITE_RESULT` – Write operation completed. | ||
* :c:enum:`BM_STORAGE_EVT_ERASE_RESULT` – Erase operation completed. | ||
|
||
Each event includes the result code, information about the address range of the associated operation, and whether the operation is synchronous or asynchronous. | ||
|
||
Sample | ||
****** | ||
|
||
The usage of this library is demonstrated in the :ref:`storage_sample` sample. | ||
|
||
Dependencies | ||
************ | ||
|
||
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_RRAM`: | ||
|
||
This backend requires the following Kconfig options to be disabled: | ||
|
||
* :kconfig:option:`CONFIG_SOFTDEVICE` | ||
|
||
* :kconfig:option:`CONFIG_BM_STORAGE_BACKEND_SD`: | ||
|
||
This backend requires the following Kconfig options to be enabled: | ||
|
||
* :kconfig:option:`CONFIG_SOFTDEVICE` | ||
* :kconfig:option:`CONFIG_NRF_SDH` | ||
* :kconfig:option:`CONFIG_RING_BUFFER` | ||
|
||
API documentation | ||
***************** | ||
|
||
| Header file: :file:`include/bm_storage.h` | ||
| Source files: :file:`lib/bm_storage/` | ||
|
||
:ref:`Storage library API reference <api_storage>` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"must be a multiple of the backend’s program unit"
This leavs me with the question, what is the backend's program unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the sample we have the comment
Could probably be added to the documentation.