Cellular: nRF Cloud REST FOTA

Note

The nRF Cloud REST library has been deprecated and it will be removed in one of the future releases. Use the Cellular: nRF Cloud CoAP FOTA sample instead.

The REST FOTA sample demonstrates how to use the nRF Cloud REST API to perform Firmware Over-the-Air (FOTA) updates over REST on your device. This covers modem, application, and full modem FOTA updates (FMFU). Also, with the nRF9160 DK, it supports SMP FOTA updates.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

Thingy:91 X

PCA20065

thingy91x

thingy91x/nrf9151/ns

nRF9161 DK

PCA10153

nrf9161dk

nrf9161dk/nrf9161/ns

nRF9160 DK

PCA10090

nrf9160dk

nrf9160dk/nrf9160/ns

nRF9151 DK

PCA10171

nrf9151dk

nrf9151dk/nrf9151/ns

For more security, it is recommended to use the */ns variant of the board target. When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

The sample requires an nRF Cloud account.

Your device must be onboarded to nRF Cloud. If it is not, follow the instructions in Device on-boarding.

Note

This sample requires modem firmware v1.3.x or later for an nRF9160 SiP and v2.0.0 or later for nRF91x1 SiPs.

External flash

To use the external flash memory on the nRF9160 DK v0.14.0 or later versions, the board controller firmware must be of version v2.0.1. This is the factory firmware version. If you need to program the board controller firmware again, complete the following steps:

  1. Download the nRF9160 DK board controller firmware from the nRF9160 DK downloads page.

  2. Make sure the PROG/DEBUG SW10 switch on the nRF9160 DK is set to nRF52.

  3. Program the board controller firmware (nrf9160_dk_board_controller_fw_2.0.1.hex) using the Programmer app in nRF Connect for Desktop.

Note

The board controller firmware version must be v2.0.1 or higher, which enables the pin routing to external flash.

See Board controller on the nRF9160 DK for more details.

Note

Full modem FOTA requires development kit version 0.14.0 or higher if you are using an nRF9160 DK.

Overview

You can update your device firmware on the nRF Cloud portal or directly through the nRF Cloud REST API. See the nRF Cloud Getting Started FOTA documentation for details.

Limitations

This sample requires the network carrier to provide date and time to the modem. Without a valid date and time, the modem cannot generate JWTs with an expiration time.

User interface

Once the device is onboarded and connected, if you want to perform an update check immediately, press Button 1. This will bypass the wait time specified by the CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN option. Button 1 is configured by the CONFIG_REST_FOTA_BUTTON_EVT_NUM option.

The configured LTE LED (LED 1 by default, CONFIG_REST_FOTA_LTE_LED_NUM) is lit once an LTE connection is established.

Onboarding your device to nRF Cloud

You must onboard your device to nRF Cloud for this sample to function. You only need to do this once for each device.

To onboard your device, install nRF Cloud Utils and follow the instructions in the README.

Configuration

See Configuring and building for information about how to permanently or temporarily change the configuration.

Configuration options

Check and configure the following configuration options for the sample:

CONFIG_REST_FOTA_JOB_CHECK_RATE_MIN - Update check rate

Defines how often the sample checks for FOTA updates. You can modify this value at runtime by adding or updating the "fotaInterval" item in the desired config section of the device’s shadow. Use the nRF Cloud portal or the REST API to perform the config update.

CONFIG_REST_FOTA_LTE_LED_NUM - LTE LED number

Defines the LED used to indicate connection to the LTE network.

CONFIG_REST_FOTA_BUTTON_EVT_NUM - Button number

Defines the button to use for manual FOTA update check.

Sending traces over UART on an nRF91 Series DK

To send modem traces over UART on an nRF91 Series DK, configuration must be added for the UART device in the devicetree and Kconfig. This is done by adding the modem trace UART snippet when building and programming.

Use the Cellular Monitor app for capturing and analyzing modem traces.

TF-M logging must use the same UART as the application. For more details, see shared TF-M logging.

Building and running

This sample can be found under samples/cellular/nrf_cloud_rest_fota in the nRF Connect SDK folder structure.

For more security, it is recommended to use the */ns variant of the board target (see the Requirements section above.) When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

The configuration files for this sample are located in samples/cellular/nrf_cloud_rest_fota. See Configuring and building for information on how to configure the parameters.

To create a FOTA test version of this sample, add the following parameter to your build command:

-DEXTRA_CONF_FILE=overlay_fota_test.conf

To enable full modem FOTA, add the following parameter to your build command:

-DEXTRA_CONF_FILE=overlay_full_modem_fota.conf

Also, if you are using an nRF9160 DK, specify your development kit version by appending it to the board name. For example, if you are using version 1.0.1, use the board name nrf9160dk@1.0.1/nrf9160/ns in your build command.

To enable SMP FOTA (nRF9160 DK only), add the following parameters to your build command:

  • -DEXTRA_CONF_FILE=overlay_smp_fota.conf

  • -DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay

Once the nRF9160 has been flashed, change the switch SW10 to the nRF52 position to be able to flash the nRF52840 on the DK. The nRF52840 device on your DK must be running an SMP compatible firmware, such as the Cellular: SMP Server sample. Otherwise, the REST FOTA sample will not be able to connect to the nRF52840 and will keep trying to connect. Build the Cellular: SMP Server sample for the nrf9160dk/nrf52840 board with the following parameters:

  • -DEXTRA_CONF_FILE=overlay-serial.conf

  • -DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_nrf52840_mcumgr_svr.overlay

To change Cellular: SMP Server sample’s application version, set the CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION Kconfig option.

Dependencies

This sample uses the following nRF Connect SDK libraries:

In addition, it uses the following secure firmware component: