Hi,
Could you please have a look at the dfu-util output and give me a hint on why what I'm doing is not working. Here is a description of the problem:
I am using an NRF52840DK.
1. I erase the chip to start clean:
nrfjprog --eraseall
2. I flash the MCUboot bootloader:
~/mcuboot/boot/zephyr$ west flash
The output from the console is OK as there is no image:
*** Booting MCUboot v2.1.0-43-g50f35144e4e4 *** *** Using Zephyr OS build v3.6.0-596-g9fa4cd8226ce *** 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
3. I flash my first USB DFU enabled image:
~/zephyr/usb_dfu/build/zephyr$ nrfjprog --program build/zephyr/zephyr.signed.hex
After resetting, the console output is OK and the image is executed:
*** Booting MCUboot v2.1.0-43-g50f35144e4e4 *** *** Using Zephyr OS build v3.6.0-596-g9fa4cd8226ce *** 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: Image index: 0, Swap type: none I: Bootloader chainload address offset: 0xc000 I: Jumping to the first image slot [00:00:00.000,213] <err> qspi_nor: JEDEC id [00 00 00] expect [c2 28 17] *** Booting Zephyr OS build v3.6.0-596-g9fa4cd8226ce *** [00:00:00.000,549] <inf> main: This device supports USB DFU class.
4. I check dfu-util:
~/zephyr/counter/build/zephyr# dfu-util -l dfu-util 0.11
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2021 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to sourceforge.net/.../
Found Runtime: [2fe3:0005] ver=0306, devnum=117, cfg=1, intf=0, path="3-3.4.3", alt=0, name="UNKNOWN", serial="4327BC869F6C049C"
Notice there is only alt=0
5. I try to download the new image:
~/zephyr/counter/build/zephyr# dfu-util --download zephyr.signed.hex
The download fails but alt=1 appears:
dfu-util 0.11
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2021 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to sourceforge.net/.../
dfu-util: Warning: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release Opening DFU capable USB device... Device ID 2fe3:0005 Device DFU version 0110 Claiming USB DFU (Run-Time) Interface... Setting Alternate Interface zero... Determining device status... DFU state(0) = appIDLE, status(0) = No error condition is present Device really in Run-Time Mode, send DFU detach request... Device will detach and reattach... dfu-util: More than one DFU capable USB device found! Try `--list' and specify the serial number or disconnect all but one device
6. I try to download the new image in the newly appeared slot:
~/zephyr/counter/build/zephyr# dfu-util --download zephyr.signed.hex --alt 1
This time dfu-util succeeds:
dfu-util 0.11
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2021 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to sourceforge.net/.../
dfu-util: Warning: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release Opening DFU capable USB device... Device ID 2fe3:ffff Device DFU version 0110 Claiming USB DFU Interface... Setting Alternate Interface #1 ... Determining device status... DFU state(2) = dfuIDLE, status(0) = No error condition is present DFU mode device DFU version 0110 Device returned transfer size 128 Copying data from PC to DFU device Download [=========================] 100% 177796 bytes Download done. DFU state(2) = dfuIDLE, status(0) = No error condition is present Done!
But after I press reset, the board swaps but still boots the old image:
*** Booting MCUboot v2.1.0-43-g50f35144e4e4 *** *** Using Zephyr OS build v3.6.0-596-g9fa4cd8226ce *** I: Starting bootloader I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3 I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3 I: Boot source: none I: Image index: 0, Swap type: test I: Bootloader chainload address offset: 0xc000 I: Jumping to the first image slot [00:00:00.000,213] <err> qspi_nor: JEDEC id [00 00 00] expect [c2 28 17] *** Booting Zephyr OS build v3.6.0-596-g9fa4cd8226ce *** [00:00:00.000,549] <inf> main: This device supports USB DFU class.
Best regards,
-- Alex
The dfu-util output of the download looks fine to me. I'd assume the problem is in the boot loader on the target device, not dfu-util.
On Tue, Aug 13, 2024 at 2:52 AM Alexander Feldman wrote:
- I check dfu-util:
Found Runtime: [2fe3:0005] ver=0306, devnum=117, cfg=1, intf=0, path="3-3.4.3", alt=0, name="UNKNOWN", serial="4327BC869F6C049C"
Notice there is only alt=0
Yes, in Run-Time mode there can only be one DFU interface, thus with alt=0.
The dfu-util -a filter option will only apply to DFU Mode interfaces. If you specify the correct -a value you should be able to do this with a single invocation of dfu-util.
- I try to download the new image:
~/zephyr/counter/build/zephyr# dfu-util --download zephyr.signed.hex
The download fails but alt=1 appears:
Out of curiosity, what does dfu-util --list report at this stage, with the device in DFU mode?
- I try to download the new image in the newly appeared slot:
~/zephyr/counter/build/zephyr# dfu-util --download zephyr.signed.hex --alt 1
Are you sure the bootloader expects a .hex file? It is possible that the bootloader receives the whole payload, says thanks and bye to dfu-util, for then to take a look at the payload and decides to ignore it.
Tormod
Thanks Tormod and Harald!
I found the problem. The problem was I was trying to send .hex via dfu-util and not .bin. Maybe we should try to probe .hex files and generate a warning as such obvious mistakes are easy to make. The other issue with reattaching the USB to the host disappeared as well.
Best regards,
-- Alex
On 8/13/24 12:25, Tormod Volden wrote:
On Tue, Aug 13, 2024 at 2:52 AM Alexander Feldman wrote:
- I check dfu-util:
Found Runtime: [2fe3:0005] ver=0306, devnum=117, cfg=1, intf=0, path="3-3.4.3", alt=0, name="UNKNOWN", serial="4327BC869F6C049C"
Notice there is only alt=0
Yes, in Run-Time mode there can only be one DFU interface, thus with alt=0.
The dfu-util -a filter option will only apply to DFU Mode interfaces. If you specify the correct -a value you should be able to do this with a single invocation of dfu-util.
I try to download the new image:
~/zephyr/counter/build/zephyr# dfu-util --download zephyr.signed.hex
The download fails but alt=1 appears:
Out of curiosity, what does dfu-util --list report at this stage, with the device in DFU mode?
I try to download the new image in the newly appeared slot:
~/zephyr/counter/build/zephyr# dfu-util --download zephyr.signed.hex --alt 1
Are you sure the bootloader expects a .hex file? It is possible that the bootloader receives the whole payload, says thanks and bye to dfu-util, for then to take a look at the payload and decides to ignore it.
Tormod _______________________________________________ dfu-util mailing list -- dfu-util@lists.osmocom.org To unsubscribe send an email to dfu-util-leave@lists.osmocom.org
The file contents is undefined in the DFU spec.
There could hypothetically be a bootloader on some target, which requires data to be in hex format. Therefore dfu-util cannot make any assumptions on the contents/formatting of the data.
If at all, the target device would need to have such checks and reject it.