Skip to content

Commit

Permalink
[nrf toup][nrfconnect] Enable ZMS in nrfconnect if RRAM is in use.
Browse files Browse the repository at this point in the history
Disabled NVS and enabled ZMS fs backend for all devices that
uses RRAM.

Signed-off-by: Arkadiusz Balys <[email protected]>
  • Loading branch information
ArekBalysNordic authored and rlubos committed Oct 16, 2024
1 parent 0c49058 commit 9a4ea8e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
7 changes: 7 additions & 0 deletions config/nrfconnect/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ if (CONFIG_CHIP_PW_RPC)
matter_add_gn_arg("pw_build_LINK_DEPS" [\"${PIGWEED_DIR}/pw_assert:impl\",\ \"${PIGWEED_DIR}/pw_log:impl\"])
endif()

# Inform users that they use not-optimized settings backend for the nRF54LX series.
if(CONFIG_SOC_SERIES_NRF54LX AND CONFIG_SETTINGS_NVS)
message(WARNING "
The nRF54L series is not optimized for the NVS settings backend due to RRAM specifications.
Consider using the CONFIG_SETTINGS_ZMS Kconfig option, which is recommended for this type of non-volatile memory.")
endif()

matter_generate_args_tmp_file()

# ==============================================================================
Expand Down
12 changes: 8 additions & 4 deletions config/nrfconnect/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
rsource "../../zephyr/Kconfig"

config CHIP
imply NVS_LOOKUP_CACHE
imply NVS_LOOKUP_CACHE_FOR_SETTINGS
imply NVS if !SOC_FLASH_NRF_RRAM
imply NVS_LOOKUP_CACHE if !SOC_FLASH_NRF_RRAM
imply NVS_LOOKUP_CACHE_FOR_SETTINGS if !SOC_FLASH_NRF_RRAM
imply ZMS if SOC_FLASH_NRF_RRAM
imply ZMS_LOOKUP_CACHE if SOC_FLASH_NRF_RRAM
imply ZMS_LOOKUP_CACHE_FOR_SETTINGS if SOC_FLASH_NRF_RRAM

if CHIP

Expand Down Expand Up @@ -322,9 +326,9 @@ config CHIP_DEVICE_GENERATE_ROTATING_DEVICE_UID
endif # CHIP_FACTORY_DATA_BUILD

# See config/zephyr/Kconfig for full definition
config CHIP_FACTORY_RESET_ERASE_NVS
bool
config CHIP_FACTORY_RESET_ERASE_SETTINGS
default y
depends on NVS || ZMS
depends on !CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY

config CHIP_LOG_SIZE_OPTIMIZATION
Expand Down
5 changes: 4 additions & 1 deletion config/nrfconnect/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ config COMMON_LIBC_MALLOC_ARENA_SIZE
default -1

config NVS_LOOKUP_CACHE_SIZE
default 512
default 512 if NVS

config ZMS_LOOKUP_CACHE_SIZE
default 512 if ZMS

# ==============================================================================
# Zephyr networking configuration
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/nrfconnect_examples_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ set the `CONFIG_CHIP_NFC_COMMISSIONING` option.
By default, the factory reset procedure implemented in the Matter stack removes
Matter-related settings only. If your application does not depend on any
device-lifelong data stored in the non-volatile storage, set the
`CONFIG_CHIP_FACTORY_RESET_ERASE_NVS` option to fully erase the NVS partition at
the factory reset. This approach is more robust and regains the original NVS
`CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS` option to fully erase the non-volatile settings partition at
the factory reset. This approach is more robust and regains the original non-volatile
performance in case it has been polluted with unwanted entries.
#### Logging
Expand Down
4 changes: 4 additions & 0 deletions src/platform/nrfconnect/FactoryDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ CHIP_ERROR FactoryDataProvider<FlashFactoryData>::MoveDACPrivateKeyToSecureStora
}

#ifdef CONFIG_CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY
#ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS
#error "Do not use both CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS and CONFIG_CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY kconfig options " \
"because you will permanently lose the DAC private key from the device."
#endif
// Check once again if the saved key has attributes set before removing it from the factory data set.
VerifyOrReturnError(psa_get_key_attributes(mDACPrivKeyId, &attributes) == PSA_SUCCESS, CHIP_ERROR_INTERNAL);

Expand Down

0 comments on commit 9a4ea8e

Please sign in to comment.