This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Firmware upgradable over USB based on nRF52840 with NCS/Zephyr

Hi

My goal is to create a USB HCI firmware that works on any custom board that exposes the USB port of a nRF52840. Based on the requirement for USB HCI it was clear to use NCS/Zephyr which has a working example for USB HCI. The problems cam in when t comes to the requirement "Upgradable". As the hardware has no button the update should be possible from the application itself.

Searching through the Zephyr/NCS documentation brought me to the USB DFU support of Zephyr. As far as I understand this it activates MCUBOOT as bootloader subimage and extends the application with the USB DFU class. Combined with the USB HCI we have in this setup two classes -> composite device. My extended configuration for the usb-hci sample looks as follows:
CONFIG_STDOUT_CONSOLE=y
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_GPIO_AS_PINRESET=y

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_RX_BUF_LEN=260
CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_CTLR_DTM_HCI=y

CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_BLUETOOTH=y

CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0xAD83
CONFIG_USB_DEVICE_MANUFACTURER="XYZ"
CONFIG_USB_DEVICE_PRODUCT="nRF52 HCI Dongle"

CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_DFU_CLASS=y

CONFIG_FLASH=y
CONFIG_IMG_MANAGER=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUBOOT_IMG_MANAGER=y

The built image works also properly on a nRF52840 DK. My thought was that now we can use the dfu-util (http://dfu-util.sourceforge.net/) to update the firmware. The tool can even be started and detects the USB-DFU device:

C:\Downloads\dfu-util-0.9-win64>dfu-util-static.exe -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to sourceforge.net/.../

Found Runtime: [1915:ad83] ver=0203, devnum=9, cfg=1, intf=1, path="3-3.2.3", alt=0, name="UNKNOWN", serial="DB??????????????"

But when I try to update the device it fails on the reset:

C:\Downloads\dfu-util-0.9-win64>dfu-util-static.exe -U app_update.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to sourceforge.net/.../

Opening DFU capable USB device...
ID 1915:ad83
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...
Lost device after RESET?

The entering into the DFU seems to fail everytime. Searching through the forums brought me to an issue in the Zephyr that explains that dfu-util will not work with composite devices on windows (https://github.com/zephyrproject-rtos/zephyr/issues/23337). It seems that this is an issue in the Windows USB behavior rigth? So there is no chance that it will be fixed in Zephyr.

My questions are now:
- Is there anything that can be done to make dfu-util work with composite devices under Windows?
- What other options do I have when the dfu-util can't be made working?
- What did other developers do with similar issues?

Any help or input about a buttonless DFU over USB in Zephyr/NCS is welcome.

Regards Adrian

 

Parents Reply
  • Hi Adrian,

    Based on the discussion in Zephyr issue #23337, there does not seem to be any workaround for this.

    I know about 2 different ways to do USB DFU/recovery in nRF Connect SDK and Zephyr.

    1) MCUBoot Serial Recovery over USB CDC ACM. But, AFAIK it will just overwrite the first slot. This is used on e.g. the Thingy:91 asset tracker application.

    2) DFU over HID, with B0 bootloader. This is the approach we are using in the nRF Desktop reference design. Documentation here and here. From the first link, “The update image is transmitted in the background through the Configuration channel. The configuration channel data is transmitted either through USB or over Bluetooth, using HID feature reports. This allows the device to be used normally during the whole process (that is, the device does not need to enter any special state in which it becomes non-responsive to the user).”

Children
No Data
Related