.. _fmfu_smp_svr_sample: Cellular: Full modem firmware update using SMP Server ##################################################### .. contents:: :local: :depth: 2 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 :ref:`device_mgmt`. Requirements ************ This sample supports the following development kits: .. table-from-sample-yaml:: .. include:: /includes/tfm.txt Overview ******** The sample performs the following operations: 1. It deinitializes the :ref:`nrfxlib:nrf_modem`. #. 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 :ref:`lib_fmfu_mgmt` 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 :ref:`testing_rtt` for details. .. include:: /libraries/modem/nrf_modem_lib/nrf_modem_lib_trace.rst :start-after: modem_lib_sending_traces_UART_start :end-before: modem_lib_sending_traces_UART_end Building and running ******************** .. |sample path| replace:: :file:`samples/cellular/fmfu_smp_svr` .. include:: /includes/build_and_run_ns.txt To use the UART overlay for increasing the transfer speed, add the ``-DDTC_OVERLAY_FILE=uart.overlay`` flag to your build. See :ref:`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: .. parsed-literal:: :class: highlight west build -b *build_target* -- -DDTC_OVERLAY_FILE=uart.overlay |build_target| Testing ======= After programming the sample to your development kit, test it by performing the following steps: 1. 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 :file:`update_modem.py` script specifying the COM port, the firmware ZIP file, and the UART baud rate shown in the following examples. .. tabs:: .. group-tab:: nRF91x1 DK * If you used the default baud rate: .. parsed-literal:: :class: highlight python update_modem.py mfw_nrf91x1_2.0.0.zip /dev/ttyACM0 *115200* * If you used the ``-DDTC_OVERLAY_FILE=uart.overlay`` flag: .. parsed-literal:: :class: highlight python update_modem.py mfw_nrf91x1_2.0.0.zip /dev/ttyACM0 *1000000* .. group-tab:: nRF9160 DK * If you used the default baud rate: .. parsed-literal:: :class: highlight python update_modem.py mfw_nrf9160_1.3.5.zip /dev/ttyACM0 *115200* * If you used the ``-DDTC_OVERLAY_FILE=uart.overlay`` flag: .. parsed-literal:: :class: highlight python update_modem.py mfw_nrf9160_1.3.5.zip /dev/ttyACM0 *1000000* Sample output ------------- The python script should print the following output: .. code-block:: console # 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: .. parsed-literal:: :class: highlight 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 |NCS| libraries: * :ref:`lib_fmfu_mgmt` * :ref:`modem_info_readme` This sample uses the following `sdk-nrfxlib`_ library: * :ref:`nrfxlib:nrf_modem` In addition, it uses the following secure firmware component: * :ref:`Trusted Firmware-M `