Flash the device

Asset Tracker Template

tags
Asset Tracker Template

Expand the section that matches your hardware setup.

Thingy:91 X (with debugger) or nRF9151 DK

With an external J-Link debugger attached to the Thingy:91 X, flash with the following command:

west flash --erase

The --erase option performs a full chip erase, including UICR, before programming. Without it, west flash fails with a UICR-related error when the new firmware writes different UICR contents.

By default, west flash after a sysbuild programs each bootloader and application image separately. That is equivalent to programming build/merged.hex, which combines the same images into one file. To generate the merged image and flash it in a single step, for example after changing the partition layout, use the following commands:

west ncs-mergehex --no-rebuild
west flash --erase --skip-rebuild --hex-file build/merged.hex

west ncs-mergehex combines the per-board-target build/merged_*.hex files from the sysbuild into build/merged.hex, as listed in app/mergehex.yaml.

Release builds publish the same merged image as asset-tracker-template-{VERSION}-<board>-nrf91.hex, as described in Release artifacts.

Thingy:91 X (no debugger)

The Thingy:91 X does not have an on-board debugger. Flash over the serial bootloader using one of the following alternatives.

The first alternative, which Nordic Semiconductor recommends, is west thingy91x-dfu. It auto-discovers the device and flashes build/dfu_application.zip:

west thingy91x-dfu

The second alternative is nrfutil device program, which needs the Thingy:91 X serial number. To find the serial number, run nrfutil device list and locate the entry with Product: Thingy:91 X UART and the mcuBoot trait:

nrfutil device list
851006699
Product         J-Link
Traits          usb, jlink, seggerUsb

THINGY91X_ED0E7655C09       <-- this is the Thingy:91 X serial number
Product         Thingy:91 X UART
Ports           /dev/tty.usbmodem142102, vcom: 0
                /dev/tty.usbmodem142105, vcom: 1
Traits          mcuBoot, modem, serialPorts, nordicUsb, usb

Then flash, replacing <serial-number> with the identifier from the previous command (for example THINGY91X_ED0E7655C09):

nrfutil device program --firmware build/dfu_application.zip \
    --serial-number <serial-number> --traits mcuboot \
    --x-family nrf91 --core Application

To reset the Thingy:91 X from the terminal without re-flashing, which is equivalent to pressing the reset button, run the following command:

west thingy91x-reset

The application is now built and flashed to the device. Open a serial terminal at 115200 baud to view the logs. Nordic Semiconductor recommends the Serial Terminal app, which is part of nRF Connect for Desktop. PuTTY, Tera Term, and minicom also work.

As the next step, continue to Connecting to onboard and provision the device on nRF Cloud.