Skip to content

Commit 0109956

Browse files
ahasztagtomchy
authored andcommitted
samples: dfu: Add minimal firmware loader sample
This commit adds a firmware loader sample with minimal configuration. The earlier used smp_svr_mini_boot optimized MCUBoot, but not the application itself. As such minimal configuration is planned to be reused, it is more beneficial to add it as a separate sample. Signed-off-by: Artur Hadasz <[email protected]>
1 parent 4cf0821 commit 0109956

File tree

10 files changed

+223
-8
lines changed

10 files changed

+223
-8
lines changed

.github/test-spec.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
- "samples/zephyr/smp_svr_mini_boot/**/*"
147147
- "samples/zephyr/subsys/mgmt/mcumgr/smp_svr/**/*"
148148
- "scripts/bootloader/**/*"
149+
- "samples/dfu/**/*"
149150
- "samples/mcuboot/**/*"
150151
- "scripts/nrf_compress/**/*"
151152
- "scripts/west_commands/ncs*"

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@
509509
/samples/dfu/ab/ @nrfconnect/ncs-eris
510510
/samples/dfu/dfu_target/ @nrfconnect/ncs-eris
511511
/samples/dfu/dfu_multi_image/ @nrfconnect/ncs-eris
512+
/samples/dfu/fw_loader/ @nrfconnect/ncs-eris
512513
/samples/edge_impulse/ @nrfconnect/ncs-si-muffin
513514
/samples/esb/ @nrfconnect/ncs-si-muffin
514515
/samples/event_manager_proxy/ @nrfconnect/ncs-si-muffin
@@ -638,6 +639,7 @@
638639
/samples/dfu/ab/*.rst @nrfconnect/ncs-eris-doc
639640
/samples/dfu/dfu_target/*.rst @nrfconnect/ncs-eris-doc
640641
/samples/dfu/dfu_multi_image/*.rst @nrfconnect/ncs-eris-doc
642+
/samples/dfu/fw_loader/**/*.rst @nrfconnect/ncs-eris-doc
641643
/samples/esb/**/*.rst @nrfconnect/ncs-si-muffin-doc
642644
/samples/edge_impulse/**/*.rst @nrfconnect/ncs-si-muffin-doc
643645
/samples/event_manager_proxy/*.rst @nrfconnect/ncs-si-muffin-doc

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ DFU samples
512512

513513
* The :ref:`dfu_multi_image_sample` sample to demonstrate how to use the :ref:`lib_dfu_target` library.
514514
* The :ref:`ab_sample` sample to demonstrate how to implement the A/B firmware update strategy using :ref:`MCUboot <mcuboot_index_ncs>`.
515+
* The :ref:`fw_loader_ble_mcumgr` sample that provides a minimal configuration for firmware loading using SMP over Bluetooth LE.
516+
This sample is intended as a starting point for developing custom firmware loader applications that work with the MCUboot bootloader.
515517

516518
Edge Impulse samples
517519
--------------------

doc/nrf/samples/dfu.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ This page lists |NCS| samples demonstrating the use of Device Firmware Update (D
1717
:glob:
1818

1919
../../../samples/dfu/*/README
20+
../../../samples/dfu/fw_loader/*/README
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
project(ble_mcumgr)
10+
11+
target_sources(app PRIVATE ${ZEPHYR_BASE}/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c)
12+
target_sources(app PRIVATE ${ZEPHYR_BASE}/samples/subsys/mgmt/mcumgr/smp_svr/src/bluetooth.c)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.. _fw_loader_ble_mcumgr:
2+
3+
Minimal Bluetooth LE SMP firmware loader
4+
########################################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
This sample provides the minimal and recommended configuration for the Firmware Loader application to run on the :ref:`nRF54L15 DK <ug_nrf54l>`.
11+
It uses code from Zephyr's :zephyr:code-sample:`smp-svr` sample to enable the Bluetooth® Low Energy Simple Management Protocol (SMP) server functionality.
12+
13+
This sample is not intended to function as a standalone sample.
14+
Instead, it serves as a starting point for developing a custom Firmware Loader application that works with the MCUboot bootloader.
15+
16+
.. _fw_loader_minimal_overview:
17+
18+
Requirements
19+
************
20+
21+
The sample supports the following development kit:
22+
23+
.. table-from-sample-yaml::
24+
25+
.. _fw_loader_minimal_build_run:
26+
27+
Overview
28+
********
29+
30+
The application uses the SMP over Bluetooth LE to perform firmware updates and manage device operations.
31+
It is optimized for minimal memory usage and contains only the essential functionalities required for firmware loading.
32+
33+
The firmware loader advertises itself as "FW loader" over Bluetooth LE and accepts SMP commands for:
34+
35+
* Image upload and management
36+
* Device information queries
37+
* Bootloader information
38+
39+
.. _fw_loader_minimal_reqs:
40+
41+
Building and running
42+
********************
43+
44+
This sample is not intended for standalone building.
45+
It is automatically included and built when the following Kconfig options are enabled in a project configuration:
46+
47+
* :kconfig:option:`SB_CONFIG_BOOTLOADER_MCUBOOT`
48+
* :kconfig:option:`SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER`
49+
* :kconfig:option:`SB_CONFIG_FIRMWARE_LOADER_IMAGE_BLE_MCUMGR`
50+
51+
52+
Testing
53+
=======
54+
55+
This sample is not intended for standalone testing.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Enable MCUmgr and dependencies.
2+
CONFIG_NET_BUF=y
3+
CONFIG_ZCBOR=y
4+
CONFIG_CRC=y
5+
CONFIG_MCUMGR=y
6+
CONFIG_STREAM_FLASH=y
7+
CONFIG_FLASH_MAP=y
8+
9+
# Some command handlers require a large stack.
10+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
11+
CONFIG_MAIN_STACK_SIZE=2176
12+
13+
# Ensure an MCUboot-compatible binary is generated.
14+
CONFIG_BOOTLOADER_MCUBOOT=y
15+
16+
# Enable flash operations.
17+
CONFIG_FLASH=y
18+
19+
# Enable most core commands.
20+
CONFIG_IMG_MANAGER=y
21+
CONFIG_MCUMGR_GRP_IMG=y
22+
CONFIG_MCUMGR_GRP_OS=y
23+
CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y
24+
CONFIG_MCUMGR_GRP_OS_ECHO=n
25+
CONFIG_MCUMGR_GRP_OS_INFO=n
26+
27+
# Disable debug logging
28+
CONFIG_LOG_MAX_LEVEL=3
29+
30+
CONFIG_BT=y
31+
CONFIG_BT_PERIPHERAL=y
32+
33+
# Allow for large Bluetooth data packets.
34+
CONFIG_BT_L2CAP_TX_MTU=247
35+
CONFIG_BT_BUF_ACL_RX_SIZE=251
36+
CONFIG_BT_BUF_ACL_TX_SIZE=251
37+
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
38+
39+
# Enable the Bluetooth mcumgr transport (unauthenticated).
40+
CONFIG_MCUMGR_TRANSPORT_BT=y
41+
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
42+
43+
# Enable the Shell mcumgr transport.
44+
CONFIG_BASE64=y
45+
CONFIG_CRC=y
46+
47+
# Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies.
48+
# MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands,
49+
# transmitted with the maximum possible MTU value: 247 bytes.
50+
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
51+
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=1220
52+
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
53+
CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608
54+
CONFIG_BT_DEVICE_NAME="FW loader"
55+
56+
57+
# Enable the storage erase command.
58+
CONFIG_MCUMGR_GRP_ZBASIC=y
59+
CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y
60+
61+
# Disable Bluetooth ping support
62+
CONFIG_BT_CTLR_LE_PING=n
63+
64+
# Disable shell commands that are not needed
65+
CONFIG_CLOCK_CONTROL_NRF_SHELL=n
66+
CONFIG_DEVICE_SHELL=n
67+
CONFIG_DEVMEM_SHELL=n
68+
CONFIG_FLASH_SHELL=n
69+
########
70+
71+
# Disable unneeded drivers, peripherals and features to optimize for size
72+
CONFIG_SIZE_OPTIMIZATIONS=y
73+
74+
# Enable LTO
75+
CONFIG_LTO=y
76+
CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
77+
78+
CONFIG_I2C=n
79+
CONFIG_WATCHDOG=n
80+
CONFIG_SPI_NOR=n
81+
CONFIG_GPIO=n
82+
83+
CONFIG_FPU=n
84+
85+
CONFIG_BOOT_BANNER=n
86+
CONFIG_NCS_BOOT_BANNER=n
87+
CONFIG_BOOT_DELAY=0
88+
CONFIG_PRINTK=n
89+
90+
CONFIG_ARM_MPU=n
91+
92+
CONFIG_TIMESLICING=n
93+
CONFIG_COMMON_LIBC_MALLOC=y
94+
CONFIG_LOG=n
95+
CONFIG_SERIAL=n
96+
CONFIG_UART_CONSOLE=n
97+
CONFIG_ASSERT=n
98+
99+
CONFIG_BT_HCI_VS=n
100+
101+
CONFIG_BT_DEBUG_NONE=y
102+
CONFIG_BT_ASSERT=n
103+
CONFIG_BT_DATA_LEN_UPDATE=n
104+
CONFIG_BT_PHY_UPDATE=n
105+
CONFIG_BT_GATT_CACHING=n
106+
107+
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n
108+
CONFIG_BT_GATT_READ_MULTIPLE=n
109+
CONFIG_BT_GATT_READ_MULT_VAR_LEN=n
110+
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
111+
112+
CONFIG_BT_CTLR_PRIVACY=n
113+
CONFIG_BT_CTLR_PHY_2M=n
114+
CONFIG_BT_CTLR_LE_PING=n
115+
116+
CONFIG_PSA_USE_CRACEN_CIPHER_DRIVER=n
117+
CONFIG_PSA_USE_CRACEN_AEAD_DRIVER=n
118+
CONFIG_PSA_USE_CRACEN_MAC_DRIVER=n
119+
CONFIG_PSA_USE_CRACEN_KEY_AGREEMENT_DRIVER=n
120+
CONFIG_PSA_USE_CRACEN_ASYMMETRIC_ENCRYPTION_DRIVER=n
121+
CONFIG_PSA_USE_CRACEN_KEY_MANAGEMENT_DRIVER=n
122+
CONFIG_PSA_USE_CRACEN_KEY_DERIVATION_DRIVER=n
123+
CONFIG_PSA_USE_CRACEN_PAKE_DRIVER=n
124+
CONFIG_PSA_USE_CRACEN_ASYMMETRIC_SIGNATURE_DRIVER=n
125+
CONFIG_PSA_USE_CRACEN_HASH_DRIVER=n
126+
127+
CONFIG_BT_GATT_SERVICE_CHANGED=n
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sample:
2+
description: Minimal Bluetooth LE SMP firmware loader
3+
name: ble_mcumgr
4+
common:
5+
sysbuild: true
6+
tests:
7+
sample.fw_loader_ble_mcumgr:
8+
tags:
9+
- ci_samples_dfu
10+
platform_allow:
11+
- nrf54l15dk/nrf54l15/cpuapp
12+
integration_platforms:
13+
- nrf54l15dk/nrf54l15/cpuapp
14+
extra_args:
15+
- SB_CONFIG_PARTITION_MANAGER=n

samples/mcuboot/firmware_loader_entrance/sysbuild.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
SB_CONFIG_BOOTLOADER_MCUBOOT=y
88
SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER=y
99
SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER_BOOT_MODE_ENTRANCE=y
10-
SB_CONFIG_FIRMWARE_LOADER_IMAGE_SMP_SVR_MINI_BOOT=y
10+
SB_CONFIG_FIRMWARE_LOADER_IMAGE_BLE_MCUMGR=y

sysbuild/Kconfig.firmware_loader

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
config SUPPORT_FIRMWARE_LOADER_SMP_SVR_MINI_BOOT
7+
config SUPPORT_FIRMWARE_LOADER_BLE_MCUMGR
88
bool
99
default y
1010

1111
choice FIRMWARE_LOADER
1212

13-
config FIRMWARE_LOADER_IMAGE_SMP_SVR_MINI_BOOT
14-
bool "smp_svr_mini_boot"
15-
depends on SUPPORT_FIRMWARE_LOADER_SMP_SVR_MINI_BOOT
13+
config FIRMWARE_LOADER_IMAGE_BLE_MCUMGR
14+
bool "ble_mcumgr"
15+
depends on SUPPORT_FIRMWARE_LOADER_BLE_MCUMGR
1616
help
17-
Include the minified MCUmgr ``smp_svr_mini_boot`` sample as the firmware loader image
17+
Include the minified firmware loader ``ble_mcumgr`` sample as the firmware loader image
1818
to use.
1919

2020
endchoice
2121

2222
config FIRMWARE_LOADER_IMAGE_NAME
23-
default "smp_svr_mini_boot" if FIRMWARE_LOADER_IMAGE_SMP_SVR_MINI_BOOT
23+
default "ble_mcumgr" if FIRMWARE_LOADER_IMAGE_BLE_MCUMGR
2424

2525
config FIRMWARE_LOADER_IMAGE_PATH
26-
default "$(ZEPHYR_NRF_MODULE_DIR)/samples/zephyr/smp_svr_mini_boot" if FIRMWARE_LOADER_IMAGE_SMP_SVR_MINI_BOOT
26+
default "$(ZEPHYR_NRF_MODULE_DIR)/samples/dfu/fw_loader/ble_mcumgr" if FIRMWARE_LOADER_IMAGE_BLE_MCUMGR

0 commit comments

Comments
 (0)