DFU OTA - What is the right set of tools?

Hello folks,

I am working to implement a system for OTA DFU on the board Xiao BLE Sense, which I am validating first on an nRF52840-sdk.

The end goal of this project is a wearable device that will get occasional DFU updates to reflect new software features.

I've loaded up the examples on smp_svr, central_smp_client, and I've been experimenting with development on the nRF Desktop application, which documentation says has support for DFU.

I made two parallel versions of nrfDesktop with marginal (version number) changes. I loaded an application.zip of the "newer" version onto my (Android) phone, and tried to run a dfu via the Device Manager App > Image Tab > Firmware Upgrade > Select File process. I couldn't initiate the dfu process because DeviceManager claimed that the connected device wasn't running MCUBoot.

I can tell that I'm missing something, and I'd be grateful for guidance.

Right now, I'm trying to follow this example: ( nRF5 SDK v17.1.0 Secure DFU Hands-on Tutorial), but I'm stuck fairly early on trying to install micro-ecc.

My first concern is that in this tutorial, in step 5 (install ecc), is that infocenter displays a warning ("The current document displayed does not exist in the table of contents."). It makes me think that this procedure is somehow deprecated. Is this the case?

My second concern is that on the ecc download page (https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Flib_crypto_backend_micro_ecc.html&cp=8_1_3_11_16_2_2&anchor=lib_crypto_backend_micro_ecc_install), in step 4, the instructions specify to run a build_all.bat, which does not exist in their linked GitHub repository (https://github.com/kmackay/micro-ecc).

My questions in summary are:

What is the right set of tools to build DFU for my use case?

What is the right place to go and read about those tools?

Are there examples that I should refer to that use those tools?

Thank you for any advice you can provide, and happy new year.

Best,

    - Finn

Parents
  • Hi Finn, 

    First off, could you let us know which SDK you are using ? 


    You mentioned smp_svr, central_smp_client which is the method for DFU in nRF Connect SDK but you were also pointing to NRF5 SDK v17.1.0

    Please be noted that MCUBoot is used in nRF Connect SDK , not nRF5 SDK 

     For nRF 5 SDK DFU you should use nRF Device Firmware Update app (nRF DFU) not the nRF Device Manager app. 
    Note: the build_all.bat is in nRF5 SDK external\micro-ecc\ folder, not in the github repo. 


  • Hi, and thank you very much.

    My system right now is:

    nRF Connect SDK Toolchain v2.5.0

    I'm building that for the nRF52840-DK

    Thank you for pointing out that the secure DFU was from nRF5 SDK v17.1.0, that helps explain some of the disconnect I was experiencing.

    --------------------------------------------------------------

    I would like to use MCUBoot on this system.

    I would like to build my system off of the nRF Desktop (2.5.0) application framework.

    Two specific questions there are:

    1. How can I switch from the B0 (secure) bootloader to MCUBoot?

    2. How can I increment my version with trivial changes to validate correctly upgrading firmware from "Test 1" to "Test 2"

    ---------------------------------------------------------------

    Right now, I am simply creating 2 versions of the prj.conf.

    I flash a build with FW 1 to my DevKit

    CONFIG_FW_INFO_FIRMWARE_VERSION=1

    Then I update and make a new build with
    CONFIG_FW_INFO_FIRMWARE_VERSION=2

    I save the dfu_application.zip to my phone, and try to upload with the DFU application, but I get all X's on the progress screen of the app.

    Final line indicates

    Error: Invalid or too large file.

    --------------------------------------------------------------------

    What example should I refer to for a DFU procedure using MCUBoot that works with SDK v2.5.0?

    Thank you,

        - Finn

  • And I'll update the posting because I've found something useful.

    I'm trying to update smp_svr example using the dfu application.

    I know that for downgrade prevention, the firmwares need monotonically increasing version numbers.

    I've found quite a few different version settings in the nRF Kconfig GUI.

    The two I believe are most relevant to a valid firmware update are:

    Nordic nRF Connect / "Version number of the firmware" (blank by default)

    MCUboot bootloader support / "Version to pass to imgtool when signing" (default 0.0.0+0)

    Would be grateful for pointer to correct options / reading about correct options.

  • I will also add that I have now tried the following two consecutive prj.confs that failed in the same way on the DFU app. (Error: invalid or too large file)

    This is flashed to the device (only change: CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="0.0.0")

    # Enable MCUmgr and dependencies.
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    CONFIG_MCUMGR=y
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
    CONFIG_MAIN_STACK_SIZE=2048
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Enable flash operations.
    CONFIG_FLASH=y
    
    # Required by the `taskstat` command.
    CONFIG_THREAD_MONITOR=y
    
    # Support for taskstat command
    CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_STAT=y
    
    # Enable logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
    
    # Disable debug logging
    CONFIG_LOG_MAX_LEVEL=3
    
    CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=n
    CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="0.0.0"

    This is the config for the program that is in dfu_application.zip (only change: CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="0.0.1")

    # Enable MCUmgr and dependencies.
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    CONFIG_MCUMGR=y
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
    CONFIG_MAIN_STACK_SIZE=2048
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Enable flash operations.
    CONFIG_FLASH=y
    
    # Required by the `taskstat` command.
    CONFIG_THREAD_MONITOR=y
    
    # Support for taskstat command
    CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_STAT=y
    
    # Enable logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
    
    # Disable debug logging
    CONFIG_LOG_MAX_LEVEL=3
    
    CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=n
    CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="0.0.1"

  • Hi Finn,

    Could you let me know which app did you use for testing ? 
    Please try to test updating to a very simple application, for example peripheral_lbs. 

    My suggestion is to get started with only the MCUBoot not with the B0. You can add the B0 later as it's not needed for application's FOTA. 

    I assume you were following the guide here ? https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/device_guides/working_with_nrf/nrf52/developing.html#fota-updates

    I don't think you would need to increase the CONFIG_FW_INFO_FIRMWARE_VERSION for testing, as long as you don't downgrade the number, it should be OK. You can try by simply change the advertising name for example. 


    If you still see an error when testing with peripheral_lbs (by adding CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU =y to it) please send us the log/screenshot on the phone app. 

  • Hi Hung,

    ----------------------------------------------------------

    UPDATE: SUCCESS!

    Using the Device Manager app instead of nRF DFU solved it.

    Bluetooth connect to my device > image tab at bottom > dfu_application.zip > Start > Successful update

    --------------------------- Here is what I attempted to get to this answer ------------------------------

    The app that I am using is as you specified: nRF Device Firmware Update app (nRF DFU).

    To install this (Android) I downloaded the nRF Toolbox app (v3.2.6), and from there the toolbox links to "Device Firmware Update -- Open DFU Application." This opens the app "nRF Device Firmware Update."

    I looked for a different version of nRF DFU on Google Play, but what I found is the same app as the Toolbox installed.

    I am using "nRF Device Firmware Update" app.

    -------------------------------------------------------------------------------------------------------------------------------

    For testing, I am building two versions of peripheral_lbs.

    I have the following two configs for those projects:

    Version 1: "OLDNAME"

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS_OLDNAME"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

    Version 2: "NEW NAME"

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS_NEW_NAME"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    

    --------------------------------------------------------------------------------------------

    Here are the steps I am following (with screenshots of key steps).

    1. I pristine build Version 1.

    2. I erase and Flash Version 1 onto my Dev Kit

    3. I pristine build Version 2.

    4. I take the output file "dfu_application.zip" and transfer it to my phone

    5. On my phone, I open the app nRF Device Firmware Update

    6. Select File

    7. Select Device

    8. Click "Start"

    Log from nRF Logger:

    ------------------------------------------------------------------------

    Also, yes, I am following the link you sent (fota-update), but I'd like to point out a discrepancy between your advice and that tutorial. You mention that I should be using the nRF Connect DFU mobile app, but the instructions specifically call out using the nRF Connect Device Manager mobile app.

    --------------------------------------------------------------------------

    Thank you

        -  Finn

Reply
  • Hi Hung,

    ----------------------------------------------------------

    UPDATE: SUCCESS!

    Using the Device Manager app instead of nRF DFU solved it.

    Bluetooth connect to my device > image tab at bottom > dfu_application.zip > Start > Successful update

    --------------------------- Here is what I attempted to get to this answer ------------------------------

    The app that I am using is as you specified: nRF Device Firmware Update app (nRF DFU).

    To install this (Android) I downloaded the nRF Toolbox app (v3.2.6), and from there the toolbox links to "Device Firmware Update -- Open DFU Application." This opens the app "nRF Device Firmware Update."

    I looked for a different version of nRF DFU on Google Play, but what I found is the same app as the Toolbox installed.

    I am using "nRF Device Firmware Update" app.

    -------------------------------------------------------------------------------------------------------------------------------

    For testing, I am building two versions of peripheral_lbs.

    I have the following two configs for those projects:

    Version 1: "OLDNAME"

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS_OLDNAME"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

    Version 2: "NEW NAME"

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS_NEW_NAME"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    

    --------------------------------------------------------------------------------------------

    Here are the steps I am following (with screenshots of key steps).

    1. I pristine build Version 1.

    2. I erase and Flash Version 1 onto my Dev Kit

    3. I pristine build Version 2.

    4. I take the output file "dfu_application.zip" and transfer it to my phone

    5. On my phone, I open the app nRF Device Firmware Update

    6. Select File

    7. Select Device

    8. Click "Start"

    Log from nRF Logger:

    ------------------------------------------------------------------------

    Also, yes, I am following the link you sent (fota-update), but I'd like to point out a discrepancy between your advice and that tutorial. You mention that I should be using the nRF Connect DFU mobile app, but the instructions specifically call out using the nRF Connect Device Manager mobile app.

    --------------------------------------------------------------------------

    Thank you

        -  Finn

Children
  • Hi Finn, 

    I'm glad that you got it work now. The nRF Connect DFU mobile app is like a Swiss Army knife it can do everything, including DFU update for both nRF5 SDK bootloader and NCS bootloader. I was suggesting the app because it was more versatile. But it's better to use the app dedicated for DFU as the source code is available and you have more option to configure the DFU update. 

    Please let us know if you have further question, or create a new ticket if you have a new issue. 

Related