Cellular: HTTP full modem update

The HTTP full modem update sample shows how to perform a full firmware update of the modem. The sample downloads the modem firmware signed by Nordic Semiconductor and updates the firmware.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF9161 DK

PCA10153

nrf9161dk

nrf9161dk/nrf9161/ns

nRF9160 DK

PCA10090

nrf9160dk

nrf9160dk/nrf9160/ns

nRF9151 DK

PCA10171

nrf9151dk

nrf9151dk/nrf9151/ns

When built for a board target with the */ns variant, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

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.

Overview

An external flash memory with minimum 4 MB of free space is required to perform a full modem update. Hence, for the nRF9160 DK, version 0.14.0 or higher is supported by the sample as the earlier versions do not have any external flash memory. The nRF91x1 DK has external flash memory.

The sample proceeds as follows:

  1. It connects to a remote HTTP server to download a signed version of the modem firmware, using the FOTA download library.

  2. It writes the modem firmware to the external flash memory.

  3. It prevalidates the update if the firmware supports the prevalidation process.

  4. It then programs the update to the modem, using the Full modem firmware update from flash device library.

The current version of this sample downloads two different versions of the firmware. The sample then selects the version to install based on the currently installed version.

Configuration

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

Configuration options

You can customize the firmware files downloaded by the sample through the following Kconfig options in the prj.conf file:

CONFIG_DOWNLOAD_HOST

Sets the hostname of the server where the updates are located.

CONFIG_DOWNLOAD_MODEM_0_FILE

Sets the file name of the first firmware. It supports files encoded in the serialized .cbor format. See Serialization for additional information.

CONFIG_DOWNLOAD_MODEM_0_VERSION

Sets the version of the first firmware.

CONFIG_DOWNLOAD_MODEM_1_FILE

Sets the file name of the second firmware. It supports files encoded in the serialized .cbor format. See Serialization for additional information.

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/http_update/full_modem_update in the nRF Connect SDK folder structure.

When built as firmware image for a board target with the */ns variant, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE). Because of this, it automatically includes the Trusted Firmware-M (TF-M). To read more about CMSE, see Processing environments.

To build the sample, follow the instructions in Configuring and 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.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. Start the application and wait for a prompt for pressing a button.

  2. Press the Button 1 button or type “download” in the terminal emulator to start downloading the update. Wait for the download to complete.

  3. Press the Button 2 button or type “apply” in the terminal emulator to apply the update. Once the modem update procedure is complete, the modem is reinitialized to run the new firmware.

  4. Observe that the LED pattern has changed.

Dependencies

This sample uses the following nRF Connect SDK libraries:

It uses the following sdk-nrfxlib library:

It also uses the following Zephyr libraries:

In addition, it uses the following secure firmware component: