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?

  • Hi Vidar,

    My concept if finally working! I was able to use the smp_svr and foud out what was wrong in my setup.

    I took the following steps:

    1. Build the MCUboot (mcuboot\boot\zephyr)
    2. Flash the MCUboot on the nRF52840DK with VSCode
    3. Created a blinky1, building it and flash it with VSCode
      The application will flash all leds.
      The application will call boot_request_upgrade(BOOT_UPGRADE_TEST); when button 1 is pressed
      The application will reboot when button2 is pressed.
      The application will call boot_write_img_confirmed(); when button 3 is pressed.
    4. Created a blinky2, building it and flashed it with JFlash to address 00086000!!
    5. The application will flash 2 leds.
      The application will call boot_request_upgrade(BOOT_UPGRADE_TEST); when button 1 is pressed
      The application will reboot when button2 is pressed
      The application will call boot_write_img_confirmed(); when button 3 is pressed.

     Now I am able to switch from blinky1 to blinky2 as planned.

    Still one important question. Why do I need to flash the second blinky to address 00086000 while the dts file stated:

    slot1_partition: partition@73000 {
          label = "image-1";
          reg = <0x00073000 0x00067000>;
        };

     I was expecting the address to be 0x00073000 ...

  • Hi,

    Thanks for the update. I'm glad to hear that it works now.

    The Partition Manager takes over and controls the placement of the various sections when you do a multi-image build. This is why the DT entries are ignoreg, which can be confusing. You can find the actual placement of the different flash regions listed in the <build dir>/partitions.yml file.

  • Hello,

    I’m working on a similar setup and I believe I’m encountering the same issue. That’s why I’d like to ask you a few questions.

    First, let me briefly explain the structure of my project:
    I’m using an external SPI flash configured with FATFS as mass storage (the external flash is only used for storage — mcuboot_secondary is not defined in the external flash region).
    The test scenario I’m trying to implement is quite similar to yours.

    I built the Blinky1 firmware in a way that it checks whether "app_signed.hex" exists in the external flash. I then flashed Blinky1 to the board using J-Link through VS Code.
    If app_signed.hex is found, it is copied into the mcuboot_secondary region (FLASH_AREA_ID(mcuboot_secondary)), and then boot_request_upgrade(BOOT_UPGRADE_PERMANENT) is called.
    Right after that, the system is rebooted via sys_reboot(SYS_REBOOT_COLD) to trigger the update.

    Later, I modified the firmware to Blinky2, which activates different LEDs and does not check for app_signed.hex (to avoid repeated updates).
    While Blinky1 is running, I connect the board via USB and copy the app_signed.hex file to the mass storage disk.
    The file is detected, the steps mentioned above are executed, and the MCU resets — but it boots into Blinky1 again instead of Blinky2.

    My questions are:

    1. Is app_signed.hex the correct file to write into the mcuboot_secondary slot?

    2. While writing to mcuboot_secondary, I encountered alignment issues. I had to pad the end of the file with 0xFF bytes to complete the write. Is this a correct approach, or am I doing something wrong?

    3. After calling boot_request_upgrade(BOOT_UPGRADE_TEST);, I immediately call sys_reboot(SYS_REBOOT_COLD);. Do I need to perform any additional steps (such as confirming the upgrade) before rebooting?

    I’d really appreciate any help or guidance you can provide.
    Best regards,
    Cagri

Related