Skip to content

Commit 5cbdf03

Browse files
ahasztagtomchy
authored andcommitted
samples: dfu: Extend A/B sample documentation
This commit extends the A/B sample documentation with more in-depth description of the A/B feature. Signed-off-by: Artur Hadasz <[email protected]>
1 parent ef7a690 commit 5cbdf03

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

samples/dfu/ab/README.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,71 @@ The sample supports the following MCUmgr transports by default:
4242
* Bluetooth
4343
* Serial (UART)
4444

45+
A/B functionality
46+
=================
47+
48+
When the A/B functionality is used, the device has two slots for the application: slot A and slot B.
49+
The slots are equivalent, and the device can boot from either of them.
50+
In the case of MCUboot, this is achieved by using the Direct XIP feature.
51+
Thus, note that the terms slot 0, primary slot, slot A and slot 1, secondary slot, slot B are used interchangeably throughout the documentation.
52+
This configuration allows a background update of the non-active slot while the application runs from the active slot.
53+
After the update is complete, the device can quickly switch to the updated slot on the next reboot.
54+
55+
The following conditions decide which slot will be booted (active) on the next reboot:
56+
57+
1. If one of the slots is not valid, the other slot is selected as active.
58+
#. If both slots are valid, the slot marked as "preferred" is selected as active.
59+
#. If both slots are valid and none is marked as "preferred," the slot with the higher version number is selected as active.
60+
#. If none of the above conditions is met, slot A is selected as active.
61+
62+
You can set the preferred slot using the ``boot_request_set_preferred_slot`` function.
63+
Currently, this only sets the boot preference for a single reboot.
64+
65+
Identifying the active slot
66+
---------------------------
67+
68+
If the project uses the Partition Manager, the currently running slot can be identified by checking if ``CONFIG_NCS_IS_VARIANT_IMAGE`` is defined.
69+
If it is defined, the application is running from slot B.
70+
Otherwise, it is running from slot A.
71+
72+
If the project does not use the Partition Manager (a configuration currently only supported on the nRF54H20), the currently running slot can be identified by comparing the address pointed `zephyr,code-partition` to specific node addresses defined in the device tree.
73+
The following node partitions are used by default:
74+
75+
* ``slot0_partition`` - Application core, slot A
76+
* ``slot1_partition`` - Application core, slot B
77+
* ``cpurad_slot0_partition`` - Radio core, slot A
78+
* ``cpurad_slot1_partition`` - Radio core, slot B
79+
80+
For example, verifying that the application is running from slot A can be done by using the following macro:
81+
82+
.. code-block:: c
83+
84+
#define IS_RUNNING_FROM_SLOT_A \
85+
(FIXED_PARTITION_NODE_OFFSET(DT_CHOSEN(zephyr_code_partition)) == \
86+
FIXED_PARTITION_OFFSET(slot0_partition))
87+
88+
.. _ab_build_files:
89+
90+
Build files
91+
-----------
92+
93+
When building for the nRF54H20, the merge slot feature is used if Direct XIP is enabled.
94+
This means that, for both slot A and slot B, the application image and the radio image are merged and treated as a single image by MCUboot.
95+
In this case, the following files should be sent to the device when performing an update:
96+
97+
* :file:`build/zephyr/zephyr_secondary_app.merged.bin` - Contains the slot B image.
98+
This file should be uploaded to the secondary slot when the device is running from slot A.
99+
* :file:`build/zephyr/zephyr.merged.bin` - Contains the slot A image.
100+
This file should be uploaded to the primary slot when the device is running from slot B.
101+
102+
If building on other supported platforms, where there is no separate radio core, only the application core is updated.
103+
In this case, the following MCUboot files for the application image are used:
104+
105+
* :file:`build/mcuboot_secondary_app/zephyr/zephyr.signed.bin` - Contains the slot B image.
106+
This file should be uploaded to the secondary slot when the device is running from slot A.
107+
* :file:`build/ab/zephyr/zephyr.signed.bin` - Contains the slot A image.
108+
This file should be uploaded to the primary slot when the device is running from slot B.
109+
45110
User interface
46111
**************
47112

@@ -106,6 +171,9 @@ To perform DFU using the `nRF Connect Device Manager`_ mobile app, complete the
106171
:start-after: fota_upgrades_over_ble_nrfcdm_common_dfu_steps_start
107172
:end-before: fota_upgrades_over_ble_nrfcdm_common_dfu_steps_end
108173

174+
Instead of using the :file:`dfu_application.zip` file, you can also send the appropriate binary file directly, as described in :ref:`ab_build_files`.
175+
Make sure to select the correct file based on the currently running slot.
176+
109177
Dependencies
110178
************
111179

0 commit comments

Comments
 (0)