Skip to content

Commit 9ed7bdd

Browse files
ahasztagtomchy
authored andcommitted
samples: dfu: Add single slot sample
Added a sample with a very simple main application and minimized firmware loader image and MCUBoot. It presents how to maximize the space available to the application. The firmware loader in the sample is entered by pressing a button during reset. The functionality of the sample is pretty similar to the firmware_loader_entrance sample, but it is simplified. This will also allow much easier presentation of how to add firmware loader support for nRF54H20 in the future (currently the sample only supports nRF54L15). Signed-off-by: Artur Hadasz <[email protected]>
1 parent 61f5732 commit 9ed7bdd

File tree

13 files changed

+275
-0
lines changed

13 files changed

+275
-0
lines changed

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@
510510
/samples/dfu/dfu_target/ @nrfconnect/ncs-eris
511511
/samples/dfu/dfu_multi_image/ @nrfconnect/ncs-eris
512512
/samples/dfu/fw_loader/ @nrfconnect/ncs-eris
513+
/samples/dfu/single_slot/ @nrfconnect/ncs-eris
513514
/samples/edge_impulse/ @nrfconnect/ncs-si-muffin
514515
/samples/esb/ @nrfconnect/ncs-si-muffin
515516
/samples/event_manager_proxy/ @nrfconnect/ncs-si-muffin
@@ -640,6 +641,7 @@
640641
/samples/dfu/dfu_target/*.rst @nrfconnect/ncs-eris-doc
641642
/samples/dfu/dfu_multi_image/*.rst @nrfconnect/ncs-eris-doc
642643
/samples/dfu/fw_loader/**/*.rst @nrfconnect/ncs-eris-doc
644+
/samples/dfu/single_slot/*.rst @nrfconnect/ncs-eris-doc
643645
/samples/esb/**/*.rst @nrfconnect/ncs-si-muffin-doc
644646
/samples/edge_impulse/**/*.rst @nrfconnect/ncs-si-muffin-doc
645647
/samples/event_manager_proxy/*.rst @nrfconnect/ncs-si-muffin-doc

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ DFU samples
519519
* The :ref:`ab_sample` sample to demonstrate how to implement the A/B firmware update strategy using :ref:`MCUboot <mcuboot_index_ncs>`.
520520
* The :ref:`fw_loader_ble_mcumgr` sample that provides a minimal configuration for firmware loading using SMP over Bluetooth LE.
521521
This sample is intended as a starting point for developing custom firmware loader applications that work with the MCUboot bootloader.
522+
* The :ref:`single_slot_sample` sample to demonstrate how to maximize the available space for the application with MCUboot using firmware loader mode (single-slot layout).
522523

523524
Edge Impulse samples
524525
--------------------
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+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(single_slot)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
config MCUBOOT_SIGNATURE_USING_KMU
8+
default y if SOC_SERIES_NRF54LX
9+
10+
config MCUBOOT_GENERATE_DEFAULT_KMU_KEYFILE
11+
default y if SOC_SERIES_NRF54LX
12+
13+
source "share/sysbuild/Kconfig"

samples/dfu/single_slot/README.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _single_slot_sample:
2+
3+
Single-slot DFU with MCUboot
4+
############################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The Single-slot DFU with MCUboot sample demonstrates how to maximize the available space for the application using MCUboot.
11+
You can do this by using the firmware loader mode (single-slot layout) in MCUboot.
12+
Both MCUboot and the firmware loader images are configured to achieve minimal size, leaving more space available for the application.
13+
14+
Requirements
15+
************
16+
17+
The sample supports the following development kit:
18+
19+
.. table-from-sample-yaml::
20+
21+
Overview
22+
********
23+
24+
This sample contains a simple main application with no firmware update capabilities.
25+
The firmware loader image is used to perform the DFU over Bluetooth® Low Energy.
26+
See :ref:`ug_bootloader_using_firmware_loader_mode` for more details.
27+
28+
This sample employs the :ref:`fw_loader_ble_mcumgr` firmware loader image, which uses the Simple Management Protocol (SMP) over Bluetooth LE.
29+
30+
Building and running
31+
********************
32+
33+
.. |sample path| replace:: :file:`samples/dfu/single_slot`
34+
35+
.. include:: /includes/build_and_run.txt
36+
37+
Testing
38+
=======
39+
40+
After programming the sample to your development kit, perform the following steps:
41+
42+
1. |connect_terminal_specific|
43+
#. Reset the development kit and observe the output on the terminal::
44+
45+
Starting single_slot sample
46+
build time: <BUILD TIME>
47+
48+
#. Build a second version of the sample.
49+
#. Enter the firmware loader mode by holding the **Button 0** on your development kit while you reset the device.
50+
#. Open the `nRF Connect Device Manager`_ mobile app to perform DFU over Bluetooth LE.
51+
The firmware loader advertises itself as **FW loader** and accepts MCUmgr image upload.
52+
#. Send the generated update package for the second version of the sample.
53+
See :ref:`ug_nrf54l_developing_ble_fota_steps_testing` for details on how to use the mobile app to perform the DFU.
54+
#. Verify that the printed build time corresponds to the new version once the update is complete and the device reboots into the main application.
55+
56+
Dependencies
57+
************
58+
59+
This sample uses the following |NCS| components:
60+
61+
* :ref:`MCUboot <mcuboot_index_ncs>`
62+
* :ref:`fw_loader_ble_mcumgr` (as the firmware loader image built by sysbuild)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
mcuboot:
2+
address: 0x0
3+
region: flash_primary
4+
size: 0x6000
5+
app:
6+
address: 0x6800
7+
region: flash_primary
8+
size: 0x13D800
9+
mcuboot_pad:
10+
address: 0x6000
11+
region: flash_primary
12+
size: 0x800
13+
mcuboot_primary:
14+
address: 0x6000
15+
orig_span: &id001
16+
- app
17+
- mcuboot_pad
18+
region: flash_primary
19+
size: 0x13E000
20+
span: *id001
21+
mcuboot_primary_app:
22+
address: 0x6800
23+
orig_span: &id002
24+
- app
25+
region: flash_primary
26+
size: 0x13D800
27+
span: *id002
28+
mcuboot_secondary:
29+
address: 0x144000
30+
orig_span: &id003
31+
- mcuboot_secondary_pad
32+
- firmware_loader
33+
region: flash_primary
34+
size: 0x1c000
35+
span: *id003
36+
mcuboot_secondary_pad:
37+
region: flash_primary
38+
address: 0x144000
39+
size: 0x800
40+
firmware_loader:
41+
region: flash_primary
42+
address: 0x144800
43+
size: 0x1c800
44+
settings_storage:
45+
address: 0x161000
46+
region: flash_primary
47+
size: 0x4000

samples/dfu/single_slot/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# nothing here
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
##
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
sample:
8+
description: Single slot DFU sample application
9+
name: single_slot
10+
common:
11+
sysbuild: true
12+
harness: console
13+
harness_config:
14+
type: one_line
15+
regex:
16+
- "Starting single_slot sample"
17+
tests:
18+
sample.dfu.single_slot:
19+
tags:
20+
- dfu_single_slot
21+
- ci_samples_dfu
22+
platform_allow:
23+
- nrf54l15dk/nrf54l15/cpuapp
24+
integration_platforms:
25+
- nrf54l15dk/nrf54l15/cpuapp

samples/dfu/single_slot/src/main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
9+
int main(void)
10+
{
11+
printk("Starting single_slot sample\n");
12+
13+
/* using __TIME__ ensure that a new binary will be built on every
14+
* compile which is convenient when testing firmware upgrade.
15+
*/
16+
printk("build time: " __DATE__ " " __TIME__ "\n");
17+
18+
return 0;
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
SB_CONFIG_BOOTLOADER_MCUBOOT=y
8+
SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER=y
9+
SB_CONFIG_FIRMWARE_LOADER_IMAGE_BLE_MCUMGR=y
10+
SB_CONFIG_BOOT_SIGNATURE_TYPE_PURE=y

0 commit comments

Comments
 (0)