|
| 1 | +.. _ab_sample: |
| 2 | + |
| 3 | +A/B with MCUboot |
| 4 | +################ |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The A/B with MCUboot sample demonstrates how to configure the application for updates using the A/B method using MCUboot. |
| 11 | +It also includes an example to perform a device health check before confirming the image after the update. |
| 12 | + |
| 13 | +You can update the sample using the Simple Management Protocol (SMP) with UART or Bluetooth® Low Energy. |
| 14 | + |
| 15 | +Requirements |
| 16 | +************ |
| 17 | + |
| 18 | +The sample supports the following development kits: |
| 19 | + |
| 20 | +.. table-from-sample-yaml:: |
| 21 | + |
| 22 | +You need the nRF Device Manager app for update over Bluetooth Low Energy: |
| 23 | + |
| 24 | +* `nRF Device Manager mobile app for Android`_ |
| 25 | +* `nRF Device Manager mobile app for iOS`_ |
| 26 | + |
| 27 | + |
| 28 | +Overview |
| 29 | +******** |
| 30 | + |
| 31 | +This sample demonstrates firmware update using the A/B method. |
| 32 | +This method allows two copies of the application in the NVM memory. |
| 33 | +It is possible to switch between these copies without performing a swap, which significantly reduces time of device's unavailability during the update. |
| 34 | +The switch between images can be triggered by the application or, for example, by a hardware button. |
| 35 | + |
| 36 | +This sample implements an SMP server. |
| 37 | +SMP is a basic transfer encoding used with the MCUmgr management protocol. |
| 38 | +For more information about MCUmgr and SMP, see :ref:`device_mgmt`. |
| 39 | + |
| 40 | +The sample supports the following MCUmgr transports by default: |
| 41 | + |
| 42 | +* Bluetooth |
| 43 | +* Serial (UART) |
| 44 | + |
| 45 | +User interface |
| 46 | +************** |
| 47 | + |
| 48 | +LED 0: |
| 49 | + This LED indicates that the application is running from slot A. |
| 50 | + It is controlled as active low, meaning it will turn on once the application is booted and blinks (turns off) in short intervals. |
| 51 | + The number of short blinks is configurable using the :kconfig:option:`CONFIG_N_BLINKS` Kconfig option. |
| 52 | + It will remain off if the application is running from slot B. |
| 53 | + |
| 54 | +LED 1: |
| 55 | + This LED indicates that the application is running from slot B. |
| 56 | + It is controlled as active low, meaning it will turn on once the application is booted and blinks (turns off) in short intervals. |
| 57 | + The number of short blinks is configurable using the :kconfig:option:`CONFIG_N_BLINKS` Kconfig option. |
| 58 | + It will remain off if the application is running from slot A. |
| 59 | + |
| 60 | +Button 0: |
| 61 | + By pressing this button, the non-active slot will be selected as the preferred slot on the next reboot. |
| 62 | + This preference applies only to the next boot and is cleared after the subsequent reset. |
| 63 | + |
| 64 | +Configuration |
| 65 | +************* |
| 66 | + |
| 67 | +|config| |
| 68 | + |
| 69 | +Configuration options |
| 70 | +===================== |
| 71 | + |
| 72 | +Check and configure the following configuration option for the sample: |
| 73 | + |
| 74 | +.. _CONFIG_N_BLINKS: |
| 75 | + |
| 76 | +CONFIG_N_BLINKS - The number of blinks. |
| 77 | + This configuration option sets the number of times the LED corresponding to the currently active slot blinks (LED0 for slot A, LED1 for slot B). |
| 78 | + The default value of the option is set to ``1``, causing a single blink to indicate *Version 1*. |
| 79 | + You can increment this value to represent an update, such as set it to ``2`` to indicate *Version 2*. |
| 80 | + |
| 81 | +.. _CONFIG_EMULATE_APP_HEALTH_CHECK_FAILURE: |
| 82 | + |
| 83 | +CONFIG_EMULATE_APP_HEALTH_CHECK_FAILURE - Enables emulation of a broken application that fails the self-test. |
| 84 | + This configuration option emulates a broken application that does not pass the self-test. |
| 85 | + |
| 86 | +Additional configuration |
| 87 | +======================== |
| 88 | + |
| 89 | +Check and configure the :kconfig:option:`CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION` library Kconfig option specific to the MCUboot library. |
| 90 | +This configuration option sets the version to pass to imgtool when signing. |
| 91 | +To ensure the updated build is preferred after a DFU, set this option to a higher version than the version currently running on the device. |
| 92 | + |
| 93 | +Building and running |
| 94 | +******************** |
| 95 | + |
| 96 | +.. |sample path| replace:: :file:`samples/dfu/ab` |
| 97 | + |
| 98 | +.. include:: /includes/build_and_run.txt |
| 99 | + |
| 100 | +Testing |
| 101 | +======= |
| 102 | + |
| 103 | +To perform DFU using the `nRF Connect Device Manager`_ mobile app, complete the following steps: |
| 104 | + |
| 105 | +.. include:: /app_dev/device_guides/nrf52/fota_update.rst |
| 106 | + :start-after: fota_upgrades_over_ble_nrfcdm_common_dfu_steps_start |
| 107 | + :end-before: fota_upgrades_over_ble_nrfcdm_common_dfu_steps_end |
| 108 | + |
| 109 | +Dependencies |
| 110 | +************ |
| 111 | + |
| 112 | +This sample uses the following |NCS| library: |
| 113 | + |
| 114 | +* :ref:`MCUboot <mcuboot_index_ncs>` |
0 commit comments