subsys: reduce flash operations during ZBOSS NVRAM storage - #141
Open
edmont wants to merge 4 commits into
Open
Conversation
nvram_flash_write() issued a separate flash_area_write() for every flash write block, even when the data was aligned and contiguous. Storing a typical ZBOSS dataset therefore required many flash operations. Read-modify-write only the unaligned head and tail block and write the aligned middle in a single operation. The bytes written are unchanged, so this is transparent to ZBOSS. Verified on nRF54L15 by storing a network and restoring it after reset. Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
ZBOSS stores a dataset through many small consecutive zb_osif_nvram_write() calls and marks the end of the dataset with zb_osif_nvram_flush(). Each call previously reached flash separately, which made NVRAM storage slow. Gather writes that continue the cached range in RAM and commit them as one flash operation when ZBOSS flushes the dataset. Also commit before an erase, before a read so a reader always sees its own data, and from zb_osif_nvram_wait_for_last_op(). Writes that do not continue the range, and writes larger than the cache, commit what is pending first, so the bytes reaching flash and their order are unchanged. The cache is sized by CONFIG_ZIGBEE_NVRAM_WRITE_CACHE_SIZE and defaults to 512 bytes. Set it to 0 to disable the cache and write directly to flash. On multiprotocol SoCs where flash access is less contended, the default is 0. Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Contributor
|
You can find the documentation preview for this PR here. |
All path_triggers must point to the samples and boards that have defined integration_platforms entry. Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
ArekBalysNordic
force-pushed
the
pr/improve-flash-writes
branch
from
August 7, 2026 07:02
3304c61 to
12cebb7
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ZBOSS NVRAM storage issued too many small flash writes. This PR cuts that down in two ways:
nvram_flash_write()— write the aligned middle of a buffer in oneflash_area_write(), only the unaligned head and tail use read-modify-write.zb_osif_nvram_write()calls and commit them onzb_osif_nvram_flush().Flash content and write order are unchanged. Cache size is controlled by
CONFIG_ZIGBEE_NVRAM_WRITE_CACHE_SIZE(default 512 B; 0 on multiprotocol SoCs where flash is less contended).