DFU sample, missing boot_set_pending or boot_request_upgrade

Hi, I want to update an existing image in slot 1 with a new image in slot 2.

Both are flashed on the device and in my image 1 I want to initiate the DFU process, as mentioned in https://interrupt.memfault.com/blog/mcuboot-overview#triggering-firmware-upgrades-from-main-application. Also found some info in https://devzone.nordicsemi.com/f/nordic-q-a/78575/upgraded-firmware-image-not-confirmed-by-mcuboot-dfu

However the call boot_set_pending and/or boot_request_upgrade are not defined.
Is there some setting that will enable updating the image by the program itself?

Parents
  • Hello,

    If the update image has already been flashed to the second 2 slot, then it should be become activated (i.e. copied from slot 2 to 1) on next reboot. Calling boot_set_pending and/or boot_request_upgrade should not be necessary.

    Are you sure the image in slot 2 is a valid update image? And do you have logging enabled in the MCUboot to see if it detects the new update in slot 2?

    I would also recommend you have a look at this guide here:  Add DFU support to your applicationas it is written specifically for the Zephyr / nRF connect SDK port of the MCUboot bootloader unlike the memfault article.

    Best regards,

    Vidar

  • Hi Vidar,

    Thanks for your reply.

    I am a bit lost here. I build the MCuboot and flashed it on the development kit. It shows

    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    W: Failed reading image headers; Image=0
    E: Unable to find bootable image

    Next I flash my blinky_slot0 application. 
    After a reset it shows:
    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    [00:00:00.004,241] <inf> Blinky_slot1: Led ports initialized
    [00:00:00.010,559] <inf> Blinky_slot1: Led pins configured
    [00:00:00.016,906] <inf> mcuboot_util: Swap type: none
    [00:00:00.022,735] <inf> Blinky_slot1: Next action on the next reboot = NONE

    When I understand you correctly, flashing a second variant of the Blinky application in slot 1 (address 0x00067000) should result in a swap after a reset? What about the mcumgr command image test? I tried the proces mentioned in your link before. That one worked fine.
    As we do not add the mcumgr stuff, I hoped to initiate the swapping by the  boot_request_upgrade command. 

    So when the second Blinky (blinky_slot1) was flashed a reset did not start the second variant, but again the first.
    Activating the boot_request_upgrade and reset shows:

    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x3, copy_done=0x3, image_ok=0x1
    I: Boot source: none
    I: Swap type: perm
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    [00:00:00.004,241] <inf> Blinky_slot1: Led ports initialized
    [00:00:00.010,528] <inf> Blinky_slot1: Led pins configured
    [00:00:00.016,876] <inf> mcuboot_util: Swap type: none
    [00:00:00.022,705] <inf> Blinky_slot1: Next action on the next reboot = NONE

    It looks like something is gong on?
    But still the first image is running. A next rest will show the previous output.

    ( Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3).

    Do I miss something here?

Reply
  • Hi Vidar,

    Thanks for your reply.

    I am a bit lost here. I build the MCuboot and flashed it on the development kit. It shows

    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    W: Failed reading image headers; Image=0
    E: Unable to find bootable image

    Next I flash my blinky_slot0 application. 
    After a reset it shows:
    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    [00:00:00.004,241] <inf> Blinky_slot1: Led ports initialized
    [00:00:00.010,559] <inf> Blinky_slot1: Led pins configured
    [00:00:00.016,906] <inf> mcuboot_util: Swap type: none
    [00:00:00.022,735] <inf> Blinky_slot1: Next action on the next reboot = NONE

    When I understand you correctly, flashing a second variant of the Blinky application in slot 1 (address 0x00067000) should result in a swap after a reset? What about the mcumgr command image test? I tried the proces mentioned in your link before. That one worked fine.
    As we do not add the mcumgr stuff, I hoped to initiate the swapping by the  boot_request_upgrade command. 

    So when the second Blinky (blinky_slot1) was flashed a reset did not start the second variant, but again the first.
    Activating the boot_request_upgrade and reset shows:

    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x3, copy_done=0x3, image_ok=0x1
    I: Boot source: none
    I: Swap type: perm
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.0.99-ncs1 ***
    [00:00:00.004,241] <inf> Blinky_slot1: Led ports initialized
    [00:00:00.010,528] <inf> Blinky_slot1: Led pins configured
    [00:00:00.016,876] <inf> mcuboot_util: Swap type: none
    [00:00:00.022,705] <inf> Blinky_slot1: Next action on the next reboot = NONE

    It looks like something is gong on?
    But still the first image is running. A next rest will show the previous output.

    ( Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3).

    Do I miss something here?

Children
Related