Skip to content

Commit

Permalink
[nrf noup] Lock thread stack before factory reset
Browse files Browse the repository at this point in the history
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 <patryk.lipinski@nordicsemi.no>
Signed-off-by: Michał Szablowski <michal.szablowski@nordicsemi.no>
  • Loading branch information
LipinskiPNordicSemi authored and doublemis1 committed Jan 29, 2024
1 parent 288b64a commit 4d80d20
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/platform/Zephyr/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include <zephyr/settings/settings.h>
#endif

#ifdef CONFIG_NET_L2_OPENTHREAD
#include <platform/ThreadStackManager.h>
#endif

namespace chip {
namespace DeviceLayer {

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

0 comments on commit 4d80d20

Please sign in to comment.