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 Children
  • I see now I was a bit too quick in my reply yesterday as I mixed up two libraries, sorry for that. It is as you say, an overlap.

    MCUmgr and DFU target Lib are two separate methods to perform DFU. The _confirmed() function I referred to belongs to MCUmgr, while the dfu_target_schedule_update() belongs to DFU target lib and does the same thing as _confirmed(). AFAIK dfu_target_schedule_update()'s main job is to mark the images as test or confirm.

    As for showing how to perform a test reboot and confirm, I recommend you to have a look at these two samples: 

    1. The Cellular HTTP full modem update sample . https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/cellular/http_update/modem_full_update/README.html#dependencies 
    2. The LwM2M client sample https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/cellular/lwm2m_client/sample_description.html  

    Let me know if these samples are enough to show you how to use the DFU target library for test and/or confirm

    Kind regards,
    Andreas

  • 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

Related