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


Adam Mooers
 

I am able to replicate this problem with Zephyr v1.14.0 and nrf52840 PCA10056 hardware rev 1.1.0. The same "Error during download get_status" error occurred while flashing to slot 1.

Host Configuration:

    • Ubuntu 16.04 fully updated

Bootloader Configuration:

    Environment:
        • MCUboot 1.2 compiled with Zephyr SDK 0.9.5 and Zephyr OS v1.13.00
  
    Build Steps:
        • cd boot/zephyr
        • mkdir build && cd build
        • cmake -GNinja -DBOARD=nrf52840_pca10056  ..
        • ninja
        • ninja flash

    These instructions mirror https://mcuboot.com/mcuboot/readme-zephyr.html. The source was not modified.

Slot 0 Configuration:

    Environment:
        - Zephyr SDK 0.10.0 and Zephyr OS v1.14.00

    prj.conf:
        CONFIG_LOG=y
        CONFIG_LOG_OVERRIDE_LEVEL=4
        CONFIG_STDOUT_CONSOLE=y

        CONFIG_USB=y
        CONFIG_USB_DEVICE_STACK=y
        CONFIG_USB_DFU_CLASS=y

        CONFIG_BOOTLOADER_MCUBOOT=y
        CONFIG_IMG_MANAGER=y
        CONFIG_MCUBOOT_IMG_MANAGER=y

        CONFIG_USB_DEVICE_VID=0x167f
        CONFIG_USB_DEVICE_PID=0x3001
        CONFIG_USB_DEVICE_MANUFACTURER="Company"
        CONFIG_USB_DEVICE_PRODUCT="Product"
        CONFIG_USB_DEVICE_SN="123abc"

    source:
        #include <zephyr.h>
        #include <misc/printk.h>

        void main(void)
        {
            printk("Hello World!\n");
        }

    Build steps
        • source zephyr/zephyr/zephyr-env.sh
        • mkdir -p build/nrf52840_pca10056 && cd build/nrf52840_pca10056
        • cmake -GNinja -DBOARD=nrf52840_pca10056 -Dapp_VERSION_BUILD=9999 ../..
        • ninja
        • ~/repos/mcuboot/scripts/imgtool.py sign --key ~/repos/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 8 --version 1.2 -S 0x69000 ./zephyr/zephyr.hex signed-hello.hex
        • nrfjprog --family NRF52 --program signed-hello.hex --sectorerase

Procedure for uploading new firmware:

    • The nrf USB cable was connected first followed by the segger USB cable. A reset via the button on the board directly preceded the logs below. The full log is attached.

            ***** Booting Zephyr OS zephyr-v1.13.0 *****
            ***** Booting Zephyr OS zephyr-v1.14.0 *****
            Hello World!
            [00:00:00.005,035] <dbg> usb_descriptor.ascii7_to_utf16le: char g : 67, idx 3 -> 7
            --- 66 messages dropped ---
            [00:00:00.005,096] <dbg> usb_descriptor.ascii7_to_utf16le: char i : 69, idx 0 -> 1
            [00:00:00.005,126] <dbg> usb_descriptor.ascii7_to_utf16le: idx_max 13, ascii_idx_max 6, buf 2000362f
            [00:00:00.005,157] <dbg> usb_descriptor.ascii7_to_utf16le: char 0 : 30, idx 6 -> 13
            [00:00:00.005,157] <dbg> usb_descriptor.ascii7_to_utf16le: char - : 2d, idx 5 -> 11
            [00:00:00.005,187] <dbg> usb_descriptor.ascii7_to_utf16le: char e : 65, idx 4 -> 9
            [00:00:00.005,218] <dbg> usb_descriptor.ascii7_to_utf16le: char g : 67, idx 3 -> 7
            [00:00:00.005,218] <dbg> usb_descriptor.ascii7_to_utf16le: char a : 61, idx 2 -> 5
            [00:00:00.005,249] <dbg> usb_descriptor.ascii7_to_utf16le: char m : 6d, idx 1 -> 3
            [00:00:00.005,279] <dbg> usb_descriptor.ascii7_to_utf16le: char i : 69, idx 0 -> 1
            [00:00:00.005,493] <dbg> usb_nrfx.usbd_work_process_pwr_events: USB detected
            ...

    • ~/repos/mcuboot/scripts/imgtool.py sign --key ~/repos/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 8 --version 1.2 -S 0x69000 ./zephyr/zephyr.bin signed-hello.bin
    • sudo dfu-util --alt 1 --download signed-hello.bin
           

Result:

    • dfu-util detects the monitor and attempts to download firmware but fails after a timeout.

            dfu-util 0.8

            Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
            Copyright 2010-2014 Tormod Volden and Stefan Schmidt
            This program is Free Software and has ABSOLUTELY NO WARRANTY
            Please report bugs to dfu-util@...

            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 167f:3001
            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

    • The nrf52840 shows a hardware exception (the full log is attached):

            [00:07:45.671,081] <dbg> usb_nrfx.usb_dc_ep_write: ep_write: ep 128, len 0
            [00:07:45.671,508] <dbg> usb_nrfx.usbd_work_process_setup: SETUP: r:3 rt:161 v:0 i:0 l:6
            [00:07:45.671,508] <dbg> usb_device.usb_handle_control_transfer: ep 0, status 0
            [00:07:45.671,508] <dbg> usb_nrfx.usb_dc_ep_read: ep_read: ep 0, maxlen 8
            [00:07:45.671,539] <dbg> usb_device.usb_handle_request: ** 1 **
            [00:07:45.671,569] <dbg> usb_dfu.dfu_class_handle_req: DFU_GETSTATUS: status 0, state 4
            [00:07:45.671,569] <dbg> usb_nrfx.usb_dc_ep_write: ep_write: ep 128, len 6
            [00:07:45.671,661] <dbg> usb_nrfx.usbd_event_transfer_ctrl: ctrl write complete
            ***** BUS FAULT *****
              Instruction bus error
            ***** Hardware exception *****
            Current thread ID = 0x20001824
            Faulting instruction address = 0x9f38018
            Fatal fault in thread 0x20001824! Aborting.
            07:45.670,654] <dbg> usb_nrfx.usbd_work_process_setup: SETUP: r:1 rt:33 v:0 i:0 l:64

    • dmesg shows nothing related to the crash. It does detect the USB device initial connect:

            [260966.516923] usb 1-2: new full-speed USB device number 55 using xhci_hcd
            [260966.669260] usb 1-2: New USB device found, idVendor=167f, idProduct=3001
            [260966.669265] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
            [260966.669269] usb 1-2: Product: Product
            [260966.669273] usb 1-2: Manufacturer: Company
            [260966.669276] usb 1-2: SerialNumber: 123abc

Attempted Mitigations:

    • Disabling logging in Zephyr did not affect the crash.
    • Attempting to re-run dfu-util did not succeed:
   
        dfu-util 0.8

        Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
        Copyright 2010-2014 Tormod Volden and Stefan Schmidt
        This program is Free Software and has ABSOLUTELY NO WARRANTY
        Please report bugs to dfu-util@...

        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 167f:3001
        Run-time device DFU version 0110
        Claiming USB DFU Interface...
        Setting Alternate Setting #1 ...
        dfu-util: Cannot set alternate interface


Is DFU supported on the nrf52840 with Zephyr 1.14? Any supporting documentation would be appreciated.

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