ZMS sync with latest changes in zephyr main#4101
Merged
Merged
Conversation
Closed
de-nordic
approved these changes
May 20, 2026
Add mount_flags to zms_fs structure to be able to control the mount operation. If ZMS_MOUNT_FLAG_NO_FORMAT flag is enabled, no header will be added to an erased memory and it will return -ENOTSUP error. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no> (cherry picked from commit a5e7080)
Add tests for the ZMS_MOUNT_FLAG_NO_FORMAT flag when mounting a storage Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no> (cherry picked from commit 0a93151)
Updtae the documentation and describe the usage of the mount_flags. Detail the ZMS_MOUNT_FLAG_NO_FORMAT optional flag. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no> (cherry picked from commit 9f7802e)
…oard target Fix number of writes to trigger a GC for native_sim/native/64 board as it has a different sector size. Fix the returned value for zms_free_space when ate_wra < data_wra. Skip test_zms_gc_3sectors for targets that have a sector size different than 1KB. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no> (cherry picked from commit 64997e4)
When executing this test with flash simulator some flash_write are manually injected to simulate data corruption. Add a flash_erase before these writes to fix the test. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no> (cherry picked from commit f331ee5)
...which calculates the maximum number of times a single ZMS sector has been recycled. This is to enable estimation of an RRAM lifetime based on a set of tests. Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no> Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit 72032cb)
…r erase In zms_gc(), the sector erase at zms_flash_erase_sector() destroyed the empty ATE holding full_cycle_cnt before zms_add_empty_ate() could read it, causing zms_get_full_sector_cycle() to always return -ENOENT and resetting the count to 0 (stored as 1). The counter could never exceed 1. Fix by reading full_cycle_cnt before erasing and passing the saved value to zms_add_empty_ate() via a new prev_cycle_cnt parameter. Apply the same read-before-erase pattern in zms_init() recovery paths. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit 893f3dd)
Add zms_get_sector_num_cycles() to retrieve the 32-bit cycle count for a specific sector. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit 9196b58)
Add a sample that exercises zms_get_num_cycles() by advancing sectors in a loop and verifying the counter increments correctly, including past the uint8_t wraparound boundary at 256. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit 134cc43)
…fix wipe In zms_add_empty_ate(), use zms_get_sector_cycle() for the 8-bit cycle_cnt (data validity) independently from the 32-bit full_cycle_cnt (erase tracking). Previously cycle_cnt was derived from full_cycle_cnt which broke when zms_verify_and_increment_cycle_cnt double-incremented cycle_cnt. In zms_wipe_partition(), read each sector's full_cycle_cnt before erasing so the count is preserved. This is needed for RRAM/MRAM devices where zms_flash_erase_sector is a no-op. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit a3c7d23)
List of added tests : - zms.test_zms_cycle_count_input_validation - zms.test_zms_cycle_count_increments - zms.test_zms_cycle_count_persistence Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit cce771e)
…4-bit mode The 64-bit ATE format only has a 4-byte payload union after the 8-byte id, so empty_ate.full_cycle_cnt and empty_ate.metadata alias the same 4 bytes. zms_add_empty_ate() wrote both — metadata first (needed for format/version detection on mount) then full_cycle_cnt — and the second write silently clobbered the first. As a result, every empty ATE in 64-bit ID mode lost its magic/version, zms_init() failed to recognise sectors on remount, and tests including test_zms_gc, test_zms_full_sector and test_zms_id_64bit failed silently. In 64-bit ID mode, skip the empty_ate.full_cycle_cnt write entirely so metadata stays intact. The 8-bit empty_ate.cycle_cnt (a separate field at byte offset 1, with no aliasing) is now seeded from prev_cycle_cnt on the just-erased path so it accumulates across recycles modulo 256 and doubles as the cumulative wear counter exposed by zms_get_num_cycles() / zms_get_sector_num_cycles(). The 32-bit ID codepath keeps the existing 32-bit full_cycle_cnt range and behaviour. Trade-off: in 64-bit ID mode the cycle counter wraps every 256 cycles instead of every ~4 billion. The 32-bit ID format is unchanged. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit cd38efa)
The field is no longer written in 64-bit mode, so remove it from the struct. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit b2620ba)
Match zms_get_sector_num_cycles(): return int and pass the value through an output pointer. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit 63568b7)
Extend test_zms_cycle_count_persistence to call zms_clear() between the advances and the remount and check the counter is preserved. Signed-off-by: Mircea Caprioru <mcaprioru@baylibre.com> (cherry picked from commit fa07d33)
9845e39 to
3517dd4
Compare
NordicBuilder
added a commit
to NordicBuilder/sdk-nrf
that referenced
this pull request
May 22, 2026
Automatically created by action-manifest-pr GH action from PR: nrfconnect/sdk-zephyr#4101 Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
carlescufi
approved these changes
May 22, 2026
NordicBuilder
added a commit
to NordicBuilder/sdk-nrf
that referenced
this pull request
May 25, 2026
Automatically created by action-manifest-pr GH action from PR: nrfconnect/sdk-zephyr#4101 Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
rlubos
pushed a commit
to nrfconnect/sdk-nrf
that referenced
this pull request
May 25, 2026
Automatically created by action-manifest-pr GH action from PR: nrfconnect/sdk-zephyr#4101 Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
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.
Synhcronize ZMS with merged upstream PRs :
zephyrproject-rtos/zephyr#108096
zephyrproject-rtos/zephyr#105593
zephyrproject-rtos/zephyr#108283
zephyrproject-rtos/zephyr#108124