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

ot-nrf52840 dfu trigger library

I'm working with following project and would like to add the DFU trigger library.

https://github.com/openthread/ot-nrf528xx

1. Build like this, I'm using a PCA10059 Dongle

./script/build nrf52840 USB_trans -DOT_BOOTLOADER=USB

2. I create the hex File

arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex

3. I generate .Zip file for nrfutil

nrfutil pkg generate --debug-mode --hw-version 52 --sd-req 0x00 --application ot-cli-ftd.hex app_dfu_package.zip

4. I must press the reset button to get into Bootloader mode and load the Firmware.

nrfutil dfu usb-serial -pkg app_dfu_package.zip -p COM8

ERROR:

C:\Users\..Desktop\Nrfutil-Trigger-Test>nrfutil dfu usb-serial -pkg app_dfu_package.zip -p COM8
[------------------------------------] 0%2021-07-12 16:15:37,334 No trigger interface found for device with serial number: CFXXXXXXXX, Product ID: 0xCAFE and Vendor ID: 0x1915

How can I implement the DFU-Trigger library and how can I trigger it with nrfutil?

Output of ./script/build :

vscode ➜ /workspaces/ot-nrf528xx (main ✗) $ ./script/build nrf52840 USB_trans -DOT_BOOTLOADER=USB
+ OT_CMAKE_NINJA_TARGET=
+ NRF_PLATFORMS=(nrf52811 nrf52833 nrf52840)
+ readonly NRF_PLATFORMS
+ NRF_BUILD_TYPES=(UART_trans USB_trans SPI_trans_NCP soft_crypto soft_crypto_threading)
+ readonly NRF_BUILD_TYPES
++ pwd
+ readonly OT_SRCDIR=/workspaces/ot-nrf528xx
+ OT_SRCDIR=/workspaces/ot-nrf528xx
+ OT_OPTIONS=("-DCMAKE_BUILD_TYPE=MinSizeRel" "-DOT_PLATFORM=external" "-DOT_SLAAC=ON")
+ readonly OT_OPTIONS
+ main nrf52840 USB_trans -DOT_BOOTLOADER=USB
+ [[ 3 == 0 ]]
+ local platform=nrf52840
+ echo nrf52811 nrf52833 nrf52840
+ grep -wq nrf52840
+ [[ 3 == 1 ]]
+ local nrf_build_type=USB_trans
+ echo UART_trans USB_trans SPI_trans_NCP soft_crypto soft_crypto_threading
+ grep -wq USB_trans
+ shift
+ shift
+ local_options=()
+ local local_options
+ options=("${OT_OPTIONS[@]}")
+ local options
+ case "${platform}" in
+ local_options+=("-DCMAKE_TOOLCHAIN_FILE=src/${platform}/arm-none-eabi.cmake")
+ case "${nrf_build_type}" in
+ options+=("${local_options[@]}" "-DOT_USB=ON" "-DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls")
+ options+=("$@")
+ build -DNRF_PLATFORM=nrf52840 -DCMAKE_BUILD_TYPE=MinSizeRel -DOT_PLATFORM=external -DOT_SLAAC=ON -DCMAKE_TOOLCHAIN_FILE=src/nrf52840/arm-none-eabi.cmake -DOT_USB=ON -DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls -DOT_BOOTLOADER=USB
+ local builddir=build
+ mkdir -p build
+ cd build
+ cmake -GNinja -DOT_COMPILE_WARNING_AS_ERROR=ON -DNRF_PLATFORM=nrf52840 -DCMAKE_BUILD_TYPE=MinSizeRel -DOT_PLATFORM=external -DOT_SLAAC=ON -DCMAKE_TOOLCHAIN_FILE=src/nrf52840/arm-none-eabi.cmake -DOT_USB=ON -DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls -DOT_BOOTLOADER=USB /workspaces/ot-nrf528xx
-- OpenThread Source Directory: /workspaces/ot-nrf528xx/openthread
-- OpenThread CMake build type: MinSizeRel
-- Package Name: OPENTHREAD
-- Setting default package version: thread-reference-20200818-1060-g681214da9
-- Package Version: thread-reference-20200818-1060-g681214da9
-- Configuring done
-- Generating done
-- Build files have been written to: /workspaces/ot-nrf528xx/build
+ [[ -n '' ]]
+ ninja
[29/113] cd /workspaces/ot-nrf528xx/build/openthread && /usr/bin/cmake -DLIST="OPENTHREAD_CONFIG_ASSER...eck.h";MBEDTLS_CONFIG_FILE="nrf-config.h"" -P /workspaces/ot-nrf528xx/openthread/etc/cmake/print.cmak
OPENTHREAD_CONFIG_ASSERT_ENABLE=1
OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=0
OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=0
OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0
OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=1
OPENTHREAD_CONFIG_PING_SENDER_ENABLE=1
OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1
OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=0
PACKAGE_NAME=OPENTHREAD
PACKAGE_VERSION=thread-reference-20200818-1060-g681214da9
OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_2
OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1
OPENTHREAD_CONFIG_FILE=openthread-core-nrf52840-config.h
OPENTHREAD_PROJECT_CORE_CONFIG_FILE=openthread-core-nrf52840-config.h
OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=openthread-core-nrf52840-config-check.h
MBEDTLS_USER_CONFIG_FILE=nrf52840-mbedtls-config.h
USB_CDC_AS_SERIAL_TRANSPORT=1
APP_USBD_NRF_DFU_TRIGGER_ENABLED=1
OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=openthread-core-nrf52840-config-check.h
MBEDTLS_CONFIG_FILE=nrf-config.h
[113/113] Linking CXX executable bin/ot-ncp-ftd
+ cd /workspaces/ot-nrf528xx

  • Hi Uyl,

    Did you see the red led blink?

    Best regards,

    Charlie

  • It's is only blinking when you enter the bootloader mode.

    I've changed following things:

    ./script/build nrf52840 USB_trans -DOT_BOOTLOADER=USB -DOT_APP_CLI=ON -DOT_MTD=ON

    and the config files:

    ## app_config.h ##

        #ifndef APP_USBD_PID
        #define APP_USBD_PID 0x0C00A
        endif

        #ifndef APP_USBD_NRF_DFU_TRIGGER_ENABLED
        #define APP_USBD_NRF_DFU_TRIGGER_ENABLED 1
        #endif

    ## nrf52840/sdk_config.h ##

        #ifndef APP_USBD_ENABLED
        #define APP_USBD_ENABLED 1
        #endif

        #ifndef APP_USBD_CONFIG_SELF_POWERED
        #define APP_USBD_CONFIG_SELF_POWERED 0
        #endif

        #ifndef APP_USBD_CDC_ACM_ENABLED
        #define APP_USBD_CDC_ACM_ENABLED 1
        #endif

        #ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED
        #define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 1
        #endif

    Now the devices appears as "  nRF Connect USB CDC ACM (COM11) " and I can trigger the Reset with the NRF-Connect Programmer.

    But it still doesn't work with nrfutil, do you know the command?

  • Hi Uyl,

    This is already a Nordic Open bootloader preprogrammed into nRF52840 Dongle. You only need to trigger DFU mode manually. Plug in nRF52840 Dongle and press reset button to trigger the DFU mode, you will see the red LED start to blink. 

    I repeat your procedure without changing any codes and it worked well. It is on Ubuntu system but should be the same with Windows.

    cd ot-nrf528xx
    ./script/build nrf52840 USB_trans -DOT_BOOTLOADER=USB
    arm-none-eabi-objcopy -O ihex build/bin/ot-cli-ftd ot-cli-ftd.hex
    nrfutil pkg generate --debug-mode --hw-version 52 --sd-req 0x00 --application ot-cli-ftd.hex app_dfu_package.zip
    sudo nrfutil dfu usb-serial -pkg app_dfu_package.zip -p /dev/ttyACM0
    [####################################]  100%          
    Device programmed.
    Could you confirm the way you trigger DFU mode is the same as I mentioned?

    Best regards,

    Charlile

  • Hello Charlie

    I know the procedure with the reset button.

    But I'm going to have a Thread network with 100 devices  for Testing and i dont want to press the rest button 100 times Slight smile.

    I want to be able to Flash firmware updates without pressing the RESET button.  I can enter the Bootloader mode without pressing the RESET button. But it doesn't work with NRFutil only with NRF-Connect programmer .

    This appears and when i press it, it changes to sDFU. This is all good but how can i trigger it with NRFutil?

  • Hi Uyl,

    Sorry, I do not fully understand your meaning before.

    I did the following changes and it does work with nrfutil, but the issue is that you have to program this package first, then you would be able to use USB DFU buttonless triggering next time.

    ## src\nrf52833\transport-config.h ##
    define USB_CDC_AS_SERIAL_TRANSPORT 1

    ## third_party\NordicSemiconductor\config\app_config.h ##
    define APP_USBD_PID 0xC00A
    define APP_USBD_NRF_DFU_TRIGGER_ENABLED 1
    Your configuration should also work. The nrfutil command is the same as before:
    sudo nrfutil dfu usb-serial -pkg app_dfu_package.zip -p /dev/ttyACM0
    [####################################]  100%          
    Device programmed.
    I also experience error reports like below. Just try to wait a bit longer to program again. I guess sometimes it takes longer time to trigger DFU, but the nrfutil is timeout. Use "ls /dev/ttyACM*" to check you are always using the correct serial port.
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu_transport_serial.py", line 197, in open
        self.__ensure_bootloader()
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu_transport_serial.py", line 326, in __ensure_bootloader
        trigger.enter_bootloader_mode(device)
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu_trigger.py", line 171, in enter_bootloader_mode
        libusb_device = self.select_device(listed_device)
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu_trigger.py", line 134, in select_device
        SNO = handle.getSerialNumber()
      File "/usr/local/lib/python3.8/dist-packages/usb1/__init__.py", line 1154, in getSerialNumber
        return self.getASCIIStringDescriptor(
      File "/usr/local/lib/python3.8/dist-packages/usb1/__init__.py", line 1307, in getASCIIStringDescriptor
        received = mayRaiseUSBError(libusb1.libusb_get_string_descriptor_ascii(
      File "/usr/local/lib/python3.8/dist-packages/usb1/__init__.py", line 127, in mayRaiseUSBError
        __raiseUSBError(value)
      File "/usr/local/lib/python3.8/dist-packages/usb1/__init__.py", line 119, in raiseUSBError
        raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)
    usb1.USBErrorTimeout: LIBUSB_ERROR_TIMEOUT [-7]
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/bin/nrfutil", line 8, in <module>
        sys.exit(cli())
      File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
        rv = self.invoke(ctx)
      File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/__main__.py", line 1014, in usb_serial
        do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, False,
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/__main__.py", line 970, in do_serial
        dfu.dfu_send_images()
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu.py", line 88, in _dfu_send_image
        self.dfu_transport.open()
      File "/usr/local/lib/python3.8/dist-packages/nordicsemi/dfu/dfu_transport_serial.py", line 203, in open
        ". Reason: {1}".format(self.com_port, e.strerror))
    AttributeError: 'USBErrorTimeout' object has no attribute 'strerror'
    

    Best regards,

    Charlie

Related