Thingy:91 Firmware Update using MCUboot

Thingy:91 Firmware Update using MCUboot

The nRF Connect Programmer application now also supports MCUboot! Follow these steps to update through the programmer application or the following guide for the command line alternative. 

This guide shows you how to update your Nordic Thingy:91 application FW without having to use an external JLink programmer but instead using the Thingy:91 built-in MCUboot serial recovery mode using the mcumgr command line tool. 

Nordic Thingy:91 ships with the asset tracker application running on the nRF9160 SiP and the usb_uart_bridge running on the nRF52840 SoC.

The following steps can also be used to compile and update to all the other nRF9160 and nRF52840 compatible applications found in nRF Connect SDK.

Prerequisites

  1. Download, install and make sure Go Language (1.7 or later) is in your system path.
  2. Install mcumgr command line tool by issuing the following go get command:
go get github.com/apache/mynewt-mcumgr-cli/mcumgr
  1. If compiling the code: Follow the nRF Connect SDK getting started guide to set up your system to be able to compile a compatible update binary.

Getting the FW

To get hold of the FW update binaries you could either download the FW package with pre-compiled binaries or compile your own. Pick one of the following methods.

Download pre-compiled binaries

Download and unzip the Thingy:91 FW package found under the download tab on the Thingy:91 product page. Make sure to download v0.2.3 or later.

The MCUboot compatible binary files we will use in the next steps are located here: thingy91fwvXXX\images_dfu\

thingy91_at_client_v0.2.3.bin           Firmware for direct modem communication
thingy91_ltem_v0.2.2.bin                Asset tracker firmware for nRF9160, LTE-M network mode
thingy91_nbiot_legacy_pco_v0.2.2.bin    Asset tracker firmware for nRF9160, NB-IoT network mode, legacy PCO
thingy91_nbiot_v0.2.2.bin               Asset tracker firmware for nRF9160, NB-IoT network mode

Compiling the source code

There are two compile targets of interest for Thingy:91 in nRF Connect SDK; nrf9160_pca20035ns should be used when compiling the application code for the nRF9160 SiP and nrf52840_pca20035 should be used when compiling the code for the on-board nRF52840 SoC.

Go into the desired application folder. In this case compiling the asset tracker application for the nrf9160_pca20035ns target.

cd ncs\nrf\applications\asset_tracker

Make sure you have the latest version of NCS master by pulling the nrf repository by running git pull, then run west update to get the rest of the dependencies. Also make sure that CONFIG_BOOTLOADER_MCUBOOT=y is added to the project configuration file to enable compilation of the appropriate binaries.

Compile the code using west:

west build -b nrf9160_pca20035ns

The MCUboot compatible binary file we will use in the next steps is located here: build\zephyr\app_update.bin

Updating FW

Before trying to update your Thingy:91 FW make sure its connected to your computer using USB.

  1. Put your Thingy:91 into application serial recovery mode either by pushing the main button (SW3) while turning on power to update the nRF9160 SiP or the small button (SW4) while turning on power to update the nRF52840 SoC.
  2. Then update the FW by using the below mcumgr image upload command:

In the below commands change <image> to the desired binary file from the above “Getting the FW” steps and change <serial port> to the serial port the Thingy:91 is assigned when connected to your system. Format for <serial port> should be e.g. COM1 for Windows and something like /dev/ttyACM0 for Linux based systems.

mcumgr --conntype=serial --connstring=<serial port> image upload <image>
  1. Then start the application by running a reset:
mcumgr --conntype=serial --connstring=<serial port> reset
Anonymous
  • While running 

    west build -b nrf9160_pca20035ns

    I am getting :

     ERROR: Build directory C:\Users\parva\ncs\v1.3.1\nrf\applications\asset_tracker\build targets board thingy91_nrf9160ns, but board nrf9160_pca20035ns was specified. (Clean the directory, use --pristine, or use --build-dir to specify a different one.)
    FATAL ERROR: refusing to proceed without --force due to the above error

    so, I changed the board name to thingy91_nrf9160ns and then I was getting this error:

    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' '-BC:\Users\parva\ncs\v1.3.1\nrf\applications\asset_tracker\build' '-SC:\Users\parva\ncs\v1.3.1\nrf\applications\asset_tracker' -GNinja

    What to do about it?

  • Does the same command apply to modem firmware dfu?

    My target is running mfw_nrf9160_1.2.0 and I tried providing mfw_nrf9160_update_from_1.2.0_to_1.2.0-FOTA-TEST.bin as the <image>.  It always fail with error 3.

  • Make sure that CONFIG_BOOTLOADER_MCUBOOT=y is added to the project configuration file then compile and it should appear an app_update.bin file in the current build folder under zephyr.

  • On master branch or newer tag versions of NCS,  "app_update.bin" will be generated instead of "update.bin".  

  • Hi, it depends on how are you trying to build the SW.

    1. If you build using the command line (power shell in Windows 10) using

    "west build -b nrf9160_pca20035ns" in "cd ncs\nrf\applications\asset_tracker"
    you can see "app_update.bin" under the "build\zephyr\app_update.bin", if your build success.

    If your build was failed, delete the previous build folder in "applications\asset_tracker" and build one more time.


    2. If you are trying to build using SEGGER Embedded Studio, you can see under

    C:\ncs\nrf\applications\asset_tracker\build_nrf9160_pca20035ns\zephyr\app_update.bin"