Skip to content

Commit

Permalink
[nrf noup] Disable mpsl before factory reset
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ArekBalysNordic committed Jan 9, 2025
1 parent ad8ba68 commit d4993d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions config/nrfconnect/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==============================================================================
Expand Down
14 changes: 12 additions & 2 deletions src/platform/Zephyr/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
#include <platform/ThreadStackManager.h>
#endif

#ifdef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL
#include <mpsl/mpsl_lib.h>
#endif // CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL

namespace chip {
namespace DeviceLayer {

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d4993d3

Please sign in to comment.