Cellular: 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 kits:
Hardware platforms |
PCA |
Board name |
Board target |
---|---|---|---|
PCA10153 |
|
||
PCA10090 |
|
||
PCA10171 |
|
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.
Overview
The sample performs the following operations:
It deinitializes the Modem library.
It registers to mcumgr a
stat
command.It then registers the commands to upload the firmware and to get the hash.
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.
Note
UART is the only transport method supported. RTT is enabled by default to ensure that you can view the log generated by the sample or other subsystems. See Testing and optimization for details.
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/fmfu_smp_svr
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 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.
To use the UART overlay for increasing the transfer speed, add the -DDTC_OVERLAY_FILE=uart.overlay
flag to your build.
See Providing CMake options for instructions on how to add this flag.
When building on the command line add the UART overlay in the following way, depending on the DK you are using:
west build -b board_target -- -DDTC_OVERLAY_FILE=uart.overlay
Replace the board_target with the board target of the nRF91 Series device you are using (see the Requirements section).
Testing
After programming the sample to your development kit, test it by performing the following steps:
Connect the USB cable and power on or reset your nRF91 Series DK.
Open a terminal emulator, observe that the sample starts, and then close the terminal emulator.
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_nrf91x1_2.0.0.zip /dev/ttyACM0 115200
If you used the
-DDTC_OVERLAY_FILE=uart.overlay
flag:
python update_modem.py mfw_nrf91x1_2.0.0.zip /dev/ttyACM0 1000000
If you used the default baud rate:
python update_modem.py mfw_nrf9160_1.3.5.zip /dev/ttyACM0 115200
If you used the
-DDTC_OVERLAY_FILE=uart.overlay
flag:
python update_modem.py mfw_nrf9160_1.3.5.zip /dev/ttyACM0 1000000
Sample output
The python script should print the following output:
# nrf91 Series 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 sdk-nrfxlib library:
In addition, it uses the following secure firmware component: