nRF9160: Full modem firmware update using SMP Server

This sample application implements a Simple Management Protocol (SMP) Server, using the SMP transfer encoding with the MCU manager (mcumgr) management protocol, to provide an interface over UART which enables the device to do full modem firmware updates.

For more information about mcumgr and SMP, see Device Management.

Requirements

This sample supports the following development kit:

Hardware platforms

PCA

Board name

Build target

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160ns

The sample is configured to compile and run as a non-secure application on nRF91’s Cortex-M33. Therefore, it automatically includes the Secure Partition Manager that prepares the required peripherals to be available for the application.

You can also configure it to use TF-M instead of Secure Partition Manager.

Overview

The sample does the following:

  1. It deinitializes the Modem library.

  2. It registers to mcumgr a stat command.

  3. It then registers the commands to upload the firmware and to get the hash.

  4. It finally enters an idle loop, waiting for any communication over the serial line.

The sample also provides a UART overlay that will allow your sample to transfer at a speed of 1M baud, and it enables support for the fmfu_mgmt command group. See Mcumgr based full modem update for more details.

Building and running

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

The sample is built as a non-secure firmware image for the nrf9160dk_nrf9160ns build target. Because of this, it automatically includes the Secure Partition Manager. You can also configure it to use TF-M instead of SPM.

See Building and programming a sample application for information about how to build and program the application.

To use the UART overlay for increasing the transfer speed, add the -DOVERLAY_FILE=uart.overlay flag to your build.

Testing

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

  1. Connect the USB cable and power on or reset your nRF9160 DK.

  2. Open a terminal emulator, observe that the sample starts, and then close the terminal emulator.

  3. Call the provided update_modem.py script specifying the COM port, the firmware ZIP file, and the UART baud rate shown in the following examples.

    • If you used the default baud rate:

      python update_modem.py mfw_nrf9160_1.2.2.zip /dev/ttyACM0 115200
    • If you used the -DOVERLAY_FILE=uart.overlay flag:

      python update_modem.py mfw_nrf9160_1.2.2.zip /dev/ttyACM0 1000000

Sample output

The python script should print the following output:

# nrf9160 modem firmware upgrade over serial port example started.
{
"duration": 406,
"error_code": "Ok",
"operation": "open_uart",
"outcome": "success",
"progress_percentage": 100
}
Programming modem bootloader.
...
Finished with file.
Verifying memory range 1 of 3
Verifying memory range 2 of 3
Verifying memory range 3 of 3
Verification success.
{
"duration": 5,
"error_code": "Ok",
"operation": "close_uart",
"outcome": "success",
"progress_percentage": 100
}
------------------------------------------------------------

Troubleshooting

You can use the mcumgr CLI tool to test if the sample is running correctly, as follows:

 mcumgr --conntype serial --connstring="dev=*COM Port*,baud=*Baudrate*" stat smp_com
 stat group: smp_com
     512 frame_max
     504 pack_max

Dependencies

This sample uses the following nRF Connect SDK libraries:

This sample uses the following nrfxlib libraries:

In addition, it uses the following nRF Connect SDK sample: