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
  • I am not a DFU/FOTA expert, so thinking out loud here.

    After a FOTA, the device seems to hit an assert at boot because the mesh flash metadata on the chip seems to not match the flash-manager layout compiled into the new firmware. The flash manager reads the stored page count and compares it to the current config. If they differ, it asserts.

    You can try one to keep the layout fixed across releases. Use the same base addresses and page counts for all flash-manager areas. If nothing moves, the stored metadata still matches and your data stays intact. Or If the layout changed, clear the mesh areas on first boot of the new image. Do this before bringing up the mesh stack: Call mesh_stack_config_clear() to wipe mesh configuration and network state, or For your own managers, call flash_manager_remove() and wait for completion. Then reboot and let the stack rebuild its areas.

    If you need to preserve your own data, keep it in a separate flash-manager area that never moves between releases. That way you can clear mesh state when needed without touching your app data.

Reply
  • I am not a DFU/FOTA expert, so thinking out loud here.

    After a FOTA, the device seems to hit an assert at boot because the mesh flash metadata on the chip seems to not match the flash-manager layout compiled into the new firmware. The flash manager reads the stored page count and compares it to the current config. If they differ, it asserts.

    You can try one to keep the layout fixed across releases. Use the same base addresses and page counts for all flash-manager areas. If nothing moves, the stored metadata still matches and your data stays intact. Or If the layout changed, clear the mesh areas on first boot of the new image. Do this before bringing up the mesh stack: Call mesh_stack_config_clear() to wipe mesh configuration and network state, or For your own managers, call flash_manager_remove() and wait for completion. Then reboot and let the stack rebuild its areas.

    If you need to preserve your own data, keep it in a separate flash-manager area that never moves between releases. That way you can clear mesh state when needed without touching your app data.

Children
  • Hi Susheel

    You named it on the point, as long the flash entries not change the update runs without any problems. After some time in the field there are aditional features developed and with that, more data to store. For the features the harware remains in the field and a software update will be performed.

    I will go the way to first boot erase all the data to be shure there is no assert or corrupt data.

    To know that im first booting, i would like to write on the ucir from the application, reading is working but write fails:

    this i tried following example from the devzone:

          NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
          while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
          *(uint32_t *)0x10001090 = 0xFFFFFFFE;
          NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
          while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

    what am i missing at this point?  The Memory remains FF FF FF FF

    regards Simon

Related