Skip to content

Commit e065a2a

Browse files
committed
suit: Pass manifest component ID to set size
Pass manifest component ID while setting component size parameter, so the IPUC can be declared with the corresponding manifest role. Ref: NCSDK-31343 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 61b8072 commit e065a2a

File tree

16 files changed

+355
-34
lines changed

16 files changed

+355
-34
lines changed

subsys/suit/platform/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ zephyr_library_link_libraries_ifdef(CONFIG_SUIT_SINK_SELECTOR suit_sink_selector
3737
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM_FILTER_DECRYPT suit_stream_filters_interface)
3838
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_manifest_variables)
3939
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_IPUC suit_ipuc)
40+
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STORAGE suit_storage_interface)
4041

4142
if(CONFIG_SUIT_PLATFORM_VARIANT_APP)
4243
add_subdirectory(app)

subsys/suit/platform/src/suit_plat_components.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#if defined(CONFIG_SUIT_IPUC) && defined(CONFIG_SUIT_PLATFORM_VARIANT_SDFW)
1414
#include <suit_ipuc_sdfw.h>
15+
#include <suit_storage_mpi.h>
1516
#endif
1617

1718
LOG_MODULE_REGISTER(plat_components, CONFIG_SUIT_LOG_LEVEL);
@@ -215,7 +216,8 @@ int suit_plat_component_id_get(suit_component_t handle, struct zcbor_string **co
215216
return SUIT_SUCCESS;
216217
}
217218

218-
int suit_plat_override_image_size(suit_component_t handle, size_t size)
219+
int suit_plat_override_image_size(suit_component_t handle, size_t size,
220+
struct zcbor_string *manifest_component_id)
219221
{
220222
struct zcbor_string *component_id = NULL;
221223

@@ -233,6 +235,21 @@ int suit_plat_override_image_size(suit_component_t handle, size_t size)
233235
return SUIT_ERR_DECODING;
234236
}
235237

238+
#if defined(CONFIG_SUIT_IPUC) && defined(CONFIG_SUIT_PLATFORM_VARIANT_SDFW)
239+
suit_manifest_class_id_t *class_id = NULL;
240+
suit_manifest_role_t role = SUIT_MANIFEST_UNKNOWN;
241+
242+
if (suit_plat_decode_manifest_class_id(manifest_component_id, &class_id) !=
243+
SUIT_PLAT_SUCCESS) {
244+
LOG_ERR("Component ID is not a manifest class");
245+
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
246+
}
247+
248+
if (suit_storage_mpi_role_get(class_id, &role) != SUIT_PLAT_SUCCESS) {
249+
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
250+
}
251+
#endif
252+
236253
/* Size override is done only for MEM type component */
237254
if (component_type == SUIT_COMPONENT_TYPE_MEM) {
238255
intptr_t run_address;
@@ -277,8 +294,6 @@ int suit_plat_override_image_size(suit_component_t handle, size_t size)
277294

278295
#if defined(CONFIG_SUIT_IPUC) && defined(CONFIG_SUIT_PLATFORM_VARIANT_SDFW)
279296
if (size == 0) {
280-
suit_manifest_role_t role = SUIT_MANIFEST_UNKNOWN;
281-
282297
suit_ipuc_sdfw_declare(handle, role);
283298
} else {
284299
suit_ipuc_sdfw_revoke(handle);

tests/subsys/suit/fetch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
# Include and define MOCK_* Kconfigs
88
rsource "../mocks/Kconfig"
9+
rsource "../tests/Kconfig"
910

1011
source "Kconfig.zephyr"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_FLASH_SIMULATOR=y
8+
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&flash0 {
8+
partitions {
9+
compatible = "fixed-partitions";
10+
#address-cells = <1>;
11+
#size-cells = <1>;
12+
13+
/* Use the last 48KB of NVM as suit storage. */
14+
suit_storage: partition@f4000 {
15+
reg = <0xf4000 DT_SIZE_K(48)>;
16+
};
17+
};
18+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_FLASH_SIMULATOR=y
8+
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&flash0 {
8+
partitions {
9+
compatible = "fixed-partitions";
10+
#address-cells = <1>;
11+
#size-cells = <1>;
12+
13+
/* Use the last 48KB of NVM as suit storage. */
14+
suit_storage: partition@f4000 {
15+
reg = <0xf4000 DT_SIZE_K(48)>;
16+
};
17+
};
18+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
&flash0 {
8+
partitions {
9+
compatible = "fixed-partitions";
10+
#address-cells = <1>;
11+
#size-cells = <1>;
12+
13+
/* Use the last 48KB of NVM as suit storage. */
14+
suit_storage: partition@f4000 {
15+
reg = <0xf4000 DT_SIZE_K(48)>;
16+
};
17+
};
18+
};

tests/subsys/suit/fetch/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ CONFIG_FLASH_MAP=y
3030

3131
CONFIG_SUIT_IPUC=y
3232
CONFIG_MOCK_SDFW_ARBITER=y
33+
CONFIG_SUIT_STORAGE=y
3334

3435
CONFIG_SUIT_EXECUTION_MODE=y
3536
CONFIG_SUIT_MCI=y

tests/subsys/suit/ipuc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
# Include and define MOCK_* Kconfigs
88
rsource "../mocks/Kconfig"
9+
rsource "../tests/Kconfig"
910

1011
source "Kconfig.zephyr"

0 commit comments

Comments
 (0)