This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue with mesh_config_clear() and MESH_CONFIG_STRATEGY_ON_POWER_DOWN

When mesh_config_clear() is called with a setup containing a file strategy MESH_CONFIG_STRATEGY_ON_POWER_DOWN and an entry in that file has been changed but not yet written to the backend, the internal state of that entry will retain it's dirty flag.

The issue is within dirty_entries_process() as the return code from mesh_config_backend_erase() is NRF_ERROR_NOT_FOUND but the code wrongly assumes it to be NRF_ERROR_NO_MEM.

This issues causes mesh_config_is_busy() to return true despite flash_manager_is_stable() returning true.

The following patch solves the issue by clearing the dirty flag if NRF_ERROR_NOT_FOUND is returned.

diff --git a/mesh/core/src/mesh_config.c b/mesh/core/src/mesh_config.c
index ae2c2ef..5e900d1 100644
--- a/mesh/core/src/mesh_config.c
+++ b/mesh/core/src/mesh_config.c
@@ -167,6 +167,11 @@ static void dirty_entries_process(void)
                         p_params->p_state[j] &= (mesh_config_entry_flags_t)~MESH_CONFIG_ENTRY_FLAG_DIRTY;
                         p_params->p_state[j] |= MESH_CONFIG_ENTRY_FLAG_BUSY;
                     }
+                    else if (status == NRF_ERROR_NOT_FOUND)
+                    {
+                        /* This can only happen with mesh_config_backend_erase() */
+                        p_params->p_state[j] &= (mesh_config_entry_flags_t)~MESH_CONFIG_ENTRY_FLAG_DIRTY;
+                    }
                     else
                     {
                         /* Back off if the backend call fails, to allow it to free up some resources */

Mesh SDK 3.2.0.

Thanks.

Parents Reply Children
Related