Skip to content

Commit 4f31284

Browse files
ahasztagtomchy
authored andcommitted
suit: Recovery run from APP_LOCAL_3 manifest
This commit changes the way the recovery application image is connected to the APP_RECOVERY manifest. In the new approach, it is not accessed directly from the APP_RECOVERY manifest - instead, the APP_RECOVERY manifest is connected to the APP_LOCAL_3 manifest, which then orchestrates invoking and installing of the application recovery image. It is still possible to use the old approach by setting SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY during build. Signed-off-by: Artur Hadasz <[email protected]>
1 parent 77c9344 commit 4f31284

File tree

6 files changed

+281
-23
lines changed

6 files changed

+281
-23
lines changed

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

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
{%- set mpi_app_recovery_class_name = application['config']['CONFIG_SUIT_MPI_APP_RECOVERY_CLASS_NAME']|default('nRF54H20_app_recovery') %}
66
{%- set mpi_rad_recovery_vendor_name = application['config']['CONFIG_SUIT_MPI_RAD_RECOVERY_VENDOR_NAME']|default('nordicsemi.com') %}
77
{%- set mpi_rad_recovery_class_name = application['config']['CONFIG_SUIT_MPI_RAD_RECOVERY_CLASS_NAME']|default('nRF54H20_rad_recovery') %}
8+
{%- if sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_LOCAL_3']%}
9+
{%- set mpi_app_recovery_local_vendor_name = application['config']['CONFIG_SUIT_MPI_APP_LOCAL_3_VENDOR_NAME']|default('nordicsemi.com') %}
10+
{%- set mpi_app_recovery_local_class_name = application['config']['CONFIG_SUIT_MPI_APP_LOCAL_3_CLASS_NAME']|default('nRF54H20_sample_app_2') %}
11+
{%- endif %}
812
SUIT_Envelope_Tagged:
913
suit-authentication-wrapper:
1014
SuitDigest:
@@ -20,18 +24,33 @@ SUIT_Envelope_Tagged:
2024
{%- endif %}
2125
suit-common:
2226
suit-components:
27+
{%- set component_index = 0 %}
28+
{%- if sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY']%}
2329
- - CAND_IMG
2430
- 0
31+
{%- set component_index = component_index + 1 %}
32+
{%- endif %}
2533
- - CAND_MFST
2634
- 0
27-
{%- set component_index = 2 %}
28-
{%- if app_recovery is defined %}
35+
{%- set cand_mfst_component_index = component_index %}
36+
{%- set component_index = component_index + 1 %}
37+
{%- if app_recovery_img is defined %}
38+
{%- if sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY']%}
2939
{%- set app_img_component_index = component_index %}
3040
{{- component_list.append( app_img_component_index ) or ""}}
3141
- - MEM
32-
- {{ app_recovery['dt'].label2node['cpu'].unit_addr }}
33-
- {{ get_absolute_address(app_recovery['dt'].chosen_nodes['zephyr,code-partition']) }}
34-
- {{ app_recovery['dt'].chosen_nodes['zephyr,code-partition'].regs[0].size }}
42+
- {{ app_recovery_img['dt'].label2node['cpu'].unit_addr }}
43+
- {{ get_absolute_address(app_recovery_img['dt'].chosen_nodes['zephyr,code-partition']) }}
44+
- {{ app_recovery_img['dt'].chosen_nodes['zephyr,code-partition'].regs[0].size }}
45+
{%- elif sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_LOCAL_3'] %}
46+
{%- set app_recovery_local_instld_mfst_component_index = component_index %}
47+
{{- component_list.append( app_recovery_local_instld_mfst_component_index ) or ""}}
48+
{{- dependencies_list.append( app_recovery_local_instld_mfst_component_index ) or ""}}
49+
- - INSTLD_MFST
50+
- RFC4122_UUID:
51+
namespace: {{ mpi_app_recovery_local_vendor_name }}
52+
name: {{ mpi_app_recovery_local_class_name }}
53+
{%- endif %}
3554
{%- set component_index = component_index + 1 %}
3655
{%- endif %}
3756
{%- if rad_recovery is defined %}
@@ -56,7 +75,8 @@ SUIT_Envelope_Tagged:
5675
namespace: {{ mpi_app_recovery_vendor_name }}
5776
name: {{ mpi_app_recovery_class_name }}
5877
{%- endif %}
59-
{%- if app_recovery is defined %}
78+
{%- if app_recovery_img is defined %}
79+
{%- if sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY']%}
6080
- suit-directive-set-component-index: {{ app_img_component_index }}
6181
- suit-directive-override-parameters:
6282
suit-parameter-vendor-identifier:
@@ -68,9 +88,19 @@ SUIT_Envelope_Tagged:
6888
suit-parameter-image-digest:
6989
suit-digest-algorithm-id: cose-alg-sha-256
7090
suit-digest-bytes:
71-
file: {{ app_recovery['binary'] }}
91+
file: {{ app_recovery_img['binary'] }}
7292
suit-parameter-image-size:
73-
file: {{ app_recovery['binary'] }}
93+
file: {{ app_recovery_img['binary'] }}
94+
{%- elif sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_LOCAL_3'] %}
95+
- suit-directive-set-component-index: {{ app_recovery_local_instld_mfst_component_index }}
96+
- suit-directive-override-parameters:
97+
suit-parameter-vendor-identifier:
98+
RFC4122_UUID: {{ mpi_app_recovery_local_vendor_name }}
99+
suit-parameter-class-identifier:
100+
RFC4122_UUID:
101+
namespace: {{ mpi_app_recovery_local_vendor_name }}
102+
name: {{ mpi_app_recovery_class_name }}
103+
{%- endif %}
74104
{%- endif %}
75105
- suit-directive-set-component-index: [{{ component_list|join(',') }}]
76106
- suit-condition-vendor-identifier:
@@ -85,7 +115,7 @@ SUIT_Envelope_Tagged:
85115
- suit-send-sysinfo-failure
86116
suit-dependencies:
87117
# Key is the index of suit-components that describe the dependency manifest
88-
"1": {}
118+
"{{ cand_mfst_component_index }}": {}
89119
{%- for component_element in dependencies_list %}
90120
"{{ component_element }}": {}
91121
{%- endfor %}
@@ -104,7 +134,7 @@ SUIT_Envelope_Tagged:
104134
- suit-send-sysinfo-success
105135
- suit-send-sysinfo-failure
106136
{% endif %}
107-
{%- if app_recovery is defined %}
137+
{%- if app_recovery_img is defined and sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY'] %}
108138
- suit-directive-set-component-index: {{ app_img_component_index }}
109139
- suit-condition-image-match:
110140
- suit-send-record-success
@@ -127,7 +157,7 @@ SUIT_Envelope_Tagged:
127157
- suit-send-sysinfo-success
128158
- suit-send-sysinfo-failure
129159
{% endif %}
130-
{%- if app_recovery is defined %}
160+
{%- if app_recovery_img is defined and sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY'] %}
131161
- suit-directive-set-component-index: {{ app_img_component_index }}
132162
- suit-directive-invoke:
133163
- suit-send-record-failure
@@ -146,7 +176,7 @@ SUIT_Envelope_Tagged:
146176
suit-install:
147177
{%- endif %}
148178
{%- if rad_recovery is defined %}
149-
- suit-directive-set-component-index: 1
179+
- suit-directive-set-component-index: {{ cand_mfst_component_index }}
150180
- suit-directive-override-parameters:
151181
suit-parameter-uri: '#{{ rad_recovery['name'] }}'
152182
suit-parameter-image-digest:
@@ -171,18 +201,19 @@ SUIT_Envelope_Tagged:
171201
- suit-send-sysinfo-success
172202
- suit-send-sysinfo-failure
173203
{%- endif %}
174-
{%- if app_recovery is defined %}
204+
{%- if app_recovery_img is defined %}
205+
{%- if sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY']%}
175206
- suit-directive-set-component-index: 0
176207
- suit-directive-override-parameters:
177-
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI' in app_recovery['config'] and app_recovery['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] != '' %}
178-
suit-parameter-uri: '{{ app_recovery['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] }}'
208+
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI' in app_recovery_img['config'] and app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] != '' %}
209+
suit-parameter-uri: '{{ app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] }}'
179210
{%- else %}
180-
suit-parameter-uri: '#{{ app_recovery['name'] }}'
211+
suit-parameter-uri: '#{{ app_recovery_img['name'] }}'
181212
{%- endif %}
182213
suit-parameter-image-digest:
183214
suit-digest-algorithm-id: cose-alg-sha-256
184215
suit-digest-bytes:
185-
file: {{ app_recovery['binary'] }}
216+
file: {{ app_recovery_img['binary'] }}
186217
- suit-directive-fetch:
187218
- suit-send-record-failure
188219
- suit-condition-image-match:
@@ -200,6 +231,32 @@ SUIT_Envelope_Tagged:
200231
- suit-send-record-failure
201232
- suit-send-sysinfo-success
202233
- suit-send-sysinfo-failure
234+
{%- elif sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_LOCAL_3'] %}
235+
- suit-directive-set-component-index: 0
236+
- suit-directive-override-parameters:
237+
suit-parameter-uri: '#{{ app_recovery_img['name'] }}'
238+
suit-parameter-image-digest:
239+
suit-digest-algorithm-id: cose-alg-sha-256
240+
suit-digest-bytes:
241+
envelope: {{ artifacts_folder ~ app_recovery_img['name'] }}.suit
242+
- suit-directive-fetch:
243+
- suit-send-record-failure
244+
- suit-condition-image-match:
245+
- suit-send-record-success
246+
- suit-send-record-failure
247+
- suit-send-sysinfo-success
248+
- suit-send-sysinfo-failure
249+
- suit-condition-dependency-integrity:
250+
- suit-send-record-success
251+
- suit-send-record-failure
252+
- suit-send-sysinfo-success
253+
- suit-send-sysinfo-failure
254+
- suit-directive-process-dependency:
255+
- suit-send-record-success
256+
- suit-send-record-failure
257+
- suit-send-sysinfo-success
258+
- suit-send-sysinfo-failure
259+
{%- endif %}
203260
{%- endif %}
204261
suit-manifest-component-id:
205262
- INSTLD_MFST
@@ -210,8 +267,12 @@ SUIT_Envelope_Tagged:
210267
{%- if rad_recovery is defined %}
211268
'#{{ rad_recovery['name'] }}': {{ artifacts_folder ~ rad_recovery['name'] }}.suit
212269
{%- endif %}
213-
{%- if app_recovery is defined %}
214-
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE' not in app_recovery['config'] or app_recovery['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE'] == '' %}
215-
'#{{ app_recovery['name'] }}': {{ app_recovery['binary'] }}
270+
{%- if app_recovery_img is defined %}
271+
{%- if sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_RECOVERY']%}
272+
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE' not in app_recovery_img['config'] or app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE'] == '' %}
273+
'#{{ app_recovery_img['name'] }}': {{ app_recovery_img['binary'] }}
274+
{%- endif %}
275+
{%- elif sysbuild['config']['SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_LOCAL_3'] %}
276+
'#{{ app_recovery_img['name'] }}': {{ artifacts_folder ~ app_recovery_img['name'] }}.suit
216277
{%- endif %}
217278
{%- endif %}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
{%- set mpi_app_recovery_local_vendor_name = application['config']['CONFIG_SUIT_MPI_APP_LOCAL_3_VENDOR_NAME']|default('nordicsemi.com') %}
2+
{%- set mpi_app_recovery_local_class_name = application['config']['CONFIG_SUIT_MPI_APP_LOCAL_3_CLASS_NAME']|default('nRF54H20_sample_app_3') %}
3+
SUIT_Envelope_Tagged:
4+
suit-authentication-wrapper:
5+
SuitDigest:
6+
suit-digest-algorithm-id: cose-alg-sha-256
7+
suit-manifest:
8+
suit-manifest-version: 1
9+
{%- if APP_LOCAL_3_SEQ_NUM is defined %}
10+
suit-manifest-sequence-number: {{ APP_LOCAL_3_SEQ_NUM }}
11+
{%- elif DEFAULT_SEQ_NUM is defined %}
12+
suit-manifest-sequence-number: {{ DEFAULT_SEQ_NUM }}
13+
{%- else %}
14+
suit-manifest-sequence-number: 1
15+
{%- endif %}
16+
suit-common:
17+
suit-components:
18+
- - MEM
19+
- {{ app_recovery_img['dt'].label2node['cpu'].unit_addr }}
20+
- {{ get_absolute_address(app_recovery_img['dt'].chosen_nodes['zephyr,code-partition']) }}
21+
- {{ app_recovery_img['dt'].chosen_nodes['zephyr,code-partition'].regs[0].size }}
22+
- - CAND_IMG
23+
- 0
24+
suit-shared-sequence:
25+
- suit-directive-set-component-index: 0
26+
- suit-directive-override-parameters:
27+
suit-parameter-vendor-identifier:
28+
RFC4122_UUID: {{ mpi_app_recovery_local_vendor_name }}
29+
suit-parameter-class-identifier:
30+
RFC4122_UUID:
31+
namespace: {{ mpi_app_recovery_local_vendor_name }}
32+
name: {{ mpi_app_recovery_local_class_name }}
33+
suit-parameter-image-digest:
34+
suit-digest-algorithm-id: cose-alg-sha-256
35+
suit-digest-bytes:
36+
file: {{ app_recovery_img['binary'] }}
37+
suit-parameter-image-size:
38+
file: {{ app_recovery_img['binary'] }}
39+
- suit-condition-vendor-identifier:
40+
- suit-send-record-success
41+
- suit-send-record-failure
42+
- suit-send-sysinfo-success
43+
- suit-send-sysinfo-failure
44+
- suit-condition-class-identifier:
45+
- suit-send-record-success
46+
- suit-send-record-failure
47+
- suit-send-sysinfo-success
48+
- suit-send-sysinfo-failure
49+
suit-validate:
50+
- suit-directive-set-component-index: 0
51+
# In the case of streaming operations it is worth to retry them at least once.
52+
# This increases the robustness against bit flips on the transport,
53+
# for example when storing the data on an external memory device.
54+
# The suit-directive-try-each will complete on the first successful subsequence.
55+
- suit-directive-try-each:
56+
- - suit-condition-image-match:
57+
- suit-send-record-success
58+
- suit-send-record-failure
59+
- suit-send-sysinfo-success
60+
- suit-send-sysinfo-failure
61+
- - suit-condition-image-match:
62+
- suit-send-record-success
63+
- suit-send-record-failure
64+
- suit-send-sysinfo-success
65+
- suit-send-sysinfo-failure
66+
suit-invoke:
67+
- suit-directive-set-component-index: 0
68+
- suit-directive-invoke:
69+
- suit-send-record-failure
70+
71+
{%- if APP_LOCAL_3_VERSION is defined %}
72+
suit-current-version: {{ APP_LOCAL_3_VERSION }}
73+
{%- elif DEFAULT_VERSION is defined %}
74+
suit-current-version: {{ DEFAULT_VERSION }}
75+
{%- endif %}
76+
77+
{%- if application['dt'].label2node['suit_storage_partition'].regs[0].size == 24576 %}
78+
# Application DTS contains larger SUIT storage - use legacy encoding
79+
suit-install-legacy:
80+
{%- else %}
81+
suit-install:
82+
{%- endif %}
83+
- suit-directive-set-component-index: 1
84+
- suit-directive-override-parameters:
85+
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI' in app_recovery_img['config'] and app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] != '' %}
86+
suit-parameter-uri: '{{ app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] }}'
87+
{%- else %}
88+
suit-parameter-uri: '#{{ app_recovery_img['name'] }}'
89+
{%- endif %}
90+
suit-parameter-image-digest:
91+
suit-digest-algorithm-id: cose-alg-sha-256
92+
suit-digest-bytes:
93+
file: {{ app_recovery_img['binary'] }}
94+
- suit-directive-fetch:
95+
- suit-send-record-failure
96+
- suit-directive-try-each:
97+
- - suit-condition-image-match:
98+
- suit-send-record-success
99+
- suit-send-record-failure
100+
- suit-send-sysinfo-success
101+
- suit-send-sysinfo-failure
102+
- - suit-condition-image-match:
103+
- suit-send-record-success
104+
- suit-send-record-failure
105+
- suit-send-sysinfo-success
106+
- suit-send-sysinfo-failure
107+
- suit-directive-set-component-index: 0
108+
- suit-directive-override-parameters:
109+
suit-parameter-source-component: 1
110+
# When copying the data it is worth to retry the sequence of
111+
# suit-directive-copy and suit-condition-image-match at least once.
112+
# If a bit flip occurs, it might be due to a transport issue, not
113+
# a corrupted candidate image. In this case the bit flip is recoverable
114+
# and it is worth retrying the operation.
115+
# The suit-directive-try-each will complete on the first successful subsequence.
116+
- suit-directive-try-each:
117+
- - suit-directive-copy:
118+
- suit-send-record-failure
119+
- suit-condition-image-match:
120+
- suit-send-record-success
121+
- suit-send-record-failure
122+
- suit-send-sysinfo-success
123+
- suit-send-sysinfo-failure
124+
- - suit-directive-copy:
125+
- suit-send-record-failure
126+
- suit-condition-image-match:
127+
- suit-send-record-success
128+
- suit-send-record-failure
129+
- suit-send-sysinfo-success
130+
- suit-send-sysinfo-failure
131+
suit-text:
132+
suit-digest-algorithm-id: cose-alg-sha-256
133+
134+
suit-candidate-verification:
135+
- suit-directive-set-component-index: 1
136+
- suit-directive-override-parameters:
137+
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI' in app_recovery_img['config'] and app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] != '' %}
138+
suit-parameter-uri: '{{ app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE_URI'] }}'
139+
{%- else %}
140+
suit-parameter-uri: '#{{ app_recovery_img['name'] }}'
141+
{%- endif %}
142+
suit-parameter-image-digest:
143+
suit-digest-algorithm-id: cose-alg-sha-256
144+
suit-digest-bytes:
145+
file: {{ app_recovery_img['binary'] }}
146+
- suit-directive-fetch:
147+
- suit-send-record-failure
148+
- suit-directive-try-each:
149+
- - suit-condition-image-match:
150+
- suit-send-record-success
151+
- suit-send-record-failure
152+
- suit-send-sysinfo-success
153+
- suit-send-sysinfo-failure
154+
- - suit-condition-image-match:
155+
- suit-send-record-success
156+
- suit-send-record-failure
157+
- suit-send-sysinfo-success
158+
- suit-send-sysinfo-failure
159+
160+
suit-manifest-component-id:
161+
- INSTLD_MFST
162+
- RFC4122_UUID:
163+
namespace: {{ mpi_app_recovery_local_vendor_name }}
164+
name: {{ mpi_app_recovery_local_class_name }}
165+
suit-text:
166+
en:
167+
'["MEM", {{ app_recovery_img['dt'].label2node['cpu'].unit_addr }}, {{ get_absolute_address(app_recovery_img['dt'].chosen_nodes['zephyr,code-partition']) }}, {{ app_recovery_img['dt'].chosen_nodes['zephyr,code-partition'].regs[0].size }}]':
168+
suit-text-vendor-name: Nordic Semiconductor ASA
169+
suit-text-model-name: nRF54H20_cpuapp_3
170+
suit-text-vendor-domain: nordicsemi.com
171+
suit-text-model-info: The nRF54H20 application core companion/recovery
172+
suit-text-component-description: Sample application core companion/recovery FW
173+
suit-text-component-version: v1.0.0
174+
{%- if 'CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE' not in app_recovery_img['config'] or app_recovery_img['config']['CONFIG_SUIT_DFU_CACHE_EXTRACT_IMAGE'] == '' %}
175+
suit-integrated-payloads:
176+
'#{{ app_recovery_img['name'] }}': {{ app_recovery_img['binary'] }}
177+
{%- endif %}

sysbuild/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
560560
if(SB_CONFIG_SUIT_BUILD_RECOVERY)
561561
set_config_bool(${DEFAULT_IMAGE} CONFIG_SUIT_MPI_APP_RECOVERY y)
562562
set_config_bool(${DEFAULT_IMAGE} CONFIG_SUIT_MPI_RAD_RECOVERY y)
563+
564+
if(SB_CONFIG_SUIT_RECOVERY_APPLICATION_IMAGE_MANIFEST_APP_LOCAL_3)
565+
set_config_bool(${DEFAULT_IMAGE} CONFIG_SUIT_MPI_APP_LOCAL_3 y)
566+
endif()
563567
endif()
564568

565569
if(SB_CONFIG_SDP)

0 commit comments

Comments
 (0)