Cellular: SMP Server
This sample is a reference implementation to use MCUboot recovery mode or serial SMP server mode for external image update.
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10090 |
|
Overview
The sample supports the mcuboot
shell commands for checking image information and a new activated image will be confirmed automatically.
Connecting nRF9160 SiP to nRF52840 SoC
On the nRF9160 DK, you can configure the hardware interface between the nRF9160 SiP and nRF52840 SoC to use serial connection. In this sample, the nRF9160 SiP uses UART2 and nRF52840 SoC uses UART1. The reset line is needed for activating MCUboot recovery mode.
/*
| nRF9160 | | nRF52840 |
| UART 2 | | UART1 |
| RTS P0.17 | -- nRF interface line 0 -- | P0.17 CTS |
| P0.18 | -- nRF interface line 1 -- | P0.20 |
| P0.19 | -- nRF interface line 2 -- | P0.15 |
| RX P0.21 | -- nRF interface line 3 -- | P0.22 TX |
| CTS P0.22 | -- nRF interface line 4 -- | P1.04 RTS |
| TX P0.23 | -- nRF interface line 5 -- | P1.02 RX |
| COEX0 | -- nRF interface line 6 -- | P1.13 |
| COEX1 | -- nRF interface line 7 -- | P1.11 |
| COEX2 | -- nRF interface line 8 -- | P1.15 |
| P0.24 | -- nRF interface line 9 -- | P0.18 (nRESET) | (in v0.14.0 or later)
*/
SMP and MCUmgr protocols are used to communicate over UART.
Configuration
See Configuring your application for information about how to permanently or temporarily change the configuration.
Configuration files
The sample supports UART1 connection for the nRF9160 DK with or without MCUboot recovery mode. The nRF52840 SoC needs to enable UART1 on the devicetree using the following configuration files and recovery mode overlay files:
overlay-serial.conf
- Defines the MCUmgr server configuration with SMP serial transport for UART1. This requires an additional devicetree overlay filenrf9160dk_nrf52840_mcumgr_srv.overlay
.nrf9160dk_nrf52840_recovery.overlay
- Devicetree overlay file that enables resetting of the MCUboot recovery mode.
MCUboot configuration
The sample has defined configuration and device tree overlay files for MCUboot that are available in the sample folder:
child_image/mcuboot.conf
- Defines the MCUboot recovery mode.child_image/mcuboot/boards/nrf9160dk_nrf52840_0_14_0.overlay
- Define UART1 for MCUmgr.
The MCUboot configuration is enabled automatically at build.
Partition management
The sample has a static partition management file pm_static_nrf9160dk_nrf52480.yml
to enable MCUboot secondary slot usage, which is a requirement.
Building
This sample can be found under samples/cellular/smp_svr/
in the nRF Connect SDK folder structure.
When built as firmware image for the _ns
build target, 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 with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Building and programming an application for other building and programming scenarios and Testing and debugging an application for general information about testing and debugging in the nRF Connect SDK.
Note
Before building the sample, make sure the PROG/DEBUG switch is set to nRF52.
MCUboot recovery mode
west build --pristine -b nrf9160dk_nrf52840 -- -DEXTRA_DTC_OVERLAY_FILE="nrf9160dk_nrf52840_recovery.overlay"
MCUmgr server image management
west build --pristine -b nrf9160dk_nrf52840 -- -DOVERLAY_CONFIG="overlay-serial.conf" -DEXTRA_DTC_OVERLAY_FILE="nrf9160dk_nrf52840_mcumgr_srv.overlay"
Testing
After programming the sample to your development kit, complete the following steps to test it:
Connect the kit to the computer using a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.
Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.
Observe that the sample starts.
Open a terminal connection for the nRF52840 SoC (VCOM1), in Linux
/dev/ttyACM1
, and call themcuboot
command on the shell. You can see the following output on the terminal:uart:~$ mcuboot swap type: none confirmed: 1 primary area (2): version: 1.0.0+0 image size: 70136 magic: unset swap type: none copy done: unset image ok: unset failed to read secondary area (5) header: -5 uart:~$
Dependencies
The sample uses the following secure firmware component: