Skip to content

Commit 2e87c51

Browse files
committed
suit: Verify usage of SUIT IPUCs in dfu_target
Verify that it is possible to push IPUC_based updates using DFU target module. Ref: NCSDK-NONE Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
1 parent e5afc47 commit 2e87c51

File tree

8 files changed

+663
-6
lines changed

8 files changed

+663
-6
lines changed

subsys/dfu/dfu_target/src/dfu_target_suit.c

+45-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#endif
1616
#include <dfu/suit_dfu.h>
1717

18+
#ifdef CONFIG_FLASH_IPUC
19+
#include <drivers/flash/flash_ipuc.h>
20+
#endif /* CONFIG_FLASH_IPUC */
21+
1822
LOG_MODULE_REGISTER(dfu_target_suit, CONFIG_DFU_TARGET_LOG_LEVEL);
1923

2024
#define IS_ALIGNED_32(POINTER) (((uintptr_t)(const void *)(POINTER)) % 4 == 0)
@@ -59,19 +63,40 @@ int dfu_target_suit_init(size_t file_size, int img_num, dfu_target_callback_t cb
5963
return -ENODEV;
6064
}
6165

66+
device_info.fdev = NULL;
6267
if (ENVELOPE_IMAGE_NUMBER == img_num) {
6368
/* Get info about dfu_partition to store the envelope */
6469
err = suit_dfu_partition_device_info_get(&device_info);
6570
} else {
71+
#ifdef CONFIG_FLASH_IPUC
72+
device_info.partition_offset = 0;
73+
device_info.erase_block_size = 1;
74+
device_info.write_block_size = 1;
75+
device_info.fdev = flash_image_ipuc_create(img_num, NULL, NULL,
76+
(uintptr_t *)&device_info.mapped_address,
77+
&device_info.partition_size);
78+
if (device_info.fdev != NULL) {
79+
LOG_INF("Found IPUC for image %d (0x%lx, 0x%x)", img_num,
80+
(uintptr_t)device_info.mapped_address, device_info.partition_size);
81+
}
82+
#endif /* CONFIG_FLASH_IPUC */
6683
#ifdef CONFIG_DFU_TARGET_SUIT_CACHE_PROCESSING
6784
/* Cache partitions ids starts from 0, whereas image number 0 is reserved for
6885
* dfu_partition. Decrease img_num value by 1 to reach the correct DFU cache
6986
* partition id.
7087
*/
71-
err = suit_dfu_cache_rw_device_info_get(img_num - 1, &device_info);
72-
#else
73-
return -ENOTSUP;
74-
#endif
88+
if (device_info.fdev == NULL) {
89+
err = suit_dfu_cache_rw_device_info_get(img_num - 1, &device_info);
90+
if (device_info.fdev != NULL) {
91+
LOG_INF("Found cache pool %d (0x%lx, 0x%x)", img_num - 1,
92+
(uintptr_t)device_info.mapped_address,
93+
device_info.partition_size);
94+
}
95+
}
96+
#endif /* CONFIG_DFU_TARGET_SUIT_CACHE_PROCESSING */
97+
if (device_info.fdev == NULL) {
98+
return -ENOTSUP;
99+
}
75100
}
76101

77102
if (err != SUIT_PLAT_SUCCESS) {
@@ -140,6 +165,9 @@ int dfu_target_suit_write(const void *const buf, size_t len)
140165

141166
int dfu_target_suit_done(bool successful)
142167
{
168+
#ifdef CONFIG_FLASH_IPUC
169+
struct stream_flash_ctx *stream = dfu_target_stream_get_stream();
170+
#endif /* CONFIG_FLASH_IPUC */
143171
stream_flash_in_use = false;
144172

145173
int err = dfu_target_stream_done(successful);
@@ -156,6 +184,11 @@ int dfu_target_suit_done(bool successful)
156184
LOG_ERR("suit_dfu_candidate_envelope_stored error %d", err);
157185
return err;
158186
}
187+
#ifdef CONFIG_FLASH_IPUC
188+
} else {
189+
flash_image_ipuc_release(image_num);
190+
stream->fdev = NULL;
191+
#endif /* CONFIG_FLASH_IPUC */
159192
}
160193

161194
if (successful) {
@@ -187,6 +220,9 @@ int dfu_target_suit_schedule_update(int img_num)
187220

188221
int dfu_target_suit_reset(void)
189222
{
223+
#ifdef CONFIG_FLASH_IPUC
224+
struct stream_flash_ctx *stream = dfu_target_stream_get_stream();
225+
#endif /* CONFIG_FLASH_IPUC */
190226
int rc = dfu_target_stream_reset();
191227

192228
if (rc != 0) {
@@ -196,6 +232,11 @@ int dfu_target_suit_reset(void)
196232

197233
int err = suit_dfu_cleanup();
198234

235+
#ifdef CONFIG_FLASH_IPUC
236+
flash_image_ipuc_release(image_num);
237+
stream->fdev = NULL;
238+
#endif /* CONFIG_FLASH_IPUC */
239+
199240
stream_flash_in_use = false;
200241
stream_buf_bytes = 0;
201242
image_num = 0;

tests/subsys/dfu/dfu_target/suit/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@ target_sources(app PRIVATE ${app_sources})
1616
target_include_directories(app
1717
PRIVATE
1818
${ZEPHYR_NRF_MODULE_DIR}/subsys/dfu/include
19+
${ZEPHYR_NRF_MODULE_DIR}/subsys/suit/ipuc/include
20+
${ZEPHYR_NRF_MODULE_DIR}/subsys/suit/memory_layout/include
1921
"src"
2022
)
23+
24+
zephyr_compile_definitions(CONFIG_SOC_NRF54H20_CPUAPP)

tests/subsys/dfu/dfu_target/suit/Kconfig

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
menuconfig TESTS_SUIT_DFU_TARGET_SUIT_CACHE_PROCESSING
88
bool "Run tests for processing of SUIT cache partition by the SUIT DFU target"
99
imply DFU_TARGET_SUIT_CACHE_PROCESSING
10-
default n
1110

1211
menuconfig TESTS_SUIT_DFU_TARGET_SUIT_SINGLE_PARTITION
1312
bool "Run tests for processing of the dfu_partition only by the DFU target"
14-
default n
13+
14+
menuconfig TESTS_SUIT_DFU_TARGET_SUIT_CACHE_IPUC_PROCESSING
15+
bool "Run tests for processing of SUIT cache IPUC-based partition by the SUIT DFU target"
16+
imply DFU_TARGET_SUIT_CACHE_PROCESSING
17+
18+
config SUIT_CACHE_SDFW_IPUC_ID
19+
default 10
20+
depends on TESTS_SUIT_DFU_TARGET_SUIT_CACHE_IPUC_PROCESSING
1521

1622
source "Kconfig.zephyr"

tests/subsys/dfu/dfu_target/suit/boards/native_sim.overlay

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
dfu_cache_partition_3: partition@160000 {
2626
reg = <0x160000 DT_SIZE_K(128)>;
2727
};
28+
29+
dfu_target_img_31: cpurad_slot_a_partition: partition@80000 {
30+
reg = <0x80000 DT_SIZE_K(4)>;
31+
};
32+
33+
dfu_target_img_21: cpuapp_slot_a_partition: partition@190000 {
34+
reg = <0x190000 DT_SIZE_K(4)>;
35+
};
2836
};
2937
};
3038

tests/subsys/dfu/dfu_target/suit/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
reg = <0x160000 DT_SIZE_K(128)>;
4444
};
4545

46+
dfu_target_img_31: cpurad_slot_a_partition: partition@80000 {
47+
reg = <0x80000 DT_SIZE_K(4)>;
48+
};
49+
50+
dfu_target_img_21: cpuapp_slot_a_partition: partition@190000 {
51+
reg = <0x190000 DT_SIZE_K(4)>;
52+
};
53+
4654
storage_partition: partition@1df000 {
4755
reg = < 0x1df000 0x6000 >;
4856
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_TESTS_SUIT_DFU_TARGET_SUIT_CACHE_IPUC_PROCESSING=y
8+
CONFIG_SUIT_DFU_CANDIDATE_PROCESSING_PUSH_TO_CACHE=y
9+
10+
CONFIG_FLASH_IPUC=y
11+
CONFIG_FLASH_IPUC_COUNT=5
12+
CONFIG_SUIT_IPUC=y
13+
CONFIG_SUIT_CACHE_SDFW_IPUC=y
14+
CONFIG_SUIT_CACHE_APP_IPUC=y

0 commit comments

Comments
 (0)