Skip to content

Commit f65122f

Browse files
ahasztagrlubos
authored andcommitted
dfu: Added support for dfu_target with nRF54H20
This commit introduces the changes required to support dfu target with nRF54H20. The dfu_target sample is also extended. Signed-off-by: Artur Hadasz <[email protected]>
1 parent fc6234a commit f65122f

File tree

6 files changed

+72
-4
lines changed

6 files changed

+72
-4
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@
784784
/subsys/debug/ @nordic-krch
785785
/subsys/debug/coredump/ @nrfconnect/ncs-protocols-serialization
786786
/subsys/dfu/ @nrfconnect/ncs-pluto
787+
/subsys/dfu/dfu_target/ @nrfconnect/ncs-pluto @nrfconnect/ncs-charon
787788
/subsys/dfu/dfu_multi_image/ @Damian-Nordic @nrfconnect/ncs-charon
788789
/subsys/dm/ @nrfconnect/ncs-si-muffin
789790
/subsys/dult/ @nrfconnect/ncs-si-bluebagel

samples/dfu/dfu_target/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ After programming the sample to your development kit, perform the following step
7575
+===================+==================+
7676
| nRF52840 DK | ``0xa8000`` |
7777
+-------------------+------------------+
78+
| nRF54H20 DK | ``0xe092000`` |
79+
+-------------------+------------------+
7880

7981
#. Upload the second version of the image to the device using ``nrfutil device``:
8082

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+
/* This sample does not use the radio core, so the radio partition ca be reused */
8+
/delete-node/ &cpurad_slot0_partition;
9+
10+
/ {
11+
aliases {
12+
dfu-target-helper = &dfu_target_helper_partition;
13+
};
14+
};
15+
16+
&mram1x {
17+
partitions {
18+
dfu_target_helper_partition: partition@92000 {
19+
label = "helper";
20+
reg = <0x92000 DT_SIZE_K(328)>;
21+
};
22+
};
23+
};

samples/dfu/dfu_target/sample.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ sample:
88
description: DFU target sample application
99
name: dfu_target sample
1010
common:
11-
platform_allow: nrf52840dk/nrf52840
11+
platform_allow:
12+
- nrf52840dk/nrf52840
13+
- nrf54h20dk/nrf54h20/cpuapp
1214
build_only: true
1315
sysbuild: true
1416
tests:
@@ -18,3 +20,4 @@ tests:
1820
- ci_samples_dfu
1921
integration_platforms:
2022
- nrf52840dk/nrf52840
23+
- nrf54h20dk/nrf54h20/cpuapp

samples/dfu/dfu_target/src/dfu_target_shell.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
#include <dfu/dfu_target_mcuboot.h>
1515
#include <zephyr/dfu/mcuboot.h>
1616

17+
#ifdef CONFIG_PARTITION_MANAGER_ENABLED
1718
#include <pm_config.h>
19+
#endif
1820

1921
#define STREAM_BUF_SIZE 256
2022

2123
#ifdef CONFIG_PARTITION_MANAGER_ENABLED
2224
#define DFU_TARGET_HELPER_ADDRESS PM_DFU_TARGET_HELPER_ADDRESS
2325
#define DFU_TARGET_HELPER_SIZE PM_DFU_TARGET_HELPER_SIZE
2426
#else
25-
#define DFU_TARGET_HELPER_ADDRESS DT_REG_ADDR(DT_ALIAS(dfu_target_helper))
27+
#define DFU_TARGET_HELPER_CONTAINER_ADDRESS DT_REG_ADDR(DT_GPARENT(DT_ALIAS(dfu_target_helper)))
28+
#define DFU_TARGET_HELPER_OFFSET DT_REG_ADDR(DT_ALIAS(dfu_target_helper))
29+
#define DFU_TARGET_HELPER_ADDRESS ((uint32_t) DFU_TARGET_HELPER_CONTAINER_ADDRESS + \
30+
DFU_TARGET_HELPER_OFFSET)
2631
#define DFU_TARGET_HELPER_SIZE DT_REG_SIZE(DT_ALIAS(dfu_target_helper))
2732
#endif
2833

subsys/dfu/dfu_target/src/dfu_target_mcuboot.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
#include <string.h>
1818

1919
#include <zephyr/kernel.h>
20+
#ifdef CONFIG_PARTITION_MANAGER_ENABLED
2021
#include <pm_config.h>
22+
#else
23+
#include <zephyr/storage/flash_map.h>
24+
#endif
2125
#include <zephyr/logging/log.h>
2226
#include <zephyr/dfu/mcuboot.h>
2327
#include <dfu/dfu_target.h>
@@ -31,6 +35,8 @@ LOG_MODULE_REGISTER(dfu_target_mcuboot, CONFIG_DFU_TARGET_LOG_LEVEL);
3135

3236
#define IS_ALIGNED_32(POINTER) (((uintptr_t)(const void *)(POINTER)) % 4 == 0)
3337

38+
#ifdef CONFIG_PARTITION_MANAGER_ENABLED
39+
3440
#define _MB_SEC_PAT(i, x) PM_MCUBOOT_SECONDARY_ ## i ## _ ## x
3541

3642
#define _MB_SEC_PAT_STRING(i, x) STRINGIFY(PM_MCUBOOT_SECONDARY_ ## i ## _ ## x)
@@ -44,8 +50,6 @@ LOG_MODULE_REGISTER(dfu_target_mcuboot, CONFIG_DFU_TARGET_LOG_LEVEL);
4450

4551
#define _MB_SEC_LA(i, _) _H_MB_SEC_LA(i)
4652

47-
#define _STR_TARGET_NAME(i, _) STRINGIFY(MCUBOOT##i)
48-
4953
#ifdef PM_MCUBOOT_SECONDARY_2_ID
5054
#define TARGET_IMAGE_COUNT 3
5155
#elif defined(PM_MCUBOOT_SECONDARY_1_ID)
@@ -62,6 +66,36 @@ LOG_MODULE_REGISTER(dfu_target_mcuboot, CONFIG_DFU_TARGET_LOG_LEVEL);
6266
#define PM_MCUBOOT_SECONDARY_0_NAME STRINGIFY(PM_MCUBOOT_SECONDARY_NAME)
6367
#define PM_MCUBOOT_SECONDARY_0_DEV PM_MCUBOOT_SECONDARY_DEV
6468

69+
#else /* CONFIG_PARTITION_MANAGER_ENABLED */
70+
71+
/**
72+
* These definitions are named to align with those used when Partition Manager
73+
* is enabled, ensuring compatibility for use in the array definitions below.
74+
*/
75+
76+
/**
77+
* The labels are defined: slot1_partition for image 0, slot3_partition for image 1, etc.
78+
*/
79+
#define SEC_PAT_NODELABEL(i) UTIL_CAT(slot, UTIL_CAT(UTIL_INC(UTIL_X2(i)), _partition))
80+
81+
#define SEC_PAT_ADDRESS(i) FIXED_PARTITION_OFFSET(SEC_PAT_NODELABEL(i))
82+
83+
#define SEC_PAT_SIZE(i) FIXED_PARTITION_SIZE(SEC_PAT_NODELABEL(i))
84+
85+
#define _MB_SEC_PAT(i, x) UTIL_CAT(SEC_PAT_, x)(i)
86+
87+
/* Ignore the 'x' parameter, it is needed for compatibility with Partition Manager scenarios. */
88+
#define _MB_SEC_PAT_DEV(i, x) FIXED_PARTITION_DEVICE(SEC_PAT_NODELABEL(i))
89+
90+
/* Ignore the 'x' parameter, it is needed for compatibility with Partition Manager scenarios. */
91+
#define _MB_SEC_PAT_STRING(i, x) STRINGIFY(SEC_PAT_NODELABEL(i))
92+
93+
#define TARGET_IMAGE_COUNT CONFIG_UPDATEABLE_IMAGE_NUMBER
94+
95+
#endif /* CONFIG_PARTITION_MANAGER_ENABLED */
96+
97+
#define _STR_TARGET_NAME(i, _) STRINGIFY(MCUBOOT##i)
98+
6599
static const size_t secondary_size[] = {
66100
LIST_DROP_EMPTY(LISTIFY(TARGET_IMAGE_COUNT, _MB_SEC_PAT, (,), SIZE))
67101
};

0 commit comments

Comments
 (0)