From 241fd44d968f3847cf05c794b24321fbed344cb5 Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Fri, 11 Oct 2024 10:21:24 +0200 Subject: [PATCH] [nrf toup][nrfconnect] Enable ZMS in nrfconnect if RRAM is in use. Disabled NVS and enabled ZMS fs backend for all devices that uses RRAM. Signed-off-by: Arkadiusz Balys --- config/nrfconnect/chip-module/CMakeLists.txt | 7 +++++++ config/nrfconnect/chip-module/Kconfig | 12 ++++++++---- config/nrfconnect/chip-module/Kconfig.defaults | 5 ++++- docs/guides/nrfconnect_examples_configuration.md | 4 ++-- src/platform/nrfconnect/FactoryDataProvider.cpp | 4 ++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 6f8744c908..9d4004c352 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -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() # ============================================================================== diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index e5251902af..ddcefeb568 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -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 @@ -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 || KVS depends on !CHIP_CRYPTO_PSA_MIGRATE_DAC_PRIV_KEY config CHIP_LOG_SIZE_OPTIMIZATION diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults index edf3c1e707..ded3ea9aa5 100644 --- a/config/nrfconnect/chip-module/Kconfig.defaults +++ b/config/nrfconnect/chip-module/Kconfig.defaults @@ -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 diff --git a/docs/guides/nrfconnect_examples_configuration.md b/docs/guides/nrfconnect_examples_configuration.md index 1e74d2f4e0..4a10f6cc1c 100644 --- a/docs/guides/nrfconnect_examples_configuration.md +++ b/docs/guides/nrfconnect_examples_configuration.md @@ -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 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 diff --git a/src/platform/nrfconnect/FactoryDataProvider.cpp b/src/platform/nrfconnect/FactoryDataProvider.cpp index 23864a82f8..6b0ff14c31 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.cpp +++ b/src/platform/nrfconnect/FactoryDataProvider.cpp @@ -160,6 +160,10 @@ CHIP_ERROR FactoryDataProvider::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 lose the DAC private key permanently 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);