Skip to content

Commit 0b5e80f

Browse files
ahasztagtomchy
authored andcommitted
suit: Integrated nordic binaries pull into build system
This commit allows to build a SUIT envelope prepared for pulling Nordic firmware binaries into the build system. Signed-off-by: Artur Hadasz <[email protected]>
1 parent 16ebce5 commit 0b5e80f

File tree

5 files changed

+86
-3
lines changed

5 files changed

+86
-3
lines changed

cmake/sysbuild/suit.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@ function(suit_create_package)
230230
--core sysbuild,,,${PROJECT_BINARY_DIR}/.config
231231
)
232232

233+
if(SB_CONFIG_SUIT_ENVELOPE_NORDIC_TOP_IN_ROOT)
234+
# Prepare Nordic artifacts for the root SUIT envelope
235+
set(nordic_pull FALSE)
236+
if(SB_CONFIG_SUIT_ENVELOPE_NORDIC_TOP_EXTRACT_PAYLOADS_FOR_PULL)
237+
set(nordic_pull TRUE)
238+
endif()
239+
suit_nordic_artifacts_prepare(
240+
${SB_CONFIG_SUIT_ENVELOPE_NORDIC_TOP_DIRECTORY}
241+
${nordic_pull}
242+
)
243+
endif()
244+
233245
foreach(image ${IMAGES})
234246
unset(target)
235247
unset(encrypt)

cmake/sysbuild/suit_utilities.cmake

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,51 @@ function(suit_copy_artifact_to_output_directory target artifact)
3737
)
3838
endfunction()
3939

40+
function(suit_nordic_artifacts_prepare nordic_top_directory pull)
41+
if(pull)
42+
list(APPEND nordic_extract_args "--input-envelope" "${nordic_top_directory}/nordic_top.suit")
43+
list(APPEND nordic_extract_args "--output-envelope" "nordic_top.suit")
44+
list(APPEND nordic_extract_args "--omit-payload-regex" "(?!.*sec.*\.bin|.*sysctl_v.*\.bin).*")
45+
list(APPEND nordic_extract_args "--dependency-regex" "(#secdom|#sysctrl)")
46+
list(APPEND nordic_extract_args "--payload-file-prefix-to-remove" "file://")
47+
48+
execute_process(
49+
COMMAND ${CMAKE_COMMAND} -E make_directory "nordic_pull_dir"
50+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
51+
)
52+
53+
execute_process(
54+
COMMAND
55+
${PYTHON_EXECUTABLE} ${SUIT_GENERATOR_CLI_SCRIPT}
56+
payload_extract
57+
recursive
58+
${nordic_extract_args}
59+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nordic_pull_dir
60+
)
61+
62+
set(temporary_dir "${CMAKE_CURRENT_BINARY_DIR}/nordic_pull_dir")
63+
file(GLOB nordic_binaries RELATIVE "${temporary_dir}" "${temporary_dir}/*.bin")
64+
65+
foreach(nordic_bin ${nordic_binaries})
66+
set_property(
67+
GLOBAL APPEND PROPERTY SUIT_POST_BUILD_COMMANDS
68+
COMMAND ${CMAKE_COMMAND} -E copy ${temporary_dir}/${nordic_bin} ${SUIT_ROOT_DIRECTORY}${nordic_bin}
69+
BYPRODUCTS ${SUIT_ROOT_DIRECTORY}${nordic_bin}
70+
)
71+
72+
set_property(GLOBAL APPEND PROPERTY SUIT_DFU_ARTIFACTS ${SUIT_ROOT_DIRECTORY}${nordic_bin})
73+
endforeach()
74+
75+
set(nordic_top_directory "${temporary_dir}")
76+
endif()
77+
78+
set_property(
79+
GLOBAL APPEND PROPERTY SUIT_POST_BUILD_COMMANDS
80+
COMMAND ${CMAKE_COMMAND} -E copy ${nordic_top_directory}/nordic_top.suit ${SUIT_ROOT_DIRECTORY}nordic_top.suit
81+
BYPRODUCTS ${SUIT_ROOT_DIRECTORY}nordic_top.suit
82+
)
83+
endfunction()
84+
4085
# Render jinja templates using passed arguments.
4186
# Function uses core_arguments which is list of folowing entries:
4287
# --core <target_name>,<locatino_of_firmware_binary_file>,<location_of_edt_file_representing_dts>
@@ -132,7 +177,7 @@ endfunction()
132177
# 'output_file' - path to output cache partition file
133178
function(suit_create_nordic_cache_partition args output_file)
134179
list(APPEND args "--output-file" "${output_file}")
135-
list(APPEND args "--omit-payload-regex" "'(?!.*secdom.*\.bin|.*sysctl_v.*\.bin).*'")
180+
list(APPEND args "--omit-payload-regex" "'(?!.*sec.*\.bin|.*sysctl_v.*\.bin).*'")
136181
list(APPEND args "--dependency-regex" "'(#top|#secdom|#sysctrl)'")
137182

138183
set_property(

config/suit/templates/nrf54h20/default/v1/root_with_binary_nordic_top.yaml.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,5 +510,5 @@ SUIT_Envelope_Tagged:
510510
'#{{ application['name'] }}': {{ artifacts_folder ~ application['name'] }}.suit
511511
{%- endif %}
512512
{%- if nordic_top %}
513-
'#top': {{ sysbuild['config']['SB_CONFIG_SUIT_ENVELOPE_NORDIC_TOP_DIRECTORY'] }}/nordic_top.suit
513+
'#top': {{ artifacts_folder }}nordic_top.suit
514514
{%- endif %}

samples/suit/smp_transfer/suit/nrf54h20/root_with_binary_nordic_top_extflash.yaml.jinja2

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,23 @@ SUIT_Envelope_Tagged:
122122
{%- endif %}
123123

124124
suit-payload-fetch:
125+
{%- if nordic_top %}
126+
- suit-directive-set-component-index: 0
127+
- suit-directive-override-parameters:
128+
suit-parameter-uri: "#top"
129+
- suit-directive-fetch:
130+
- suit-send-record-failure
131+
- suit-condition-dependency-integrity:
132+
- suit-send-record-success
133+
- suit-send-record-failure
134+
- suit-send-sysinfo-success
135+
- suit-send-sysinfo-failure
136+
- suit-directive-process-dependency:
137+
- suit-send-record-success
138+
- suit-send-record-failure
139+
- suit-send-sysinfo-success
140+
- suit-send-sysinfo-failure
141+
{%- endif %}
125142
{%- if radio is defined %}
126143
- suit-directive-set-component-index: 0
127144
- suit-directive-override-parameters:
@@ -309,5 +326,5 @@ SUIT_Envelope_Tagged:
309326
'#{{ application['name'] }}': {{ artifacts_folder ~ application['name'] }}.suit
310327
{%- endif %}
311328
{%- if nordic_top %}
312-
'#top': {{ sysbuild['config']['SB_CONFIG_SUIT_ENVELOPE_NORDIC_TOP_DIRECTORY'] }}/nordic_top.suit
329+
'#top': {{ artifacts_folder }}nordic_top.suit
313330
{%- endif %}

sysbuild/Kconfig.suit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ config SUIT_ENVELOPE_NORDIC_TOP_EXTRACT_PAYLOADS_TO_CACHE
6666
size to 0 in the suit-candidate-verification sequence - so that its
6767
memory can be used as a mirror for the update of the Nordic elements.
6868

69+
config SUIT_ENVELOPE_NORDIC_TOP_EXTRACT_PAYLOADS_FOR_PULL
70+
bool "Extract payloads from the nordic_top envelope for the use of the pull model"
71+
depends on !SUIT_ENVELOPE_NORDIC_TOP_EXTRACT_PAYLOADS_TO_CACHE
72+
help
73+
When this option is enabled, the build system extracts payloads from
74+
the nordic_top envelope into binaries. The binaries are stored in the
75+
DFU directory, allowing them to be used for the pull model.
76+
They are also added to the DFU zip file.
77+
6978
config SUIT_ENVELOPE_NORDIC_TOP_CACHE_PARTITION_NUM
7079
int "Cache partition number to store the payloads extracted from nordic_top envelope"
7180
default 1

0 commit comments

Comments
 (0)