Programming onto nRF91 Series devices
You can program applications and samples onto the nRF91 Series devices after Building an application the corresponding firmware images.
To program firmware onto nRF91 Series devices, follow the process described in the Programming an application section. Pay attention to the exceptions specific to the nRF91 Series, which are listed below.
Before you program a device in the nRF Connect for VS Code extension, you need to set up a build configuration, which is part of Building an application.
Complete the following steps to program the application:
Connect the development kit to your PC using a USB cable.
Power on the development kit.
Make sure to check the programming exceptions for the nRF91 Series in the sections below.
Open the nRF Connect extension in Visual Studio Code by clicking its icon in the Activity Bar.
In the extension’s Actions View, click on Flash.
For instructions about programming with the nRF Connect for VS Code extension, see How to flash an application.
If you want to program with custom options or scripts, read about Binding custom tasks to actions in the extension documentation.
For information about how to flash and erase in the nRF Connect for VS Code extension, read about the Application-specific flash options.
Complete the following steps to program the application:
Connect the development kit to your PC using a USB cable.
Power on the development kit.
Make sure to check the programming exceptions for the nRF91 Series in the sections below.
Start the toolchain environment in a terminal window.
Program the application to the kit using the following command:
west flash --erase
This command erases the full flash memory before programming, which is the recommended approach. If the application depends on other flash memory areas (for example, if it uses the Settings partition where bonding information is stored), erasing the full kit before programming ensures that these areas are updated with the new content. You can also program without erasing.
The west flash
command automatically resets the kit and starts the application.
For more information on programming using the command line, see Flashing in the Zephyr documentation.
Compatible versions of modem and application
When you update the application firmware on an nRF91 Series DK, make sure that the modem firmware and application firmware are compatible versions.
Selecting board controller on nRF9160 DK
When programming on the nRF9160 DK, make sure to set the SW10 switch (marked PROG/DEBUG) in the nRF91 position to program the nRF9160 application. In nRF9160 DK board revision v0.9.0 and earlier, the switch is called SW5.
Programming onto Thingy:91
You can also program the Thingy:91 with the images obtained by building the code in an nRF Connect SDK environment.
To set up your system to be able to build a compatible firmware image, follow the Installation guide for the nRF Connect SDK and read the Configuring and building documentation. The build targets of interest for Thingy:91 in nRF Connect SDK are as follows:
Component |
Build target |
---|---|
nRF9160 SiP |
|
nRF52840 SoC |
|
You must use the build target thingy91/nrf9160/ns
when building the application code for the nRF9160 SiP and the build target thingy91/nrf52840
when building the application code for the onboard nRF52840 SoC.
Note
In nRF Connect SDK releases before v1.3.0, these build targets were named
nrf9160_pca20035
,nrf9160_pca20035ns
, andnrf52840_pca20035
.In nRF Connect SDK releases ranging from v1.3.0 to v1.6.1, the build target
thingy91/nrf9160/ns
was namedthingy91_nrf9160ns
.
Note
LTE/GNSS features can only be used with Cortex-M Security Extensions enabled (_ns
build target).
The following table shows the different types of build files that are generated and the different scenarios in which they are used:
File |
File format |
Programming scenario |
---|---|---|
|
Full image, HEX format |
Using an external debug probe and nRF Connect Programmer. |
|
MCUboot compatible image, HEX format |
Using the built-in bootloader and nRF Connect Programmer. |
|
MCUboot compatible image, binary format |
|
For an overview of different types of build files in the nRF Connect SDK, see Output build files (image files).
There are multiple methods of programming a sample or application onto a Thingy:91. It is recommended to use an external debug probe to program the Thingy:91.
Note
If you do not have an external debug probe available to program the Thingy:91, you can directly program by using the USB (MCUboot) method and nRF Connect Programmer.
In this scenario, use the app_signed.hex
firmware image file.
Note
While building applications for Thingy:91, the build system changes the signing algorithm of MCUboot so that it uses the default RSA keys. This is to ensure backward compatibility with the MCUboot versions that precede the nRF Connect SDK v1.4.0. Use the default RSA keys only for development. In a final product, you must use your own, secret keys. See Using development keys for more information.
Complete the following steps to program firmware onto Thingy:91:
Set the Thingy:91 SWD selection switch (SW2) to nRF91 or nRF52 depending on whether you want to program the nRF9160 SiP or the nRF52840 SoC component.
Connect the Thingy:91 to the debug out port on a 10-pin external debug probe, for example, nRF9160 DK, using a 10-pin JTAG cable.
Note
If you are using nRF9160 DK as the debug probe, make sure that VDD_IO (SW11) is set to 1.8 V.
Connect the external debug probe to the PC using a USB cable.
Make sure that the Thingy:91 and the external debug probe are powered on.
In nRF Connect for VS Code extension, click the Flash option in the Actions View.
If you have multiple boards connected, you are prompted to pick a device at the top of the screen.
A small notification banner appears in the bottom-right corner of Visual Studio Code to display the progress and confirm when the flash is complete.
Start the toolchain environment in a terminal window.
Program the sample or application to the device using the following command:
west flash
The device resets and runs the programmed sample or application.
Programming onto Thingy:91 X
You can also program the Thingy:91 X with the images obtained by building the code in an nRF Connect SDK environment and the west tool.
To set up your system to be able to build a compatible firmware image, follow the Installation guide for the nRF Connect SDK and read the Configuring and building documentation. The build targets of interest for Thingy:91 X in the nRF Connect SDK are as follows:
Component |
Build target |
---|---|
nRF9151 SiP |
|
nRF5340 SoC - Application core |
|
nRF5340 SoC - Network core |
|
Note
LTE/GNSS features can only be used with Cortex-M Security Extensions enabled (nRF9151 ns
build target).
The following table shows the different types of build files that are generated and the different scenarios in which they are used:
File |
File format |
Programming scenario |
---|---|---|
|
Full image, HEX format |
Using an external debug probe and nrfutil device. |
|
MCUboot compatible image, HEX format |
Using the built-in bootloader and nrfutil device. |
|
MCUboot compatible image, binary format |
|
Complete the following steps to program firmware onto Thingy:91 X:
Set the Thingy:91 X SWD selection switch (SW2) to nRF91 or nRF53 depending on whether you want to program the nRF9151 SiP or the nRF5340 SoC component.
Connect the Thingy:91 X to the debug out port on a 10-pin external debug probe, for example, nRF9151 DK, using a 10-pin SWD cable.
Connect the external debug probe to the PC using a USB cable.
Make sure that the Thingy:91 X and the external debug probe are powered on.
In nRF Connect for VS Code extension, click the Flash option in the Actions View.
If you have multiple boards connected, you are prompted to pick a device at the top of the screen.
A small notification banner appears in the bottom-right corner of Visual Studio Code to display the progress and confirm when the flash is complete.
Start the toolchain environment in a terminal window.
Program the sample or application to the device using the following command:
west flash
The device resets and runs the programmed sample or application.