MCUboot: Recovery entry

This sample demonstrates how to reboot into MCUboot’s recovery (firmware loader) mode using the retention boot mode subsystem via Bluetooth Low Energy and MCUmgr. See Running the DFU process for details on DFU support in Bare Metal.

Requirements

The sample supports the following development kits:

S115:

Hardware platform

PCA

Board target

nRF54L15 DK

PCA10156

bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice/mcuboot

nRF54L15 DK (emulating nRF54L10)

PCA10156

bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice/mcuboot

nRF54L15 DK (emulating nRF54L05)

PCA10156

bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice/mcuboot

nRF54LM20 DK

PCA10184

bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice/mcuboot

nRF54LS05 DK

PCA10214

bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice/mcuboot

nRF54LV10 DK

PCA10188

bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice/mcuboot

S145:

Hardware platform

PCA

Board target

nRF54L15 DK

PCA10156

bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcuboot

nRF54L15 DK (emulating nRF54L10)

PCA10156

bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcuboot

nRF54L15 DK (emulating nRF54L05)

PCA10156

bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot

nRF54LM20 DK

PCA10184

bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcuboot

nRF54LS05 DK

PCA10214

bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice/mcuboot

nRF54LV10 DK

PCA10188

bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice/mcuboot

Overview

After the application boots, it begins advertising as nRF_BM_Entry, advertising the MCUmgr service.

A mobile device can then connect and issue the OS mgmt reset command with the optional boot_mode parameter provided and set to 1. Before the reset, the mobile device can also set up the advertising name of the firmware loader using the MCUmgr settings management commands. The command sets the retention register for entering the firmware loader mode and reboots the device. It then starts advertising the MCUmgr service allowing for a firmware update to be loaded.

For more details on this workflow, see System reset in Zephyr documentation.

Building and running

This sample can be found under samples/boot/mcuboot_recovery_entry/ in the Bare Metal folder structure. The sample supports the default configuration for evaluation purposes and the size-optimized configuration of the DFU component for reference. To enable the size-optimized configuration, set FILE_SUFFIX to size_opt when building the sample.

For details on how to create, configure, and program a sample, see Getting Started with the samples.

Testing

  1. Compile and program the application.

  2. Connect the device to the computer to access the UART. If you use a development kit, the UART is forwarded as a COM port (Windows) or ttyACM device (Linux) after you connect the development kit over USB.

  3. Connect to the DK with a terminal emulator (for example, the Serial Terminal app) to VCOM1.

  4. Reset the DK.

  5. Observe in the terminal that the device boots into application mode and then advertises with the default name nRF_BM_Entry.

  6. Connect to your device using the nRF Connect Device Manager mobile application.

  7. Under the image tab, tap Advanced.

  8. In the reset control panel, select Switch to Firmware Loader mode. Optionally, specify the advertising name in the text field below and tap Send Reset Command.

  9. Observe in the terminal that the device reboots into the Firmware Loader mode and advertises with the advertising name specified or the default Firmware Loader name nRF_BM_MCUmgr.

  10. Using the nRF Connect Device Manager mobile application, go back to the device list and refresh it by swiping down. Connect to your device that now advertises with the advertising name specified or the default firmware loader name nRF_BM_MCUmgr.

  11. Under the image tab, tap Advanced. Then, in the image control pane, tap Read. Observe that the details of the currently loaded application are displayed.

  12. Build an application with a modified image version by changing the CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION Kconfig option. One way of changing the option is to add CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="1.0.0+0" to the sample’s prj.conf file to override the default version string.

  13. Transfer the <build_dir>/installer_softdevice_firmware_loader.bin and <build_dir>/<app_name>/zephyr/zephyr.signed.bin files to your mobile device.

  14. In nRF Connect Device Manager application, tap the Image tab at the bottom to move to the image management tab. If you only see the basic image tab view, tap Advanced to switch to the advanced image tab view.

  15. Under Firmware Upload select the update file to load:

    • Choose installer_softdevice_firmware_loader.bin to update the SoftDevice and Firmware Loader images. This is only needed if the SoftDevice or Firmware Loader images have been updated. This image must be loaded first if it is needed.

    • Choose zephyr.signed.bin to load the application update.

  16. Tap the Upload button, then select the Image 0 option to begin the firmware update process.

  17. The mobile device will connect and load the firmware update to the device.

  18. Once completed, reboot the device. If the Installer image was loaded, then it will apply the updates and reboot into Firmware Loader mode automatically and allow for loading the application firmware update using the same process. If an application update was loaded, then the new application will begin executing.

Dependencies

The sample uses the following Zephyr libraries: