You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/nrf/app_dev/device_guides/nrf54h/ug_nrf54h20_suit_recovery.rst
+183-1Lines changed: 183 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ These issues can occur in the following scenarios:
39
39
If any bugs are overlooked during the development phase, this could result in inconsistencies in the firmware.
40
40
41
41
Recovery Mode and Recovery Manifests
42
-
*************************************************
42
+
************************************
43
43
44
44
The recovery manifests form a separate hierarchy from the normal manifests.
45
45
In this hierarchy, the application recovery (``APP_RECOVERY``) manifest is responsible for managing both the application core image and other manifests, such as the radio recovery manifest.
@@ -232,3 +232,185 @@ To turn an application into a recovery application, the following steps have to
232
232
The value of ``SUIT_RECOVERY_APPLICATION_PATH`` can contain variables like ``${ZEPHYR_NRF_MODULE_DIR}``
233
233
234
234
#. When building the main application, set ``SB_CONFIG_SUIT_RECOVERY_APPLICATION_CUSTOM`` (or the Kconfig option name if a different one was chosen) to ``y``.
Recovery mode can be initiated through a request sent from local domains.
242
+
This functionality is useful for several scenarios, including:
243
+
244
+
* Device recovery: Provides a recovery mechanism if the main firmware crashes and a J-Link connection is unavailable.
245
+
* Foreground updates: Allows the recovery application to function as a "foreground update" application, reducing space requirements for the main application.
246
+
* Application debugging: Facilitates debugging of the recovery application.
247
+
248
+
For an exemplary implementation, see :ref:`Entering recovery through button press <ug_nrf54h20_suit_recovery_enter_through_button>`, which implements such a request-based entry.
249
+
The source code of this feature is available in the :file:`nrf/subsys/suit/app_tools/recovery_button` directory.
250
+
251
+
To request the device to enter recovery mode, invoke the ``suit_foreground_dfu_required()`` function.
252
+
253
+
To exit recovery mode, invoke the ``suit_boot_flags_reset()`` function from the recovery application.
254
+
If the main application firmware is corrupted, the device will re-enter recovery mode on the next boot, regardless of attempts to reset the boot flags.
255
+
256
+
"Enter recovery check" by running recovery firmware (companion image) before the main application
In specific scenarios, the device must determine whether to enter recovery mode before starting the main application.
260
+
For example, a developer might require the device to enter recovery mode if a specific button is pressed during boot.
261
+
262
+
To achieve this, you can configure the recovery application as a companion image in the invocation path preceding the main application.
263
+
Although other companion images can fulfill this purpose, the recovery application is the most commonly used option.
264
+
Using the recovery application as a companion simplifies the system by enabling the recovery firmware to serve multiple purposes.
265
+
266
+
The recovery (companion) application can check if the device should enter recovery mode and set the recovery flag using ``suit_foreground_dfu_required()`` if needed.
267
+
You must ensure that this is only performed when the device is in the ``SUIT_BOOT_MODE_INVOKE`` boot mode.
268
+
The current boot mode can be determined using the ``suit_boot_mode_read`` function.
269
+
270
+
If the device should remain in normal boot mode (for example, the condition is not met) or if the device is already in recovery mode, the firmware should call ``suit_invoke_confirm(0)``.
271
+
This ensures that the SUIT manifest is processed further by the Secure Domain Firmware, allowing the main application to boot.
272
+
273
+
To enable this feature, perform the following steps:
274
+
275
+
.. note::
276
+
This assumes that the companion image is orchestrated by the ``APP_LOCAL_3`` SUIT manifest, which is the default configuration when using the recovery firmware as the companion.
277
+
278
+
279
+
1. Add the appropriate checking code to the recovery (companion) application in its startup code.
You must place the code in the recovery (companion) application's source code.
315
+
To implement this, you can do one of the following:
316
+
317
+
* Create a module with the code snippet and integrate it into the Nordic-provided recovery application.
318
+
* Create a custom recovery application or companion image and include the module there.
319
+
320
+
2. If using the default SUIT manifests and running the recovery image as the companion image, no modifications to the manifest templates are needed.
321
+
Instead, set the :kconfig:option:`CONFIG_SUIT_INVOKE_APP_LOCAL_3_BEFORE_MAIN_APP` option in the recovery image.
322
+
To do so, add ``-Drecovery_CONFIG_SUIT_INVOKE_APP_LOCAL_3_BEFORE_MAIN_APP=y`` to the build command when building the recovery application.
323
+
324
+
If you are not using the default SUIT maifests, you must modify the manifest templates as follows:
325
+
326
+
a. In the ``APP_LOCAL_3`` manifest template, add the following code before the ``suit-directive-invoke`` directive on the companion image:
327
+
328
+
.. code-block:: yaml
329
+
330
+
- suit-directive-override-parameters:
331
+
suit-parameter-invoke-args:
332
+
suit-synchronous-invoke: True
333
+
suit-timeout: 1000
334
+
335
+
b. In the root manifest template, add the ``INSTLD_MFST`` component for the local manifest orchestrating the comapanion image.
336
+
You must ensure it is invoked before the main application images.
337
+
If the modified template is based on the root manifest template from the |NCS|, it will in most cases be enough to add it as the first manifest in the component list.
338
+
The following code snippet is responsible for this in the default root manifest template:
339
+
340
+
.. code-block:: yaml
341
+
342
+
{{- component_list.append( app_recovery_local_component_index ) or ""}}
A common use case for entering recovery mode is to allow the device to enter recovery mode by pressing a button.
355
+
In the |NCS|, this use case is provided as a simple plug-and-play solution.
356
+
When it is enabled, the device will enter recovery mode if the button is pressed during boot.
357
+
358
+
.. note::
359
+
If no modifications or additional modules are added to the recovery application, the only way to exit the recovery mode is by performing a device firmware upgrade.
360
+
361
+
There are two variants of this feature:
362
+
363
+
* The recovery button checked in the recovery application running as a companion image during the boot stage (recommended).
364
+
* The recovery button checked in the main application.
365
+
366
+
The first variant is recommended because it allows the check to be performed independently of the main application.
367
+
368
+
Recovery button checked in the recovery application
In this variant, the recovery application is executed as a companion image before the main application as part of the normal invocation path.
372
+
373
+
The recovery application checks whether the device is already in recovery mode.
374
+
If the device is in recovery mode, the recovery application continues its normal operation, enabling firmware recovery.
375
+
376
+
If the device is not in recovery mode, the recovery application checks whether the specified button is pressed.
377
+
If the button is pressed, the recovery application sets the recovery flag and reboots the device.
378
+
Otherwise, it sends a confirmation message to the Secure Domain Firmware, which then halts the recovery application and proceeds with booting the main application.
379
+
380
+
To enable the feature, add the following code to the :file:`sysbuild/recovery.overlay` file in the main application directory:
381
+
382
+
.. code-block:: dts
383
+
384
+
/ {
385
+
chosen {
386
+
ncs,recovery-button = &button0;
387
+
};
388
+
};
389
+
390
+
Replace ``button0`` with the appropriate button node.
391
+
392
+
393
+
.. note::
394
+
In this option, running the recovery application as a companion image is orchestrated by the root SUIT manifest.
395
+
Special care must be taken if the root manifest template is modified.
396
+
Incorrect modifications to the root manifest can result in the button press feature not functioning correctly.
397
+
This may cause the device to become unrecoverable without a JLink connection in the event of a crash.
398
+
399
+
400
+
Recovery button checked in the main application
401
+
-----------------------------------------------
402
+
403
+
In this variant, a check is performed within the main application firmware at an early stage to determine if the specified button is pressed.
404
+
If the button is pressed, the recovery flag is set, and the device reboots.
405
+
406
+
To enable this feature in this variant, add the following overlay to the main application's configuration:
407
+
408
+
.. code-block:: dts
409
+
410
+
/ {
411
+
chosen {
412
+
ncs,recovery-button = &button0;
413
+
};
414
+
};
415
+
416
+
Replace ``button0`` with the appropriate button node.
0 commit comments