Skip to content

Commit 4048cb0

Browse files
ahasztagtomchy
authored andcommitted
dfu: dfu_multi_image support for nRF54H20
This commit adds support for the nRF54H20 SoC in the build system. Signed-off-by: Artur Hadasz <[email protected]>
1 parent e874e6b commit 4048cb0

17 files changed

+280
-30
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
config SOC_SERIES_NRF53X
8+
select MCUBOOT_NRF53_MULTI_IMAGE_UPDATE
9+
select SECURE_BOOT_NETCORE
10+
select NETCORE_APP_UPDATE
11+
12+
if SOC_SERIES_NRF53X
13+
14+
choice MCUBOOT_MODE
15+
default MCUBOOT_MODE_OVERWRITE_ONLY
16+
endchoice
17+
18+
endif # SOC_SERIES_NRF53X
19+
20+
source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"

samples/dfu/dfu_multi_image/README.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Currently, it only supports DFU targets for MCUboot as its backend.
1313
Requirements
1414
************
1515

16-
The sample supports the following development kit:
16+
The sample supports the following development kits:
1717

1818
.. table-from-sample-yaml::
1919

@@ -80,6 +80,8 @@ Testing
8080
+===================+==================+
8181
| nRF5340 DK | ``0xb8000`` |
8282
+-------------------+------------------+
83+
| nRF54H20 DK | ``0xe134000`` |
84+
+-------------------+------------------+
8385

8486
#. Upload the second version of the images to the device using ``nrfutil device``:
8587

@@ -138,6 +140,11 @@ Testing
138140
139141
The build time should reflect the new version in both cases.
140142

143+
#. To make the update permanent, use the ``dfu_multi_image mcuboot_confirm <image_number>`` command.
144+
This step is optional and not applicable to the nRF5340 DK.
145+
``<image_number>`` is ``0`` for the application core and ``1`` for the network core.
146+
Without this step, any image that is not confirmed will revert to the previous image on the next reboot.
147+
141148
Dependencies
142149
************
143150

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include "../sysbuild/nrf54h20dk_nrf54h20_memory_map.dtsi"
8+
9+
slot0_partition: &cpuapp_slot0_partition {
10+
label = "image-0";
11+
};
12+
13+
slot1_partition: &cpuapp_slot1_partition {
14+
label = "image-1";
15+
};
16+
17+
slot2_partition: &cpurad_slot0_partition {
18+
label = "image-2";
19+
};
20+
21+
slot3_partition: &cpurad_slot1_partition {
22+
label = "image-3";
23+
};

samples/dfu/dfu_multi_image/sample.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ sample:
88
description: DFU multi image sample application
99
name: dfu_multi_image sample
1010
common:
11-
platform_allow: nrf5340dk/nrf5340/cpuapp
11+
platform_allow:
12+
- nrf5340dk/nrf5340/cpuapp
13+
- nrf54h20dk/nrf54h20/cpuapp
1214
build_only: true
1315
sysbuild: true
1416
tests:
@@ -18,6 +20,7 @@ tests:
1820
- ci_samples_dfu
1921
integration_platforms:
2022
- nrf5340dk/nrf5340/cpuapp
23+
- nrf54h20dk/nrf54h20/cpuapp
2124
sample.dfu.dfu_multi_image.save_progress:
2225
extra_configs:
2326
- CONFIG_DFU_TARGET_STREAM_SAVE_PROGRESS=y
@@ -29,3 +32,13 @@ tests:
2932
- ci_samples_dfu
3033
integration_platforms:
3134
- nrf5340dk/nrf5340/cpuapp
35+
- nrf54h20dk/nrf54h20/cpuapp
36+
sample.dfu.dfu_multi_image.encryption:
37+
extra_args:
38+
- SB_CONFIG_BOOT_ENCRYPTION=y
39+
tags:
40+
- dfu_multi_image
41+
- ci_samples_dfu
42+
integration_platforms:
43+
- nrf5340dk/nrf5340/cpuapp
44+
- nrf54h20dk/nrf54h20/cpuapp

samples/dfu/dfu_multi_image/src/dfu_multi_image_shell.c

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@
1313
#include <dfu/dfu_multi_image.h>
1414
#include <zephyr/dfu/mcuboot.h>
1515

16+
#ifdef CONFIG_PARTITION_MANAGER_ENABLED
1617
#include <pm_config.h>
18+
#endif
1719

1820
#include "dfu_multi_image_sample_common.h"
1921

2022
#ifdef CONFIG_PARTITION_MANAGER_ENABLED
2123
#define DFU_MULTI_IMAGE_HELPER_ADDRESS PM_DFU_MULTI_IMAGE_HELPER_ADDRESS
22-
#define DFU_TARGET_HELPER_SIZE PM_DFU_MULTI_IMAGE_HELPER_SIZE
24+
#define DFU_MULTI_IMAGE_HELPER_SIZE PM_DFU_MULTI_IMAGE_HELPER_SIZE
2325
#else
24-
#define DFU_MULTI_IMAGE_HELPER_ADDRESS DT_REG_ADDR(DT_ALIAS(dfu_multi_image_helper))
25-
#define DFU_TARGET_HELPER_SIZE DT_REG_SIZE(DT_ALIAS(dfu_multi_image_helper))
26+
#define DFU_MULTI_IMAGE_HELPER_CONTAINER_ADDRESS \
27+
DT_REG_ADDR(DT_GPARENT(DT_ALIAS(dfu_multi_image_helper)))
28+
#define DFU_MULTI_IMAGE_HELPER_OFFSET DT_REG_ADDR(DT_ALIAS(dfu_multi_image_helper))
29+
#define DFU_MULTI_IMAGE_HELPER_ADDRESS ((uint32_t) DFU_MULTI_IMAGE_HELPER_CONTAINER_ADDRESS + \
30+
DFU_MULTI_IMAGE_HELPER_OFFSET)
31+
#define DFU_MULTI_IMAGE_HELPER_SIZE DT_REG_SIZE(DT_ALIAS(dfu_multi_image_helper))
2632
#endif
2733

2834
static int cmd_dfu_multi_image_write(const struct shell *shell, size_t argc, char **argv)
@@ -186,6 +192,33 @@ static int cmd_dfu_multi_image_full_update(const struct shell *shell, size_t arg
186192
return 0;
187193
}
188194

195+
#ifndef CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY
196+
static int cmd_dfu_multi_image_mcuboot_confirm(const struct shell *shell, size_t argc, char **argv)
197+
{
198+
int ret = 0;
199+
int img_num = -1;
200+
201+
if (argc != 2) {
202+
shell_error(shell, "Usage: dfu_multi_image mcuboot_confirm <img_num>");
203+
return -EINVAL;
204+
}
205+
206+
img_num = shell_strtol(argv[1], 10, &ret);
207+
if (ret != 0) {
208+
shell_error(shell, "Invalid <img_num> argument");
209+
return -EINVAL;
210+
}
211+
ret = boot_write_img_confirmed_multi(img_num);
212+
213+
if (ret < 0) {
214+
shell_error(shell, "Failed to confirm current MCUBOOT image: %d", ret);
215+
return ret;
216+
}
217+
218+
return 0;
219+
}
220+
#endif
221+
189222
/* Define the dfu_target subcommand group */
190223
SHELL_STATIC_SUBCMD_SET_CREATE(dfu_multi_image_cmds,
191224
SHELL_CMD(write, NULL,
@@ -198,10 +231,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE(dfu_multi_image_cmds,
198231
SHELL_CMD(schedule_update, NULL, "Schedule update for the images in the uploaded package.",
199232
cmd_dfu_multi_image_schedule_update),
200233
SHELL_CMD(reset, NULL, "Reset the dfu_multi_image state as well as all the underlying "
201-
"dfu_target states", cmd_dfu_multi_image_reset),
234+
"dfu_target states", cmd_dfu_multi_image_reset),
202235
SHELL_CMD(full_update, NULL,
203-
"Perform all the steps to fully update the firmware from the NVM buffer",
204-
cmd_dfu_multi_image_full_update),
236+
"Perform all the steps to fully update the firmware from the NVM buffer",
237+
cmd_dfu_multi_image_full_update),
238+
#ifndef CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY
239+
SHELL_CMD(mcuboot_confirm, NULL, "Confirm one of the current MCUBOOT images",
240+
cmd_dfu_multi_image_mcuboot_confirm),
241+
#endif
205242
SHELL_SUBCMD_SET_END
206243
);
207244

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
17
set(empty_net_core_EXTRA_ZEPHYR_MODULES ${CMAKE_CURRENT_LIST_DIR}/modules/net_build_time_log CACHE INTERNAL "")

samples/dfu/dfu_multi_image/sysbuild.conf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ SB_CONFIG_BOOTLOADER_MCUBOOT=y
88
SB_CONFIG_DFU_MULTI_IMAGE_PACKAGE_BUILD=y
99
SB_CONFIG_DFU_MULTI_IMAGE_PACKAGE_APP=y
1010
SB_CONFIG_DFU_MULTI_IMAGE_PACKAGE_NET=y
11-
SB_CONFIG_DFU_MULTI_IMAGE_PACKAGE_MCUBOOT=y
12-
# Simulteanous update is performed - test is not supported
13-
SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y
1411

1512
# Radio core build and update enable
16-
1713
SB_CONFIG_NETCORE_EMPTY=y
18-
19-
# nRF53 specific
20-
SB_CONFIG_MCUBOOT_NRF53_MULTI_IMAGE_UPDATE=y
21-
SB_CONFIG_SECURE_BOOT_NETCORE=y
22-
SB_CONFIG_NETCORE_APP_UPDATE=y

samples/dfu/dfu_multi_image/sysbuild/empty_net_core/boards/nrf5340dk_nrf5340_cpunet.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include "../../nrf54h20dk_nrf54h20_memory_map.dtsi"
8+
9+
slot0_partition: &cpurad_slot0_partition {
10+
label = "image-0";
11+
};
12+
13+
slot1_partition: &cpurad_slot1_partition {
14+
label = "image-1";
15+
};

0 commit comments

Comments
 (0)