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.
If you are working with Bluetooth LE, Thread, Zigbee, or Matter samples, the network core sample is built as a child image when you build the application core image (see Multi-image builds on the nRF5340 DK using child and parent images above).
Complete the following steps to build and program a multi-image build to the nRF5340 application core and network core:
Open the nRF Connect for VS Code extension.
Complete the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation.
Program the sample or application
Complete the following steps to program the sample or application onto nRF5340 DK:
Connect the nRF5340 development kit to your PC using a USB cable.
Make sure that the nRF5340 DK and the external debug probe are powered on.
Click Build in the Actions View to start the build process.
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:
Start the toolchain environment in a terminal window.
Run the following command to erase the flash memory of the network core and program the network sample:
west flash --erase
Navigate to the build folder of the application sample and run the same command to erase the flash memory of the application core and program the application sample:
west flash --erase
Start the toolchain environment in a terminal window.
Run the following command to erase the flash memory of the network core and program the network sample:
nrfutil device program --firmware zephyr.hex --options chip_erase_mode=ERASE_ALL --core Network
Note
If you cannot locate the build folder of the network sample, look for a folder with one of these names inside the build folder of the application sample:
rpc_host
hci_rpsmg
802154_rpmsg
multiprotocol_rpmsg
Navigate to the build folder of the application sample and run the following command to erase the flash memory of the application core and program the application sample:
nrfutil device program --firmware zephyr.hex --options chip_erase_mode=ERASE_ALL
Note
The application build folder will be in a sub-directory which is the name of the folder of the application
Reset the development kit:
nrfutil device reset --reset-kind=RESET_PIN
See Programming with --recover if you encounter an error.
To build and program a sysbuild HEX file, follow the instructions in Programming an application for the application core sample.
To program the multi-image HEX file, you can use west or nRF Util.
Enter the following command to program multi-image builds for different cores:
west flash
Note
The minimum supported version of nrfjprog for multi-image builds for different cores is 10.21.0.
Enter the following commands to program multiple image builds for different cores:
nrfutil device program --firmware merged_CPUNET.hex --options verify=VERIFY_READ,chip_erase_mode=ERASE_CTRL_AP
nrfutil device program --firmware merged.hex --options verify=VERIFY_READ,chip_erase_mode=ERASE_CTRL_AP
Note
The --verify
command confirms that the writing operation has succeeded.
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 |
|
nRF5340 SoC - Network core |
|
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
andmerged_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 indfu_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:
Open the nRF Connect for VS Code extension.
Complete the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation.
Program the sample or application:
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.
Connect the external debug probe to the PC using a USB cable.
Make sure that the Thingy:53 and the external debug probe are powered on.
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:
Start the toolchain environment in a terminal window.
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.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.Get the rest of the dependencies using west:
west update
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
orthingy53/nrf5340/cpuapp/ns
when building samples for the application core. The proper child image forthingy53/nrf5340/cpunet
will be built automatically. See Board targets for details.Program the sample or application:
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.
Connect the external debug probe to the PC using a USB cable.
Make sure that the Nordic Thingy:53 and the external debug probe are powered on.
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.