Skip to content

Commit 3d4f19e

Browse files
e-rknordicjm
authored andcommitted
suit: move envelope creation options to sysbuild Kconfig
Moved Kconfig options that are common or affect all images being built to the sysbuild Kconfig. The new file in sysbuild/Kconfig.suit contains those options. Signed-off-by: Rafał Kuźnia <[email protected]>
1 parent c7bc93b commit 3d4f19e

File tree

9 files changed

+110
-25
lines changed

9 files changed

+110
-25
lines changed

cmake/sysbuild/suit.cmake

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ endfunction()
103103
# 'output_file' - path to output signed envelope
104104
function(suit_sign_envelope input_file output_file)
105105
cmake_path(GET ZEPHYR_NRF_MODULE_DIR PARENT_PATH NRF_DIR_PARENT)
106-
sysbuild_get(CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT KCONFIG)
107-
suit_set_absolute_or_relative_path(${CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT} ${NRF_DIR_PARENT} SIGN_SCRIPT)
106+
suit_set_absolute_or_relative_path(${SB_CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT} ${NRF_DIR_PARENT} SIGN_SCRIPT)
108107
if(NOT EXISTS ${SIGN_SCRIPT})
109-
message(SEND_ERROR "DFU: ${CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT} does not exist. Corrupted configuration?")
108+
message(SEND_ERROR "DFU: ${SB_CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT} does not exist. Corrupted configuration?")
110109
return()
111110
endif()
112111
set_property(
@@ -164,14 +163,23 @@ function(suit_create_package)
164163
set(CORE_ARGS)
165164
set(STORAGE_BOOT_ARGS)
166165

167-
sysbuild_get(CONFIG_SUIT_ENVELOPE_EDITABLE_TEMPLATES_LOCATION IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE_EDITABLE_TEMPLATES_LOCATION KCONFIG)
168-
suit_set_absolute_or_relative_path(${CONFIG_SUIT_ENVELOPE_EDITABLE_TEMPLATES_LOCATION} ${PROJECT_BINARY_DIR} INPUT_TEMPLATES_DIRECTORY)
169-
sysbuild_get(ENVELOPE_SHALL_BE_SIGNED IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE_SIGN KCONFIG)
166+
suit_set_absolute_or_relative_path(${SB_CONFIG_SUIT_ENVELOPE_EDITABLE_TEMPLATES_LOCATION} ${PROJECT_BINARY_DIR} INPUT_TEMPLATES_DIRECTORY)
167+
set(ENVELOPE_SHALL_BE_SIGNED ${SB_CONFIG_SUIT_ENVELOPE_SIGN})
170168
if(NOT DEFINED ENVELOPE_SHALL_BE_SIGNED)
171169
set(ENVELOPE_SHALL_BE_SIGNED FALSE)
172170
endif()
173171

172+
list(APPEND CORE_ARGS
173+
--core sysbuild,,,${CMAKE_BINARY_DIR}/zephyr/.config
174+
)
175+
174176
foreach(image ${IMAGES})
177+
sysbuild_get(GENERATE_LOCAL_ENVELOPE IMAGE ${image} VAR CONFIG_SUIT_LOCAL_ENVELOPE_GENERATE KCONFIG)
178+
if(NOT DEFINED GENERATE_LOCAL_ENVELOPE)
179+
continue()
180+
endif()
181+
unset(GENERATE_LOCAL_ENVELOPE)
182+
175183
sysbuild_get(INPUT_ENVELOPE_JINJA_FILE IMAGE ${image} VAR CONFIG_SUIT_ENVELOPE_TEMPLATE KCONFIG)
176184
sysbuild_get(target IMAGE ${image} VAR CONFIG_SUIT_ENVELOPE_TARGET KCONFIG)
177185
sysbuild_get(BINARY_DIR IMAGE ${image} VAR APPLICATION_BINARY_DIR CACHE)
@@ -185,10 +193,9 @@ function(suit_create_package)
185193
set(BINARY_FILE "${BINARY_FILE}.bin")
186194

187195
list(APPEND CORE_ARGS
188-
--core ${target},${SUIT_ROOT_DIRECTORY}${target}.bin,${BINARY_DIR}/zephyr/edt.pickle
196+
--core ${target},${SUIT_ROOT_DIRECTORY}${target}.bin,${BINARY_DIR}/zephyr/edt.pickle,${BINARY_DIR}/zephyr/.config
189197
)
190198

191-
sysbuild_get(CONFIG_SUIT_ENVELOPE_ROOT_ARTIFACT_NAME IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE_ROOT_ARTIFACT_NAME KCONFIG)
192199
set(ENVELOPE_YAML_FILE ${SUIT_ROOT_DIRECTORY}${target}.yaml)
193200
set(ENVELOPE_SUIT_FILE ${SUIT_ROOT_DIRECTORY}${target}.suit)
194201

@@ -200,14 +207,11 @@ function(suit_create_package)
200207
)
201208
endforeach()
202209

203-
sysbuild_get(INPUT_ROOT_ENVELOPE_JINJA_FILE IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE_ROOT_TEMPLATE KCONFIG)
210+
set(INPUT_ROOT_ENVELOPE_JINJA_FILE ${SB_CONFIG_SUIT_ENVELOPE_ROOT_TEMPLATE})
204211

205212
# create root envelope if defined
206213
if(DEFINED INPUT_ROOT_ENVELOPE_JINJA_FILE AND NOT INPUT_ROOT_ENVELOPE_JINJA_FILE STREQUAL "")
207-
sysbuild_get(ROOT_NAME IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE_ROOT_ARTIFACT_NAME KCONFIG)
208-
if(NOT DEFINED ROOT_NAME OR ROOT_NAME STREQUAL "")
209-
set(ROOT_NAME "root")
210-
endif()
214+
set(ROOT_NAME ${SB_CONFIG_SUIT_ENVELOPE_ROOT_ARTIFACT_NAME})
211215
suit_copy_input_template(${INPUT_TEMPLATES_DIRECTORY} "${INPUT_ROOT_ENVELOPE_JINJA_FILE}" ROOT_ENVELOPE_JINJA_FILE)
212216
suit_check_template_digest(${INPUT_TEMPLATES_DIRECTORY} "${INPUT_ROOT_ENVELOPE_JINJA_FILE}")
213217
set(ROOT_ENVELOPE_YAML_FILE ${SUIT_ROOT_DIRECTORY}${ROOT_NAME}.yaml)
@@ -242,6 +246,13 @@ function(suit_setup_merge)
242246
sysbuild_get(BINARY_DIR IMAGE ${DEFAULT_IMAGE} VAR APPLICATION_BINARY_DIR CACHE)
243247
foreach(image ${IMAGES})
244248
set(ARTIFACTS_TO_MERGE)
249+
250+
sysbuild_get(GENERATE_LOCAL_ENVELOPE IMAGE ${image} VAR CONFIG_SUIT_LOCAL_ENVELOPE_GENERATE KCONFIG)
251+
if(NOT DEFINED GENERATE_LOCAL_ENVELOPE)
252+
continue()
253+
endif()
254+
unset(GENERATE_LOCAL_ENVELOPE)
255+
245256
sysbuild_get(IMAGE_BINARY_DIR IMAGE ${image} VAR APPLICATION_BINARY_DIR CACHE)
246257
sysbuild_get(IMAGE_BINARY_FILE IMAGE ${image} VAR CONFIG_KERNEL_BIN_NAME KCONFIG)
247258
sysbuild_get(IMAGE_TARGET_NAME IMAGE ${image} VAR CONFIG_SUIT_ENVELOPE_TARGET KCONFIG)
@@ -275,8 +286,6 @@ function(suit_setup_merge)
275286
endforeach()
276287
endfunction()
277288

278-
# Enable SUIT envelope generation only if DEFAULT_IMAGE has it enabled.
279-
sysbuild_get(CONFIG_SUIT_ENVELOPE IMAGE ${DEFAULT_IMAGE} VAR CONFIG_SUIT_ENVELOPE KCONFIG)
280-
if(CONFIG_SUIT_ENVELOPE)
289+
if(SB_CONFIG_SUIT_ENVELOPE)
281290
suit_create_package()
282-
endif()
291+
endif()

cmake/sysbuild/suit_utilities.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function(suit_create_envelope input_file output_file create_signature)
7575
--input-file ${input_file}
7676
--output-file ${output_file}
7777
)
78-
if (create_signature)
78+
if (create_signature AND SB_CONFIG_SUIT_ENVELOPE_SIGN_SCRIPT)
7979
suit_sign_envelope(${output_file} ${output_file})
8080
endif()
81-
endfunction()
81+
endfunction()

samples/suit/smp_transfer/prj.conf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@ CONFIG_SUIT=y
2626
CONFIG_MGMT_SUITFU=y
2727
CONFIG_FLASH=y
2828

29-
# Enable SUIT envelope creation
30-
CONFIG_SUIT_ENVELOPE=y
31-
3229
# Extended SUIT commands over USER group
3330
CONFIG_MGMT_SUITFU_GRP_SUIT=y

samples/suit/smp_transfer/sample.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ sample:
88
name: SUIT update through SMP sample
99
description: Sample application that updates firmware using SUIT and SMP protocol
1010
common:
11-
extra_configs:
12-
- CONFIG_SUIT_ENVELOPE_EDITABLE_TEMPLATES_LOCATION="./"
1311
platform_allow: nrf54h20dk/nrf54h20/cpuapp
1412
build_only: true
1513
sysbuild: true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
SB_CONFIG_SUIT_ENVELOPE=y

samples/suit/smp_transfer/sysbuild_bt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7+
SB_CONFIG_SUIT_ENVELOPE=y
78
SB_CONFIG_NETCORE_HCI_IPC=y

sysbuild/Kconfig.suit

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
menu "SUIT"
8+
9+
# 'default y if SOC_SERIES_NRF54HX' to be added when SUIT is to be enabled globally.
10+
menuconfig SUIT_ENVELOPE
11+
bool "Create SUIT envelope"
12+
help
13+
Enable DFU SUIT envelope creation
14+
15+
if SUIT_ENVELOPE
16+
17+
config SUIT_ENVELOPE_SIGN
18+
bool "Sign created SUIT envelope"
19+
help
20+
Sign created SUIT envelope by external script
21+
22+
config SUIT_ENVELOPE_SEQUENCE_NUM
23+
int "Sequence number of the generated SUIT manifest"
24+
range 0 2147483647
25+
default 1
26+
27+
config SUIT_ENVELOPE_ROOT_TEMPLATE
28+
string "Path to the default root envelope template"
29+
default "${ZEPHYR_SUIT_GENERATOR_MODULE_DIR}/ncs/root_with_binary_nordic_top.yaml.jinja2"
30+
help
31+
Path to the default root envelope template, that is used if the application directory does not
32+
contain an input envelope template file.
33+
You can use either absolute or relative path.
34+
In case relative path is used, the build system uses CMAKE_SOURCE_DIR directory.
35+
36+
config SUIT_ENVELOPE_EDITABLE_TEMPLATES_LOCATION
37+
string "Path to the folder with envelope templates"
38+
default "../"
39+
help
40+
Path to the folder containing editable templates used to create binary envelopes.
41+
Input templates are created by the build system during first build from the SUIT_ENVELOPE_DEFAULT_TEMPLATE.
42+
You can use either absolute or relative path.
43+
In case relative path is used, the build system uses CMAKE_SOURCE_DIR directory.
44+
45+
config SUIT_ENVELOPE_SIGN_SCRIPT
46+
string "Location of SUIT sign script"
47+
depends on SUIT_ENVELOPE_SIGN
48+
help
49+
Python script called to sign SUIT envelope.
50+
You can use either absolute or relative path.
51+
In case relative path is used, the build system uses NRF parent directory.
52+
Script need to accept two arguments:
53+
- --input-file <STRING> - location of unsigned envelope in the build system
54+
- --output-file <STRING> - location of signed envelope to create by script
55+
default "modules/lib/suit-generator/ncs/sign_script.py"
56+
57+
config SUIT_ENVELOPE_ROOT_ARTIFACT_NAME
58+
string "Name of the root SUIT artifact."
59+
default "root"
60+
help
61+
Name of the root SUIT artifact.
62+
63+
config SUIT_ENVELOPE_NORDIC_TOP_DIRECTORY
64+
string "Path to the folder with nordic top artifacts"
65+
default ""
66+
help
67+
Path to the folder containing nordic-top.suit envelope.
68+
nordic_top.suit won't be included in the root manifest if value is empty.
69+
70+
endif # SUIT_ENVELOPE
71+
72+
endmenu

sysbuild/Kconfig.sysbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ rsource "Kconfig.mcuboot"
7474
rsource "Kconfig.dfu"
7575
rsource "Kconfig.xip"
7676
rsource "Kconfig.bt_fast_pair"
77+
rsource "Kconfig.suit"

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ manifest:
239239
upstream-sha: c6eaeda5a1c1c5dbb24dce7e027340cb8893a77b
240240
compare-by-default: false
241241
- name: suit-generator
242-
revision: c0165159dac566fafbf67be75d86ca64a34834f0
242+
revision: 1dfb3fa1676c255c9d19a5c159249b5a7e53c476
243243
path: modules/lib/suit-generator
244244
- name: suit-processor
245245
revision: 5603911b75f037dc3822fd95542c3435c0bf812d

0 commit comments

Comments
 (0)