Skip to content

Commit 9ea86f2

Browse files
committed
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 ad738e5 commit 9ea86f2

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

samples/dfu/ab/README.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,67 @@ 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 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 in the documentation.
52+
This configuration allows for performing 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+
2. If both slots are valid, the slot marked as "preferred" is selected as active.
59+
3. If both slots are valid and none is marked as "preferred", the slot with the higher version number is selected as active.
60+
4. If none of the above conditions is met, slot A is selected as active.
61+
62+
Setting the preffered slot can be done using the ``boot_request_set_preferred_slot`` function.
63+
Currently, this only allows for setting the boot preference for a single reboot.
64+
65+
Getting the currently running 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, 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 (configuration currently only supported on 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+
If building with nRF54H20, the merge slot feature is used when 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 slot B image, should be uploaded to the secondary slot when running from slot A.
98+
* :file:`build/zephyr/zephyr.merged.bin` contains slot A image, should be uploaded to the primary slot when running from slot B.
99+
100+
If building on other supported platforms, where there is no separate radio core, only the application core is updated.
101+
In this case the mcuboot files for the application image are used:
102+
103+
* :file:`build/mcuboot_secondary_app/zephyr/zephyr.signed.bin` contains slot B image, should be uploaded to the secondary slot when running from slot A.
104+
* :file:`build/ab/zephyr/zephyr.signed.bin` contains slot A image, should be uploaded to the primary slot when running from slot B.
105+
45106
User interface
46107
**************
47108

@@ -106,6 +167,9 @@ To perform DFU using the `nRF Connect Device Manager`_ mobile app, complete the
106167
:start-after: fota_upgrades_over_ble_nrfcdm_common_dfu_steps_start
107168
:end-before: fota_upgrades_over_ble_nrfcdm_common_dfu_steps_end
108169

170+
Instead of using the ``dfu_application.zip`` file, you can also send the appropriate binary file directly as described in :ref:`ab_build_files`.
171+
Make sure to select the correct file based on the currently running slot.
172+
109173
Dependencies
110174
************
111175

0 commit comments

Comments
 (0)