MCUboot SMP Server

The MCUboot SMP Server sample demonstrates firmware update using the Simple Management Protocol (SMP) with MCUboot. It provides a starting point for working with multiple MCUboot configurations. You can update the device over UART or Bluetooth® Low Energy.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF7120 DK

nrf7120dk

nrf7120dk/nrf7120/cpuapp

nRF54LV10 DK

PCA10188

nrf54lv10dk

nrf54lv10dk/nrf54lv10a/cpuapp

nRF54LS05 DK

PCA10214

nrf54ls05dk

nrf54ls05dk/nrf54ls05b/cpuapp

nRF54LM20 DK

PCA10184

nrf54lm20dk

nrf54lm20dk/nrf54lm20b/cpuapp nrf54lm20dk/nrf54lm20a/cpuapp

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp

nRF54L15 DK (emulating nRF54L10)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l10/cpuapp

nRF54L15 DK (emulating nRF54L05)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l05/cpuapp

nRF54H20 DK

PCA10175

nrf54h20dk

nrf54h20dk/nrf54h20/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

For update over UART, the nRF Util development tool mcu-manager command is recommended (nrfutil mcu-manager).

For update over Bluetooth Low Energy, you need the nRF Device Manager app:

Overview

This sample implements an SMP server. SMP is a basic transfer encoding used with the MCUmgr management protocol. For more information about MCUmgr and SMP, see Device Management.

The sample supports the serial (UART) MCUmgr transport by default.

Bluetooth LE transport is supported when building with the overlay that enables it (for example, overlay-bt.conf).

The sample is built with sysbuild and includes MCUboot as the bootloader. Various build configurations are provided for different boards, MCUboot modes (including swap, direct-XIP and overwrite), signature types, and optional features such as encryption and compression, as well as external flash support.

The various sample build configurations are defined in the sample.yaml file. The following table describes the available configurations.

Note

Not all configuration and board combinations are supported. Refer to the sample.yaml file for the list of supported boards for each configuration.

Configuration

Transport

MCUboot mode

Other features

sample.dfu.smp_svr.serial

UART

Swap

sample.dfu.smp_svr.bt

Bluetooth LE

Swap

sample.dfu.smp_svr.mcuboot_flags.direct_xip_withrevert

UART

Direct-XIP

sample.dfu.smp_svr.encryption.rsa

UART

Swap

Encryption enabled, signature: RSA

sample.dfu.smp_svr.encryption.ecdsa_p256

UART

Swap

Encryption enabled, signature: ECDSA P-256

sample.dfu.smp_svr.encryption.ed25519

UART

Swap

Encryption enabled, signature: Ed25519

sample.dfu.smp_svr.signature.none

UART

Swap

sample.dfu.smp_svr.signature.ed25519

UART

Swap

Signature using Ed25519

sample.dfu.smp_svr.signature.ecdsa_p256

UART

Swap

Signature using ECDSA P-256

sample.dfu.smp_svr.signature.pure

UART

Swap

Signature using Ed25519 (pure)

sample.dfu.smp_svr.kmu.basic

UART

Swap

KMU-based signature (Ed25519)

sample.dfu.smp_svr.nsib.kmu.basic

UART

Swap

NSIB with KMU-based signature

sample.dfu.smp_svr.kmu.revocation

UART

Swap

KMU with key revocation

sample.dfu.smp_svr.nrf_compress.basic

UART

Overwrite-only

Compressed image support

sample.dfu.smp_svr.nrf_compress.encryption_rsa

UART

Overwrite-only

Compression and encryption (RSA)

sample.dfu.smp_svr.nrf_compress.encryption_ecdsa_p256

UART

Overwrite-only

Compression and encryption (ECDSA P-256)

sample.dfu.smp_svr.nrf_compress.encryption_ed25519

UART

Overwrite-only

Compression and encryption (Ed25519)

sample.dfu.smp_svr.bt.nrf5340dk.ext_flash

Bluetooth LE

Swap

External flash

sample.dfu.smp_svr.bt.nrf54l15

Bluetooth LE

Swap

sample.dfu.smp_svr.bt.nrf54l15dk.ext_flash

Bluetooth LE

Swap

External flash

sample.dfu.smp_svr.bt.nrf54l15dk.ext_flash.pure_dts

Bluetooth LE

Swap

External flash (pure DTS, no partition manager)

sample.dfu.smp_svr.bt.nrf54l15dk.ext_flash.sqspi

Bluetooth LE

Swap

External flash, communication through software QSPI on FLPR core

sample.dfu.smp_svr.bt.nrf54h20dk

Bluetooth LE

Swap

sample.dfu.smp_svr.bt.nrf54h20dk.direct_xip_withrevert

Bluetooth LE

Direct-XIP

sample.dfu.smp_svr.serial.nrf54h20dk.ecdsa

UART

Swap

Signature using ECDSA P-256

sample.dfu.smp_svr.bt.nrf54h20dk.direct_xip_withrequests

Bluetooth LE

Direct-XIP

sample.dfu.smp_svr.bt.nrf54h20dk.ext_flash

Bluetooth LE

Swap

External flash

sample.dfu.smp_svr.ram_load

UART

RAM load

sample.dfu.smp_svr.ram_load.kmu

UART

RAM load

KMU-based signature (Ed25519)

Building and running

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

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 steps described above build the basic configuration with the UART transport and MCUboot using swap mode. Other build configurations are available for different boards, MCUboot modes, signature types, and optional features.

When building a <configuration_name> configuration from the sample.yaml file, you can use the following command:

west build -b <board_name> -T ./<configuration_name>

Alternatively, you can manually specify the extra_args parameters listed in the configuration description. Pass each parameter with the -D prefix after --:

west build -b <board_name> -- -D<extra_arg1> -D<extra_arg2> ...

For example, build the sample.dfu.smp_svr.bt.nrf54h20dk configuration by running the following command:

west build -b nrf54h20dk/nrf54h20/cpuapp -T ./sample.dfu.smp_svr.bt.nrf54h20dk

Alternatively, review the extra_args parameters defined for this configuration:

EXTRA_CONF_FILE="overlay-bt.conf"
SB_CONFIG_NETCORE_IPC_RADIO=y
SB_CONFIG_NETCORE_IPC_RADIO_BT_HCI_IPC=y
mcuboot_CONFIG_PSA_CRYPTO=y
mcuboot_CONFIG_MULTITHREADING=y
CONFIG_MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_ANY=y

You can then build the configuration by explicitly passing these parameters:

west build -b nrf54h20dk/nrf54h20/cpuapp -- -DEXTRA_CONF_FILE="overlay-bt.conf" -DSB_CONFIG_NETCORE_IPC_RADIO=y -DSB_CONFIG_NETCORE_IPC_RADIO_BT_HCI_IPC=y -Dmcuboot_CONFIG_MULTITHREADING=y -DCONFIG_MCUMGR_GRP_IMG_ALLOW_CONFIRM_NON_ACTIVE_IMAGE_ANY=y

Testing

The following steps are common for all configurations:

  1. Build the sample.

  2. Program the firmware to your development kit.

  3. Observe the following output on the terminal:

    [00:00:00.007,978] <inf> smp_sample: build time: <BUILD TIME>
    

    <BUILD TIME> indicates the build time.

Performing DFU is specific to the configuration.

Testing over UART

The following steps show how to perform DFU using the nRF Util development tool mcu-manager command over UART. Not all steps apply to all configurations. For example, if the overwrite only mode is used, no confirmation is needed.

  1. Disconnect the terminal to avoid conflicts. The SMP communication uses the same serial port as the log output. Some terminal emulators might not require this step.

  2. List the images on the device. The serial port might differ depending on your development kit and operating system.

    nrfutil mcu-manager serial image-list --serial-port <serial_port>
    

    The output resembles the following example:

    Image
      slot: 0
      version: 0.0.0
      hash: ef8cc97cf2c873bde983a3a133cbc7468ef14cd42092ee131b00275aea0429522f256020129a51f9309078b1ca310ed1f76a091c484a496f8d3f7fd565d13468
      bootable: true
      pending: false
      confirmed: true
      active: true
      permanent: false
    

    The number of images can differ depending on the configuration and board (for example, separate radio core, or merged/split images).

  3. Build the second version of the sample. For simplicity, it is assumed to be built in the build_v2 directory.

  4. Upload the second version of the image to the device using the SMP protocol:

    nrfutil mcu-manager serial image-upload --serial-port /dev/ttyACM0 --image-number 0 --firmware ./build_v2/smp_svr/zephyr/zephyr.signed.bin
    
  5. List the images on the device again to get the hash of the second version of the image:

    nrfutil mcu-manager serial image-list --serial-port /dev/ttyACM0
    

    The output resembles the following example:

    Image
      slot: 0
      version: 0.0.0
      hash: ef8cc97cf2c873bde983a3a133cbc7468ef14cd42092ee131b00275aea0429522f256020129a51f9309078b1ca310ed1f76a091c484a496f8d3f7fd565d13468
      bootable: true
      pending: false
      confirmed: true
      active: true
      permanent: false
    Image
      slot: 1
      version: 0.0.0
      hash: 35bd50242ad991aa5fd9374b33bc8ebcd2332fe26cae44f5f32172a62b7c4adcde1467f33b783e7c7090eb6dffc358bcb9a4efb8f50b99d587131418cd5da375
      bootable: true
      pending: false
      confirmed: false
      active: false
      permanent: false
    
  6. Set the test flag for the second version of the image, using the acquired hash:

    nrfutil mcu-manager serial image-test --serial-port /dev/ttyACM0 --hash 35bd50242ad991aa5fd9374b33bc8ebcd2332fe26cae44f5f32172a62b7c4adcde1467f33b783e7c7090eb6dffc358bcb9a4efb8f50b99d587131418cd5da375
    
  7. Reconnect to the terminal.

  8. Reboot the device.

  9. Verify that the build time in the terminal output reflects the new version.

  10. To make the new version permanent, confirm the image:

    nrfutil mcu-manager serial image-confirm --serial-port /dev/ttyACM0 --hash 35bd50242ad991aa5fd9374b33bc8ebcd2332fe26cae44f5f32172a62b7c4adcde1467f33b783e7c7090eb6dffc358bcb9a4efb8f50b99d587131418cd5da375
    

Testing over Bluetooth LE

To perform DFU using the nRF Connect Device Manager mobile app over Bluetooth LE, follow these steps:

  1. Start the nRF Connect Device Manager mobile app.

  2. Follow the testing steps for the FOTA over Bluetooth LE. For more information, see the following documentation pages:

  3. After the firmware update completes, check the UART output. Observe that the build time in the terminal output reflects the new version.

Dependencies

This sample uses the following nRF Connect SDK library: