From b237efcbd1e65dceab20e08d80721b1b4a71e6da Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Thu, 2 Jan 2025 11:00:33 +0100 Subject: [PATCH] [nrf noup] Disable mpsl before factory reset We can speed up flash operations while performing a factory reset by disabling mpsl before that. Thanks to that flash operations do not wait for mpsl synchronization and all write operations take less time. Signed-off-by: Arkadiusz Balys --- config/nrfconnect/chip-module/Kconfig.defaults | 15 +++++++++++++++ src/platform/Zephyr/ConfigurationManagerImpl.cpp | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults index 3fc3381a3b..59e6f55fe7 100644 --- a/config/nrfconnect/chip-module/Kconfig.defaults +++ b/config/nrfconnect/chip-module/Kconfig.defaults @@ -72,6 +72,21 @@ config NVS_LOOKUP_CACHE_SIZE config ZMS_LOOKUP_CACHE_SIZE default 512 if ZMS +# Enable Dynamic interrupts to have a possibility to reconfigure it for devices that use MPSL +# on the application core and needs synchronization between MPSL and FLASH driver. +if MPSL + +config DYNAMIC_INTERRUPTS + default y + +config DYNAMIC_DIRECT_INTERRUPTS + default y + +config MPSL_DYNAMIC_INTERRUPTS + default y + +endif # MPSL + # ============================================================================== # Zephyr networking configuration # ============================================================================== diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index 81c5707cb5..0e2ded0c89 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -54,6 +54,10 @@ #include #endif +#ifdef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL +#include +#endif // CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL + namespace chip { namespace DeviceLayer { @@ -220,14 +224,20 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) } #else + ConnectivityMgr().ErasePersistentInfo(); + + // We should disable MPSL before performing multiple operations on flash to speed up this process. + // It is required only when synchronization between flash and MPSL is enabled. +#ifdef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL + mpsl_lib_uninit(); +#endif // CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL + const CHIP_ERROR err = PersistedStorage::KeyValueStoreMgrImpl().DoFactoryReset(); if (err != CHIP_NO_ERROR) { ChipLogError(DeviceLayer, "Factory reset failed: %" CHIP_ERROR_FORMAT, err.Format()); } - - ConnectivityMgr().ErasePersistentInfo(); #endif // CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS PlatformMgr().Shutdown();