Skip to content

Commit 5f8a969

Browse files
SylwesterKonczyknordicjm
authored andcommitted
suit: manifest-controlled variables
Now manifests may declare MFST_VAR components Ref: NCSDK-30530 Signed-off-by: Sylwester Konczyk <[email protected]>
1 parent cca916a commit 5f8a969

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

subsys/suit/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ config SUIT_DFU_CANDIDATE_PROCESSING_FULL
8383
imply SUIT_MEMPTR_STORAGE
8484
imply SUIT_PLATFORM
8585
imply SUIT_PROCESSOR
86+
imply SUIT_MANIFEST_VARIABLES
8687
imply SUIT_MPI_GENERATE
8788
imply SUIT_SINK_SELECTOR
8889

subsys/suit/platform/include/suit_platform_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ typedef enum {
5050
* be stored, ready for installation.
5151
*/
5252
SUIT_COMPONENT_TYPE_CACHE_POOL,
53+
54+
/** Manifest-accessible variables.
55+
*/
56+
SUIT_COMPONENT_TYPE_MFST_VAR,
57+
5358
} suit_component_type_t;
5459

5560
/** Set the pointer to the implementation-specific data. */

subsys/suit/platform/sdfw/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ zephyr_library_link_libraries_ifdef(CONFIG_SUIT_AUTHENTICATE suit_mci)
4545
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_PLAT_CHECK_COMPONENT_COMPATIBILITY suit_mci)
4646
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_STREAM_FILTER_DECRYPT suit_stream_filters_interface)
4747
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_EVENTS suit_events)
48-
48+
zephyr_library_link_libraries_ifdef(CONFIG_SUIT_MANIFEST_VARIABLES suit_manifest_variables)
4949

5050
zephyr_library_link_libraries(suit_sdfw_platform)
5151
zephyr_library_link_libraries(suit_utils)

subsys/suit/platform/sdfw/src/suit_plat_component_compatibility.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@
88
#include <suit_plat_decode_util.h>
99
#include <suit_platform_internal.h>
1010
#include <suit_storage_mpi.h>
11+
#include <zephyr/logging/log.h>
12+
13+
#ifdef CONFIG_SUIT_MANIFEST_VARIABLES
14+
#include <suit_manifest_variables.h>
15+
#endif /* CONFIG_SUIT_MANIFEST_VARIABLES */
1116

1217
/* -1 indicates no boot capability for given cpu id */
1318
#define NO_BOOT_CAPABILITY_CPU_ID 255
1419

20+
LOG_MODULE_REGISTER(suit_plat_component_compat, CONFIG_SUIT_LOG_LEVEL);
21+
1522
int suit_plat_component_compatibility_check(const suit_manifest_class_id_t *class_id,
1623
struct zcbor_string *component_id)
1724
{
@@ -36,6 +43,7 @@ int suit_plat_component_compatibility_check(const suit_manifest_class_id_t *clas
3643
}
3744

3845
if (suit_plat_decode_component_type(component_id, &type) != SUIT_PLAT_SUCCESS) {
46+
LOG_ERR("Unrecognized component type");
3947
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
4048
}
4149

@@ -123,6 +131,26 @@ int suit_plat_component_compatibility_check(const suit_manifest_class_id_t *clas
123131

124132
break;
125133

134+
#ifdef CONFIG_SUIT_MANIFEST_VARIABLES
135+
136+
case SUIT_COMPONENT_TYPE_MFST_VAR:
137+
138+
uint32_t val;
139+
140+
if (suit_plat_decode_component_number(component_id, &number) != SUIT_PLAT_SUCCESS) {
141+
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
142+
}
143+
144+
/* Let's check if given component is supported by reading out its content
145+
*/
146+
if (suit_mfst_var_get(number, &val) != SUIT_PLAT_SUCCESS) {
147+
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
148+
}
149+
150+
break;
151+
152+
#endif /* CONFIG_SUIT_MANIFEST_VARIABLES */
153+
126154
default:
127155
return SUIT_ERR_UNSUPPORTED_COMPONENT_ID;
128156
}

subsys/suit/utils/src/suit_plat_decode_util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ suit_plat_err_t suit_plat_decode_component_type(struct zcbor_string *component_i
8484
} else if ((tmp.len == strlen("CACHE_POOL")) &&
8585
(memcmp(tmp.value, "CACHE_POOL", tmp.len) == 0)) {
8686
*type = SUIT_COMPONENT_TYPE_CACHE_POOL;
87+
} else if ((tmp.len == strlen("MFST_VAR")) &&
88+
(memcmp(tmp.value, "MFST_VAR", tmp.len) == 0)) {
89+
*type = SUIT_COMPONENT_TYPE_MFST_VAR;
8790
} else {
8891
*type = SUIT_COMPONENT_TYPE_UNSUPPORTED;
8992
return SUIT_PLAT_ERR_CBOR_DECODING;

0 commit comments

Comments
 (0)