|
| 1 | +.. _nrf_compression_mcuboot_compressed_update: |
| 2 | + |
| 3 | +nRF Compression: MCUboot compressed update |
| 4 | +########################################## |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +This sample demonstrates how to enable and use :ref:`image compression within MCUboot <mcuboot_image_compression>`, which allows for smaller application updates to be loaded to a device. |
| 11 | + |
| 12 | +Requirements |
| 13 | +************ |
| 14 | + |
| 15 | +The sample supports the following development kits: |
| 16 | + |
| 17 | +.. table-from-sample-yaml:: |
| 18 | + |
| 19 | +Overview |
| 20 | +******** |
| 21 | + |
| 22 | +This sample is using the :ref:`nrf_compression` library. |
| 23 | + |
| 24 | +The sample's default configuration has the following features enabled: |
| 25 | + |
| 26 | +* MCUboot in the upgrade-only mode with the Kconfig option :kconfig:option:`CONFIG_BOOT_UPGRADE_ONLY` set to ``y``. |
| 27 | +* Single-update image with the Kconfig option :kconfig:option:`CONFIG_UPDATEABLE_IMAGE_NUMBER` set to ``1``. |
| 28 | + |
| 29 | +When the sample is built, the build system automatically generates the update binary files with compressed image data and flags set. |
| 30 | +These files match the :ref:`requirements for MCUboot image compression <mcuboot_image_compression_setup>`. |
| 31 | + |
| 32 | +Configuration |
| 33 | +************* |
| 34 | + |
| 35 | +|config| |
| 36 | + |
| 37 | +See :ref:`configuring_kconfig` for information about the different ways you can set Kconfig options in the |NCS|. |
| 38 | + |
| 39 | +Configuration options |
| 40 | +===================== |
| 41 | + |
| 42 | +.. _CONFIG_OUTPUT_BOOT_MESSAGE: |
| 43 | + |
| 44 | +CONFIG_OUTPUT_BOOT_MESSAGE |
| 45 | + When enabled, this optional configuration option outputs a message at run-time that allows for checking if the image has been updated successfully. |
| 46 | + |
| 47 | +Building and running |
| 48 | +******************** |
| 49 | + |
| 50 | +.. |sample path| replace:: :file:`samples/nrf_compress/mcuboot_update` |
| 51 | + |
| 52 | +.. include:: /includes/build_and_run.txt |
| 53 | + |
| 54 | +To upload MCUboot and the bundle of images to the device, program the sample by using the :ref:`flash command without erase <programming_params_no_erase>`. |
| 55 | + |
| 56 | +Testing over Bluetooth LE |
| 57 | +========================= |
| 58 | + |
| 59 | +The testing scenario uses the FOTA over Bluetooth LE method to load the firmware update to the device. |
| 60 | +For the testing scenario to work, make sure you meet the following requirements: |
| 61 | + |
| 62 | +* Your update image differs from the base image so that the update can be applied. |
| 63 | +* You changed the firmware version by setting :kconfig:option:`CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION` to ``"2.0.0"``. |
| 64 | +* You set the :kconfig:option:`CONFIG_OUTPUT_BOOT_MESSAGE` Kconfig option to ``y``. |
| 65 | +* You are familiar with the FOTA over Bluetooth LE method (see :ref:`the guide for the nRF52840 DK <ug_nrf52_developing_ble_fota_steps>` and :ref:`the guide for the nRF5340 DK <ug_nrf53_developing_ble_fota_steps>`). |
| 66 | +* You have the `nRF Connect Device Manager`_ mobile app installed on your smartphone to update your device with the new firmware over Bluetooth LE. |
| 67 | + |
| 68 | +Meeting these requirements requires rebuilding the sample. |
| 69 | + |
| 70 | +|test_sample| |
| 71 | + |
| 72 | +#. |connect_kit| |
| 73 | +#. |connect_terminal| |
| 74 | +#. Start the `nRF Connect Device Manager`_ mobile app. |
| 75 | +#. Follow the testing steps for the FOTA over Bluetooth LE. |
| 76 | + See the following sections of the documentation: |
| 77 | + |
| 78 | + * :ref:`Testing steps for FOTA over Bluetooth LE with nRF52840 <ug_nrf52_developing_ble_fota_steps_testing>` |
| 79 | + * :ref:`Testing steps for FOTA over Bluetooth LE with nRF5340 <ug_nrf53_developing_ble_fota_steps_testing>` |
| 80 | + * *Not yet available*: Testing steps for FOTA over Bluetooth LE with nRF54L15 |
| 81 | + |
| 82 | +#. Once the firmware update has been loaded, check the UART output. |
| 83 | + See the following `Sample output`_ section. |
| 84 | +#. Reboot the device. |
| 85 | + The compressed firmware update will be applied to the device and it will boot into it. |
| 86 | + |
| 87 | + .. note:: |
| 88 | + At this point, the compressed flags will not be present in the running application image, as the firmware update has been decompressed whilst copying to the primary slot. |
| 89 | + |
| 90 | +Sample output |
| 91 | +============= |
| 92 | + |
| 93 | +After a firmware update has been loaded, the UART will output the information on the image which will be one of the following: |
| 94 | + |
| 95 | +LZMA2 with ARM |
| 96 | + The following output is logged: |
| 97 | + |
| 98 | + .. code-block:: console |
| 99 | +
|
| 100 | + Secondary slot image is LZMA2 compressed with ARM thumb filter applied |
| 101 | +
|
| 102 | + This indicates that the loaded firmware update has been compressed using LZMA2 and had the ARM thumb filter applied. |
| 103 | + This offers the best compression ratio and is recommended for general usage. |
| 104 | + |
| 105 | +LZMA2 only |
| 106 | + The following output is logged: |
| 107 | + |
| 108 | + .. code-block:: console |
| 109 | +
|
| 110 | + Secondary slot image is LZMA2 compressed |
| 111 | +
|
| 112 | + This indicates that the loaded firmware update has been compressed using LZMZ2. |
| 113 | + This offers a good compression ratio but is not optimal. |
| 114 | + |
| 115 | +No LZMA2 |
| 116 | + The following output is logged: |
| 117 | + |
| 118 | + .. code-block:: console |
| 119 | +
|
| 120 | + Secondary slot image is uncompressed |
| 121 | +
|
| 122 | + This indicates that the loaded firmware update has not been compressed at all. |
| 123 | + This is a suboptimal and incorrect update. |
| 124 | + |
| 125 | +For information about how these compression types are configured in the :ref:`nrf_compression` library, see :ref:`nrf_compression_config_compression_types` in its documentation. |
| 126 | + |
| 127 | +Dependencies |
| 128 | +************ |
| 129 | + |
| 130 | +The sample uses the following Zephyr library: |
| 131 | + |
| 132 | +* :ref:`zephyr:mcu_mgr` |
| 133 | + |
| 134 | +It also uses the following |NCS| library: |
| 135 | + |
| 136 | +* :ref:`partition_manager` |
| 137 | +* :ref:`nrf_compression` |
0 commit comments