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

DSM/Access Metadata clear after change doesn't work properly in Mesh SDK 4.0.0

In case the DSM metadata is changed compared to what is stored on flash, the 4.0.0 code is supposed to clear the flash from any configuration but this doesn't work properly for metadata.

When mesh_config_load() reads all entries from flash, dsm_metadata_setter() is called and detects that the metadata has changed and returns NRF_ERROR_INVALID_DATA.

Returning NRF_ERROR_INVALID_DATA will trigger a LOAD_FAILURE_INVALID_DATA and the MESH_CONFIG_ENTRY_FLAG_ACTIVE flag is never set for this entry.

Later on when dsm_mesh_config_clear() is called due to the previous LOAD_FAILURE_INVALID_DATA the call to mesh_config_entry_delete() will do nothing as the MESH_CONFIG_ENTRY_FLAG_ACTIVE was never set.

As the correct metadata is never written after dsm_clear the old broken metadata will remain for ever in flash causing the persistent storage to fail on every boot.

The same problem applies to access layer as well.

By looking at the code, the mesh_config API could use a mesh_config_clear_file() which would actually erase the backend page properly instead of manually erasing each and every entry.

Thanks.

Parents
  • After doing a DFU today, we have experienced the same, including a mesh assert, caused be the ERROR_CHECK() . see code below

    We have not solved the problem our self yet, but to get it up running I guess you have to wait for an flash stable event after the mesh config has been cleared during initialization of the mesh, maybe followed by a system reset (reboot).

    void mesh_init(void)
    {
        mesh_stack_init_params_t init_params =
        {
            /* Run application and mesh event handling in main loop using app_scheduler:
               When using the APP_SCHED to post event, the irq_priority must be changed from
               NRF_MESH_IRQ_PRIORITY_LOWEST to NRF_MESH_IRQ_PRIORITY_THREAD in order to avoid
               mesh app assert. */
            .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_THREAD, //NRF_MESH_IRQ_PRIORITY_LOWEST,
            .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
            .core.p_uuid             = NULL,
            .models.models_init_cb   = models_init_cb,
            .models.config_server_cb = config_server_evt_cb
        };
        ERROR_CHECK(mesh_stack_init(&init_params, &m_device_provisioned));
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"Provisioned:%d\n",m_device_provisioned);
    
        /* Register event handler to receive LPN, friendship events and NRF_MESH_EVT_FLASH_STABLE.
           Application functionality should be started after receiving NRF_MESH_EVT_FLASH_STABLE event. */
        nrf_mesh_evt_handler_add(&m_mesh_core_event_handler);
    }

Reply
  • After doing a DFU today, we have experienced the same, including a mesh assert, caused be the ERROR_CHECK() . see code below

    We have not solved the problem our self yet, but to get it up running I guess you have to wait for an flash stable event after the mesh config has been cleared during initialization of the mesh, maybe followed by a system reset (reboot).

    void mesh_init(void)
    {
        mesh_stack_init_params_t init_params =
        {
            /* Run application and mesh event handling in main loop using app_scheduler:
               When using the APP_SCHED to post event, the irq_priority must be changed from
               NRF_MESH_IRQ_PRIORITY_LOWEST to NRF_MESH_IRQ_PRIORITY_THREAD in order to avoid
               mesh app assert. */
            .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_THREAD, //NRF_MESH_IRQ_PRIORITY_LOWEST,
            .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
            .core.p_uuid             = NULL,
            .models.models_init_cb   = models_init_cb,
            .models.config_server_cb = config_server_evt_cb
        };
        ERROR_CHECK(mesh_stack_init(&init_params, &m_device_provisioned));
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"Provisioned:%d\n",m_device_provisioned);
    
        /* Register event handler to receive LPN, friendship events and NRF_MESH_EVT_FLASH_STABLE.
           Application functionality should be started after receiving NRF_MESH_EVT_FLASH_STABLE event. */
        nrf_mesh_evt_handler_add(&m_mesh_core_event_handler);
    }

Children
No Data
Related