Re: mcuboot + dfu-util on nRF52840 not able to update firmware


Nathan Miller
 

Pawel,

I tried out the DFU sample on your branch, and I'm not seeing the device show up as a DFU capable device. If I run sudo dfu-util -l it doesn't show up in the list, and if I run sudo dfu-util --alt 1 --download signed-hello.bin I see the error

dfu-util: No DFU capable USB device available


On Fri, May 11, 2018 at 10:47 AM Nathan Miller <nathan.miller@...> wrote:
Thanks Pawel and Carles. I'll pull that branch down and test it out!

On Fri, May 11, 2018 at 10:35 AM Zadrożniak, Paweł <Pawel.Zadrozniak@...> wrote:

It’s an adaptation of existing USBD driver from nRF SDK 15, not DFU-specific.

I haven’t enough time today to look at the DFU example, but I have shared my temporary version (which works with CDC example, also with logs enabled on level 4, but it’s very slow in that case) of the driver here:

 

https://github.com/pawelzadrozniak/zephyr/tree/nrfx_usbd

 

Feel free to test your application with that if you like; I will try DFU as well when I’m back in office at Monday.

 

From: Cufi, Carles
Sent: Friday, May 11, 2018 5:26 PM
To: Nathan Miller <nathan.miller@...>; Zadrożniak, Paweł <Pawel.Zadrozniak@...>
Cc: users@...; Johann Fischer <j.fischer@...>


Subject: Re: [Zephyr-users] mcuboot + dfu-util on nRF52840 not able to update firmware

 

Hi Nathan,

 

The enumeration issue might be caused by enabling logging in the USB subsystem, if you are doing that. We know that is an issue due to the delays that logging introduces during enumeration.

 

Regards,

 

Carles

 

From: Nathan Miller <nathan.miller@...>
Date: Friday, 11 May 2018 at 16:33
To: "Zadrożniak, Paweł" <Pawel.Zadrozniak@...>
Cc: "Cufi, Carles" <Carles.Cufi@...>, "users@..." <users@...>, Johann Fischer <j.fischer@...>
Subject: Re: [Zephyr-users] mcuboot + dfu-util on nRF52840 not able to update firmware

 

Thanks for the update. I'm really interested to hear what your result is, Pawel. Is this the lower-level, generic USB driver that's in rework, or is it something specific to DFU? If it's the former, could that have any impact on the apparent transport issue I'm having with the HCI sample as well? (https://lists.zephyrproject.org/g/users/topic/zephyr_hci_usb_nrf52840/18134782)

 

On Fri, May 11, 2018 at 4:39 AM Zadrożniak, Paweł <Pawel.Zadrozniak@...> wrote:

Hi.

 

I’ll try to run the example later with my work-in-progress driver and check if it works.

 

From: Cufi, Carles
Sent: Friday, May 11, 2018 11:33 AM
To: Nathan Miller <
nathan.miller@...>; users@...
Cc: Zadrożniak, Paweł <
Pawel.Zadrozniak@...>; Johann Fischer <j.fischer@...>
Subject: RE: [Zephyr-users] mcuboot + dfu-util on nRF52840 not able to update firmware

 

Hi Nathan,

 

This is unfortunately a known issue. The USB driver for nRF52840 is currently undergoing some heavy rework by Pawel (on copy) and he should be able to give you more details about the particular state of USB DFU itself.

 

Regards,

 

Carles

 

From: users@... <users@...> On Behalf Of Nathan Miller
Sent: 10 May 2018 23:52
To:
users@...
Subject: [Zephyr-users] mcuboot + dfu-util on nRF52840 not able to update firmware

 

Hi all,

I'm attempting to run the Zephyr USB DFU sample on an nRF52840 (pca10056 dev board) and having a bit of trouble getting it to work. I've compiled mcuboot and can load it on the board without a problem. I compiled it with no configuration changes except setting the board to nrf52840_pca10056 (
export ZEPHYR_BOARD=nrf52840_pca10056 before running cmake). I then compiled the DFU sample (samples/subsys/usb/dfu), targeting the same board. I signed the image using the following command:

~/mcuboot/scripts/imgtool.py sign --key ~/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 8 --version 1.2 --included-header ./zephyr/zephyr.hex signed-zephyr.hex

and loaded it on the board using nrfjprog. I used the hex file for the first image so as to not overwrite mcuboot, which seems to work as in the console output from the board I see this:

[MCUBOOT] [INF] main: Starting bootloader
[MCUBOOT] [INF] boot_status_source: Image 0: magic=unset, copy_done=0xff, image_ok=0xff
[MCUBOOT] [INF] boot_status_source: Scratch: magic=unset, copy_done=0x0, image_ok=0xff
[MCUBOOT] [INF] boot_status_source: Boot source: slot 0
[MCUBOOT] [INF] boot_swap_type: Swap type: none
[MCUBOOT] [INF] main: Bootloader chainload address offset: 0xc000
[MCUBOOT] [INF] main: Jumping to the first image slot
***** Booting Zephyr OS v1.11.0-952-gdc97fc2a6 *****

after this, I tried compiling the hello world application and signing the bin file using this command:

~/mcuboot/scripts/imgtool.py sign --key ~/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 8 --version 1.2 --included-header ./zephyr/zephyr.bin signed-hello.bin

and loading it using dfu-util:

sudo dfu-util --alt 1 --download signed-hello.bin

This unfortunately doesn't work. The error message seems intermittent, as sometimes I see

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 2fe3:0100
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
dfu-util: Cannot set alternate interface

and sometimes instead I see

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 2fe3:0100
Run-time device DFU version 0110
Claiming USB DFU Runtime Interface...
Determining device status: state = appIDLE, status = 0
Device really in Runtime Mode, send DFU detach request...
Resetting USB...
Opening DFU USB Device...
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 64
Copying data from PC to DFU device
Download        [                         ]   0%            0 bytesdfu-util: Error during download get_status

Regardless of which error I see, it never applies the new firmware. In the second case, I see this on the device console:

[MCUBOOT] [INF] main: Starting bootloader
[MCUBOOT] [INF] boot_status_source: Image 0: magic=unset, copy_done=0xff, image_ok=0xff
[MCUBOOT] [INF] boot_status_source: Scratch: magic=unset, copy_done=0x0, image_ok=0xff
[MCUBOOT] [INF] boot_status_source: Boot source: slot 0
[MCUBOOT] [INF] boot_swap_type: Swap type: none
[MCUBOOT] [INF] main: Bootloader chainload address offset: 0xc000
[MCUBOOT] [INF] main: Jumping to the first image slot
***** Booting Zephyr OS v1.11.0-952-gdc97fc2a6 *****
[usb/dc] [ERR] handle_ctrl_ep_data_state_events: invalid event 0 in data state for EP 0

Am I doing something wrong or missing a step? I'm attempting to follow the instructions on these pages:
http://docs.zephyrproject.org/samples/subsys/usb/dfu/README.html and https://mcuboot.com/mcuboot/readme-zephyr.html
I'm a bit stuck at this point and don't exactly know how to proceed.

Join users@lists.zephyrproject.org to automatically receive all group messages.