Building and programming with nRF53 Series

Building and programming with nRF53 Series application for the nRF53 Series devices follows the processes described in the following sections.

Building and programming with nRF5340 DK

Depending on the sample, you must program only the application core (for example, when using NFC samples) or both the network and the application core.

The steps differ depending on whether you work with Visual Studio Code or on the command line and whether you are doing a single or multi-image build.

Using Visual Studio Code

You can build and program separate images or combined images using the nRF Connect for VS Code extension.

To build and program the application core, follow the instructions in How to build an application and use nrf5340dk/nrf5340/cpuapp or nrf5340dk/nrf5340/cpuapp/ns as the board target.

To build and program the network core, follow the instructions in How to build an application and use nrf5340dk/nrf5340/cpunet as the board target.

Program the sample or application

Complete the following steps to program the sample or application onto Thingy:91:

  1. Connect the nRF5340 development kit to your PC using a USB cable.

  2. Make sure that the nRF5340 DK and the external debug probe are powered on.

  3. Click Build in the Actions View to start the build process.

  4. Click Flash in the Actions View to program the resulting image to your device.

Using the command line

To build nRF5340 samples from the command line, use west. To program the nRF5340 DK from the command line, use either west (which uses nrfjprog that is part of the nRF Command Line Tools) or nRF Util.

Note

Programming the nRF5340 DK from the command line with west requires the nRF Command Line Tools v10.12.0 or later.

To build and program the application sample and the network sample as separate images, follow the instructions in Programming an application for each of the samples.

See the following instructions for programming the images separately:

  1. Open a command prompt in the build folder of the network sample and enter the following command to erase the flash memory of the network core and program the network sample:

    west flash --erase
    
  2. Navigate to the build folder of the application sample and enter the same command to erase the flash memory of the application core and program the application sample:

    west flash --erase
    

See Readback protection if you encounter an error.

Readback protection

When programming the device, you might get an error similar to the following message:

ERROR: The operation attempted is unavailable due to readback protection in
ERROR: your device. Please use --recover to unlock the device.

This error occurs when readback protection is enabled. To disable the readback protection, you must recover your device. See the following instructions.

Use the --recover parameter with west flash, as described in Optional programming parameters.

Building and programming with Thingy:53

You can program the Nordic Thingy:53 by using the images obtained by building the code in the nRF Connect SDK environment.

To set up your system to be able to build a firmware image, follow the Installation guide for the nRF Connect SDK.

Board targets

The board targets of interest for Thingy:53 in the nRF Connect SDK are listed in the following table:

Component

Board target

nRF5340 SoC - Application core

thingy53/nrf5340/cpuapp for Cortex-M Security Extensions (CMSE) disabled

thingy53/nrf5340/cpuapp/ns for CMSE enabled

nRF5340 SoC - Network core

thingy53/nrf5340/cpunet

The nRF Connect SDK uses Multi-image builds using child and parent images for Thingy:53 by default. When you choose thingy53/nrf5340/cpuapp or thingy53/nrf5340/cpuapp/ns as the board target when building a sample or application, you will generate firmware for both the application core and network core:

  • The application core firmware consists of MCUboot bootloader and an application image.

  • The network core firmware consists of network core bootloader (B0n) and application firmware of the network core.

The build process generates firmware in two formats:

  • Intel Hex file (merged.hex and merged_CPUNET.hex) - Used with an external debug probe. These file contains bootloaders and applications for each core.

  • Binary files (zephyr.signed.bin), containing signed application firmwares for the application and network core, respectively. For convenience, the binary files are bundled in dfu_application.zip, together with a manifest that describes them. You can use the binary files or the combined zip archive to update application firmware for both cores, with either MCUboot serial recovery or OTA DFU using Bluetooth LE.

For more information about files generated as output of the build process, see Output build files (image files).

See the following sections for details regarding building and programming the firmware for Thingy:53 in various environments. See Updating firmware image for Thingy:53 for more detailed information about updating firmware on Thingy:53.

Building Wi-Fi applications on Thingy:53

You can use the Nordic Thingy:53 with the nRF7002 Expansion Board (EB) for Wi-Fi development. Connect the nRF7002 EB to the P9 connector on Thingy:53.

To build for the nRF7002 EB with Thingy:53, use the thingy53/nrf5340/cpuapp board target with the CMake SHIELD variable set to nrf7002eb. For example, you can use the following command when building on the command line:

west build -b thingy53/nrf5340/cpuapp -- -DSHIELD=nrf7002eb

For the compatible Wi-Fi samples in the nRF Connect SDK, see the Wi-Fi samples section.

Building and programming using Visual Studio Code

Complete the following steps to build and program using the nRF Connect for VS Code extension:

  1. Open the nRF Connect for VS Code extension.

  2. Complete the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation.

  1. Program the sample or application:

    1. Connect the Nordic Thingy:53 to the debug out port on a 10-pin external debug probe, for example nRF5340 DK, using a 10-pin JTAG cable.

    2. Connect the external debug probe to the PC using a USB cable.

    3. Make sure that the Thingy:53 and the external debug probe are powered on.

    4. Click Flash in the Actions View.

Building and programming on the command line

You must Set up the command-line build environment before you start building an nRF Connect SDK project on the command line.

To build and program the source code from the command line, complete the following steps:

  1. Open a command line or terminal window.

  2. Go to the specific directory for the sample or application.

    For example, the directory path is ncs/nrf/applications/machine_learning when building the source code for the nRF Machine Learning application.

  3. Make sure that you have the required version of the nRF Connect SDK repository by pulling the sdk-nrf repository on GitHub as described in Obtaining a copy of the nRF Connect SDK and Updating a copy of the nRF Connect SDK sections.

  4. Get the rest of the dependencies using west:

    west update
    
  5. Build the sample or application code as follows:

    west build -b board_target -d destination_directory_name

    The board target should be thingy53/nrf5340/cpuapp or thingy53/nrf5340/cpuapp/ns when building samples for the application core. The proper child image for thingy53/nrf5340/cpunet will be built automatically. See Board targets for details.

  6. Program the sample or application:

    1. Connect the Nordic Thingy:53 to the debug out port on a 10-pin external debug probe, for example nRF5340 DK, using a 10-pin JTAG cable.

    2. Connect the external debug probe to the PC using a USB cable.

    3. Make sure that the Nordic Thingy:53 and the external debug probe are powered on.

    4. Use the following command to program the sample or application to the device:

      west flash
      

    The device resets and runs the programmed sample or application.