From 4936f9fa2be9e6cd16b02e4fcb9a7aff611f4981 Mon Sep 17 00:00:00 2001 From: Patryk Lipinski Date: Fri, 19 Jan 2024 15:37:43 +0100 Subject: [PATCH] [nrf noup] Lock thread stack before factory reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fix a problem with thread activity interrupting factory reset. This activity used to led to “Factory reset fail: -6”. Writing to cleared nvm flash pages caused the problem. Signed-off-by: Patryk Lipinski Signed-off-by: Michał Szablowski --- src/platform/Zephyr/ConfigurationManagerImpl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index 69e82aba22..15017bb800 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -40,6 +40,10 @@ #include #endif +#ifdef CONFIG_NET_L2_OPENTHREAD +#include +#endif + namespace chip { namespace DeviceLayer { @@ -177,6 +181,11 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) { ChipLogProgress(DeviceLayer, "Performing factory reset"); +// Lock the Thread stack to avoid unwanted interaction with settings NVS during factory reset. +#ifdef CONFIG_NET_L2_OPENTHREAD + ThreadStackMgr().LockThreadStack(); +#endif + #ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_NVS void * storage = nullptr; int status = settings_storage_get(&storage);