Skip to content

Commit 91f47da

Browse files
tomchydegjorva
authored andcommitted
suit: Add support for MFST_VAR in suit_plat_write
Add support for writing content into MFST_VAR components. Ref: NCSDK-30807 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent b9a4027 commit 91f47da

File tree

10 files changed

+349
-66
lines changed

10 files changed

+349
-66
lines changed

subsys/suit/platform/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ zephyr_library_sources(src/suit_plat_commands.c)
1616
zephyr_library_sources(src/suit_plat_version.c)
1717
zephyr_library_sources(src/suit_plat_fetch.c)
1818
zephyr_library_sources(src/suit_plat_retrieve_manifest.c)
19+
zephyr_library_sources(src/suit_plat_write.c)
1920
zephyr_library_sources_ifdef(CONFIG_SUIT_CHECK_IMAGE_MATCH src/suit_plat_check_image_match.c)
2021
zephyr_library_sources_ifdef(CONFIG_SUIT_MEMPTR_STORAGE src/suit_plat_memptr_size_update.c)
2122
zephyr_library_sources(src/suit_plat_error_convert.c)
@@ -32,6 +33,7 @@ zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM suit_stream_sources_inter
3233
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MEMPTR_STORAGE suit_memptr_storage_interface)
3334
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_SINK_SELECTOR suit_sink_selector_interface)
3435
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM_FILTER_DECRYPT suit_stream_filters_interface)
36+
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_manifest_variables)
3537

3638
if(CONFIG_SUIT_PLATFORM_VARIANT_APP)
3739
add_subdirectory(app)

subsys/suit/platform/app/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ zephyr_library()
1414
zephyr_library_sources(src/suit_plat_swap.c)
1515
zephyr_library_sources(src/suit_plat_fetch_app_specific.c)
1616
zephyr_library_sources(src/suit_plat_copy.c)
17-
zephyr_library_sources(src/suit_plat_write.c)
17+
zephyr_library_sources(src/suit_plat_write_app_specific.c)
1818
zephyr_library_sources(src/suit_plat_retrieve_manifest_app_specific.c)
1919
zephyr_library_sources(src/suit_plat_version_app_specific.c)
2020
zephyr_library_sources_ifdef(CONFIG_SUIT_CHECK_IMAGE_MATCH src/suit_plat_check_image_match_app_specific.c)

subsys/suit/platform/app/src/suit_plat_write.c

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <suit_plat_write_domain_specific.h>
8+
9+
bool suit_plat_write_domain_specific_is_type_supported(suit_component_type_t component_type)
10+
{
11+
return false;
12+
}
13+
14+
int suit_plat_check_write_domain_specific(suit_component_t dst_handle,
15+
suit_component_type_t dst_component_type,
16+
struct zcbor_string *content,
17+
struct zcbor_string *manifest_component_id,
18+
struct suit_encryption_info *enc_info)
19+
{
20+
return SUIT_ERR_UNSUPPORTED_COMMAND;
21+
}
22+
23+
int suit_plat_write_domain_specific(suit_component_t dst_handle,
24+
suit_component_type_t dst_component_type,
25+
struct zcbor_string *content,
26+
struct zcbor_string *manifest_component_id,
27+
struct suit_encryption_info *enc_info)
28+
{
29+
return SUIT_ERR_UNSUPPORTED_COMMAND;
30+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef SUIT_PLAT_WRITE_DOMAIN_SPECIFIC_H__
8+
#define SUIT_PLAT_WRITE_DOMAIN_SPECIFIC_H__
9+
10+
#include <stdint.h>
11+
#include <suit_types.h>
12+
#include <suit_platform_internal.h>
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
/**
19+
* @brief Return destination component type supported by suit_plat_write for the current domain.
20+
*/
21+
bool suit_plat_write_domain_specific_is_type_supported(suit_component_type_t component_type);
22+
23+
/**
24+
* @brief Domain specific part of the core part of the suit_plat_check_write function.
25+
*/
26+
int suit_plat_check_write_domain_specific(suit_component_t dst_handle,
27+
suit_component_type_t dst_component_type,
28+
struct zcbor_string *content,
29+
struct zcbor_string *manifest_component_id,
30+
struct suit_encryption_info *enc_info);
31+
32+
/**
33+
* @brief Domain specific part of the core part of the suit_plat_write function.
34+
*/
35+
int suit_plat_write_domain_specific(suit_component_t dst_handle,
36+
suit_component_type_t dst_component_type,
37+
struct zcbor_string *content,
38+
struct zcbor_string *manifest_component_id,
39+
struct suit_encryption_info *enc_info);
40+
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
45+
#endif /* SUIT_PLAT_FETCH_DOMAIN_SPECIFIC_H__ */

subsys/suit/platform/sdfw/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ zephyr_library()
1414
zephyr_library_sources(src/suit_plat_swap.c)
1515
zephyr_library_sources(src/suit_plat_fetch_sdfw_specific.c)
1616
zephyr_library_sources(src/suit_plat_copy.c)
17-
zephyr_library_sources(src/suit_plat_write.c)
17+
zephyr_library_sources(src/suit_plat_write_sdfw_specific.c)
1818
zephyr_library_sources(src/suit_plat_retrieve_manifest_sdfw_specific.c)
1919
zephyr_library_sources(src/suit_plat_version_sdfw_specific.c)
2020
zephyr_library_sources_ifdef(CONFIG_SUIT_DIGEST_CACHE src/suit_plat_digest_cache.c)

subsys/suit/platform/sdfw/src/suit_plat_write.c renamed to subsys/suit/platform/sdfw/src/suit_plat_write_sdfw_specific.c

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <zephyr/logging/log.h>
88
#include <stdbool.h>
9-
#include <suit_platform.h>
9+
#include <suit_plat_write_domain_specific.h>
1010
#include <suit_plat_decode_util.h>
1111
#include <suit_plat_error_convert.h>
1212
#include <suit_platform_internal.h>
@@ -30,15 +30,28 @@
3030
#include <suit_decrypt_filter.h>
3131
#endif /* CONFIG_SUIT_STREAM_FILTER_DECRYPT */
3232

33-
LOG_MODULE_REGISTER(suit_plat_write, CONFIG_SUIT_LOG_LEVEL);
33+
LOG_MODULE_DECLARE(suit_plat_write, CONFIG_SUIT_LOG_LEVEL);
3434

35-
int suit_plat_check_write(suit_component_t dst_handle, struct zcbor_string *content,
36-
struct zcbor_string *manifest_component_id,
37-
struct suit_encryption_info *enc_info)
35+
bool suit_plat_write_domain_specific_is_type_supported(suit_component_type_t component_type)
36+
{
37+
#ifdef CONFIG_SUIT_STREAM
38+
/* Check if destination component type is supported */
39+
if (component_type == SUIT_COMPONENT_TYPE_MEM) {
40+
return true;
41+
}
42+
#endif /* CONFIG_SUIT_STREAM */
43+
44+
return false;
45+
}
46+
47+
int suit_plat_check_write_domain_specific(suit_component_t dst_handle,
48+
suit_component_type_t dst_component_type,
49+
struct zcbor_string *content,
50+
struct zcbor_string *manifest_component_id,
51+
struct suit_encryption_info *enc_info)
3852
{
3953
#ifdef CONFIG_SUIT_STREAM
4054
struct stream_sink dst_sink;
41-
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
4255
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
4356
int ret = SUIT_SUCCESS;
4457

@@ -50,16 +63,8 @@ int suit_plat_check_write(suit_component_t dst_handle, struct zcbor_string *cont
5063
return suit_plat_err_to_processor_err_convert(SUIT_PLAT_ERR_INVAL);
5164
}
5265

53-
/* Get destination component type based on component handle*/
54-
ret = suit_plat_component_type_get(dst_handle, &dst_component_type);
55-
if (ret != SUIT_SUCCESS) {
56-
LOG_ERR("Failed to decode destination component type");
57-
return ret;
58-
}
59-
6066
/* Check if destination component type is supported */
61-
if ((dst_component_type != SUIT_COMPONENT_TYPE_MEM) &&
62-
(dst_component_type != SUIT_COMPONENT_TYPE_SOC_SPEC)) {
67+
if (dst_component_type != SUIT_COMPONENT_TYPE_MEM) {
6368
LOG_ERR("Unsupported destination component type");
6469
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
6570
}
@@ -110,13 +115,14 @@ int suit_plat_check_write(suit_component_t dst_handle, struct zcbor_string *cont
110115
#endif /* CONFIG_SUIT_STREAM */
111116
}
112117

113-
int suit_plat_write(suit_component_t dst_handle, struct zcbor_string *content,
114-
struct zcbor_string *manifest_component_id,
115-
struct suit_encryption_info *enc_info)
118+
int suit_plat_write_domain_specific(suit_component_t dst_handle,
119+
suit_component_type_t dst_component_type,
120+
struct zcbor_string *content,
121+
struct zcbor_string *manifest_component_id,
122+
struct suit_encryption_info *enc_info)
116123
{
117124
#ifdef CONFIG_SUIT_STREAM
118125
struct stream_sink dst_sink;
119-
suit_component_type_t dst_component_type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
120126
suit_plat_err_t plat_ret = SUIT_PLAT_SUCCESS;
121127
int ret = SUIT_SUCCESS;
122128

@@ -128,16 +134,8 @@ int suit_plat_write(suit_component_t dst_handle, struct zcbor_string *content,
128134
return suit_plat_err_to_processor_err_convert(SUIT_PLAT_ERR_INVAL);
129135
}
130136

131-
/* Get destination component type based on component handle*/
132-
ret = suit_plat_component_type_get(dst_handle, &dst_component_type);
133-
if (ret != SUIT_SUCCESS) {
134-
LOG_ERR("Failed to decode destination component type");
135-
return ret;
136-
}
137-
138137
/* Check if destination component type is supported */
139-
if ((dst_component_type != SUIT_COMPONENT_TYPE_MEM) &&
140-
(dst_component_type != SUIT_COMPONENT_TYPE_SOC_SPEC)) {
138+
if (dst_component_type != SUIT_COMPONENT_TYPE_MEM) {
141139
LOG_ERR("Unsupported destination component type");
142140
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
143141
}

0 commit comments

Comments
 (0)