MCUboot test and confirm with DFU Target library

I'm adding MCUboot to my application and we'll be using our own app to upload new firmware over BLE to the device over our custom comms protocol. I can use the DFU Target library to transfer the uploaded blocks into the second application slot, and it looks as if dfu_target_schedule_update() will mark the image as ready to load on next reboot.

My question is, how do you set up a test reboot and how do you confirm it once comms has been reestablished in the new image?

Parents Reply
  • In case it helps anyone else with the same question, I searched the ncs 2.8.0 folder structure and found the following:

    dfu_target_schedule_update(img_num), when used with MCUboot, internally calls boot_request_upgrade_multi(img_num, BOOT_UPGRADE_TEST)

    So scheduling an update and rebooting will boot the new application code as test. It needs to be confirmed in my application code after reboot and once I've established BLE connection again to to prove that the new code is working.

    In the LWM2M code I found this, which seems to be what I need for that task:

    __weak bool lwm2m_os_dfu_application_update_validate(void)
    {
    #if defined(CONFIG_MCUBOOT_IMG_MANAGER)
      int err;
      bool img_confirmed;

      img_confirmed = boot_is_img_confirmed();
      if (!img_confirmed) {
        err = boot_write_img_confirmed();
        if (err == 0) {
          LOG_INF("Marked running image as confirmed");
          return true;
        }

        LOG_WRN("Failed to mark running image as confirmed");
      }
    #endif /* CONFIG_MCUBOOT_IMG_MANAGER */

      return false;
    }

    Simon

Children
No Data
Related