assert flash Memory Metadata not aligned after FOTA

Hi There

I run a NRF52840 with the MESH SDK, and use the Flash manager provided.

After some time i would like to update the Device over FOTA this ends in a Assert on booting with the new firmware at the point flash_manager.c Line 256

NRF_MESH_ASSERT(p_manager->config.p_area[i].metadata.pages_in_area == p_manager->config.page_count);

when erase the full mcu this assert is not showing up due no existing data.

In the best case i can keep the data in the Fields, when not how to erase the Flash bevore or at the FOTA?

Regards Simon

Parents Reply Children
  • Hi Susheel

    thanks for the links, they mostly recomend the --eraseall while programming over jlink.

    ACCESS_ELEMENT_COUNT and ACCESS_MODEL_COUNT only have an influence on the first Flash Manager controlled by the mesh_stack and shift the flash layout when changed what not happend in this case.

    I found many beginners struggling when loading different exampels without --eraseall of the mcu the get stuck in the asserts. 

    I would like to build a software version which can be uploaded over FOTA with a partial blank flash sector or check the nvmc for a flash config id which i can compare with my actual if it match i will proceed, otherwise i had to erase all the flash to ensure the data integrity.

    mesh_stack_config_clear() is alredy implemented and working as expected.

    while taking the mesh_stack_config_clear() as sample, there i discovered that the entry will be first overwritten and then cleared, otherwise i will find the metadata of the depreciated flash entry and assume the flash is valid?

    The assert i could reproduce is when the pagecount is increased so that the memory layout will be shiftedfor the following entries.

    Code line 10 assert at flash_manager.c line 256

    static bool flash_area_is_valid(const flash_manager_t * p_manager)
    {
        for (uint32_t i = 0; i < p_manager->config.page_count; i++)
        {
            if (metadata_is_valid(&p_manager->config.p_area[i].metadata))
            {
                /* Check that the existing metadata aligns with ours */
                NRF_MESH_ASSERT(p_manager->config.p_area[i].metadata.page_index == i);
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "check meta data: %x versus %x \n",p_manager->config.p_area[i].metadata.pages_in_area, p_manager->config.page_count);
                NRF_MESH_ASSERT(p_manager->config.p_area[i].metadata.pages_in_area == p_manager->config.page_count); // assert when structure is different
            }
            else
            {
                return false;
            }
        }
    
        return true;
    }

    <t:      10980>, flash_manager_defrag.c,  630, BOOTLOADERADDR(): 0xFFFFFFFF fm_recovery_area: 0x000FF000
    <t:      10993>, flash_manager.c,  826, FM area: 0x000FE000
    <t:      10996>, flash_manager.c,  256, check meta data: 1 versus 1 
    <t:      11000>, flash_manager.c,  826, FM area: 0x000FC000
    <t:      11003>, flash_manager.c,  256, check meta data: 1 versus 2 
    <t:      11006>, app_error_weak.c,  105, Mesh assert at 0x00035C60 (:0)

    Can you short summarise how to erase properly the user flash  entries/pages (without knowing the old layout).

    Regards

    Simon

Related