Galanakis, Minos | 41f8597 | 2019-09-30 15:56:40 +0100 | [diff] [blame^] | 1 | ########### |
| 2 | Secure boot |
| 3 | ########### |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 4 | For secure devices it is security critical to enforce firmware authenticity to |
| 5 | protect against execution of malicious software. This is implemented by building |
| 6 | a trust chain where each step in the execution chain authenticates the next |
| 7 | step before execution. The chain of trust in based on a "Root of Trust" which |
| 8 | is implemented using asymmetric cryptography. The Root of Trust is a combination |
| 9 | of an immutable bootloader and a public key (ROTPK). |
| 10 | |
Tamas Ban | 07a11a2 | 2019-09-23 13:54:15 +0100 | [diff] [blame] | 11 | .. Warning:: |
| 12 | In order to implement a proper chain of trust functionality, it is |
| 13 | mandatory that the first stage bootloader and ROTPK is stored in an |
| 14 | **immutable** way. To achieve this the bootloader code must be stored and |
| 15 | executed from ROM or such part of flash memory which supports write |
| 16 | protection. ROTPK can be stored in a one-time-programmable (OTP) memory. If |
| 17 | the SoC has a built-in BL1 (immutable) bootloader and the immutability of |
| 18 | TF-M secure boot code is not guaranteed then TF-M secure boot code must be |
| 19 | authenticated by BL1 bootloader before execution. If immutability of root |
| 20 | of trust (first stage bootloader + ROTPK) is not ensured then there is a |
| 21 | risk that the secure boot process could be bypassed, which could lead to |
| 22 | arbitrary code execution on the device. Current TF-M secure boot code is |
| 23 | intended to be a second stage bootloader, therefore it requires |
| 24 | authentication before execution. If TF-M secure boot code is used as a first |
| 25 | stage bootloader then it must be stored according to the above requirements. |
| 26 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 27 | ******************************* |
| 28 | Second stage bootloader in TF-M |
| 29 | ******************************* |
| 30 | To implement secure boot functionality an external project MCUBoot has been |
| 31 | integrated to TF-M. For further information please refer to the |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 32 | `MCUBoot homepage <https://www.mcuboot.com/>`__. Original source-code is |
| 33 | available at `GitHub <https://github.com/JuulLabs-OSS/mcuboot>`__. This document |
| 34 | contains information about MCUBoot modifications and how MCUBoot has been |
| 35 | integrated to TF-M. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 36 | |
| 37 | Bootloader is started when CPU is released from reset. It runs in secure mode. |
| 38 | It authenticates the firmware image by hash (SHA-256) and digital signature |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 39 | (RSA-3072) validation. Public key, that the checks happens against, can be built |
| 40 | into the bootloader image or can be provisioned to the SoC during manufacturing. |
| 41 | Metadata of the image is delivered together with the image itself in a header |
| 42 | and trailer section. In case of successful authentication, bootloader passes |
| 43 | execution to the secure image. Execution never returns to bootloader until |
| 44 | next reset. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 45 | |
| 46 | A default RSA key pair is stored in the repository, public key is in ``keys.c`` |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 47 | and private key is in ``root-rsa-3072.pem``. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 48 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 49 | .. Warning:: |
| 50 | DO NOT use them in production code, they are exclusively for testing! |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 51 | |
| 52 | Private key must be stored in a safe place outside of the repository. |
| 53 | ``Imgtool.py`` can be used to generate new key pairs. |
| 54 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 55 | The bootloader can handle the secure and non-secure images independently |
| 56 | (multiple image boot) or together (single image boot). In case of multiple image |
| 57 | boot they are signed independently with different keys and they can be updated |
| 58 | separately. In case of single image boot the secure and non-secure image is |
| 59 | handled as a single blob, therefore they must be contiguous in the device |
| 60 | memory. In this case they are signed together and also they can be updated only |
| 61 | together. In order to have the same artefacts at the end of the build regardless |
| 62 | of how the images are handled (independently or together) the images are always |
| 63 | concatenated. In case of single image boot they are concatenated first and then |
| 64 | signed. In case of multiple image boot they are separately signed first and then |
| 65 | concatenated. Preparation of payload is done by Python scripts: |
| 66 | ``bl2/ext/mcuboot/scripts/``. At the end of a successful build the signed TF-M |
| 67 | payload can be found in: ``<build_dir>/install/outputs/fvp/tfm_sign.bin`` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 68 | |
| 69 | ********************* |
| 70 | Integration with TF-M |
| 71 | ********************* |
| 72 | MCUBoot assumes a predefined memory layout which is described below (applicable |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 73 | for AN521). It is mandatory to define the primary slot and the secondary slot |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 74 | partitions, but their size and location can be changed:: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 75 | |
| 76 | - 0x0000_0000 - 0x0007_FFFF: BL2 bootloader - MCUBoot |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 77 | - 0x0008_0000 - 0x000F_FFFF: Primary slot : Single binary blob: |
| 78 | Secure + Non-Secure image; |
| 79 | Primary memory partition |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 80 | - 0x0008_0000 - 0x0008_03FF: Common image header |
| 81 | - 0x0008_0400 - 0x0008_xxxx: Secure image |
| 82 | - 0x0008_xxxx - 0x0010_03FF: Padding (with 0xFF) |
| 83 | - 0x0010_0400 - 0x0010_xxxx: Non-secure image |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 84 | - 0x0010_xxxx - 0x0010_xxxx: Hash value(SHA256), RSA signature and other |
| 85 | metadata of combined image |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 86 | |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 87 | - 0x0018_0000 - 0x0027_FFFF: Secondary slot : Secure + Non-Secure image; |
| 88 | Secondary memory partition, structured |
| 89 | identically to the primary slot |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 90 | - 0x0028_0000 - 0x0037_FFFF: Scratch area, only used during image |
| 91 | swapping |
| 92 | |
| 93 | Multiple image boot requires a slightly different layout:: |
| 94 | |
| 95 | - 0x0000_0000 - 0x0007_FFFF: BL2 bootloader - MCUBoot |
| 96 | - 0x0008_0000 - 0x000F_FFFF: Primary slot : Secure image |
| 97 | - 0x0008_0000 - 0x0008_03FF: Secure image header |
| 98 | - 0x0008_0400 - 0x000x_xxxx: Secure image |
| 99 | - 0x000x_xxxx - 0x000x_xxxx: Hash value(SHA256), RSA signature and other |
| 100 | metadata of secure image |
| 101 | |
| 102 | - 0x0010_0000 - 0x0017_FFFF: Primary slot : Non-secure image |
| 103 | - 0x0010_0000 - 0x0010_03FF: Non-secure image header |
| 104 | - 0x0010_0400 - 0x001x_xxxx: Non-secure image |
| 105 | - 0x001x_xxxx - 0x001x_xxxx: Hash value(SHA256), RSA signature and other |
| 106 | metadata of non-secure image |
| 107 | |
| 108 | - 0x0018_0000 - 0x001F_FFFF: Secondary slot : Secure image |
| 109 | - 0x0020_0000 - 0x0027_FFFF: Secondary slot : Non-secure image |
| 110 | |
| 111 | - 0x0028_0000 - 0x002F_FFFF: Scratch area, only used during image |
| 112 | swapping, used for secure and non-secure |
| 113 | image as well |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 114 | |
| 115 | ************************** |
| 116 | Firmware upgrade operation |
| 117 | ************************** |
| 118 | MCUBoot handles only the firmware authenticity check after start-up and the |
| 119 | firmware switch part of the firmware update process. Downloading the new version |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 120 | of the firmware is out-of-scope for MCUBoot. MCUBoot supports three different |
| 121 | ways to switch to the new firmware and it is assumed that firmware images are |
| 122 | executed-in-place (XIP). The default behaviour is the overwrite-based image |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 123 | upgrade. In this case the active firmware is always executed from the primary |
| 124 | slot and the secondary slot is a staging area for new images. Before executing |
| 125 | the new firmware image, the content of the primary slot must be overwritten with |
| 126 | the content of the secondary slot (the new firmware image). The second option is |
| 127 | the image swapping strategy when the content of the two memory slots must be |
| 128 | physically swapped. This needs the scratch area to be defined in the memory |
| 129 | layout. The third option is the non-swapping version, which eliminates the |
| 130 | complexity of image swapping and its administration. Active image can be |
| 131 | executed from either memory slot, but new firmware must be linked to the address |
| 132 | space of the proper (currently inactive) memory slot. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 133 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 134 | Overwrite operation |
Tamas Ban | e7efdc6 | 2019-06-05 13:14:52 +0100 | [diff] [blame] | 135 | =================== |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 136 | Active image is stored in the primary slot, and this image is started always by |
| 137 | the bootloader. Therefore images must be linked to the primary slot. If the |
| 138 | bootloader finds a valid image in the secondary slot, which is marked for |
| 139 | upgrade, then the content of the primary slot will be simply overwritten with |
| 140 | the content of the secondary slot, before starting the new image from the |
| 141 | primary slot. After the content of the primary slot has been successfully |
| 142 | overwritten, the header and trailer of the new image in the secondary slot is |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 143 | erased to prevent the triggering of another unnecessary image upgrade after a |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 144 | restart. The overwrite operation is fail-safe and resistant to power-cut |
| 145 | failures. For more details please refer to the MCUBoot |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 146 | `documentation <https://www.mcuboot.com/mcuboot/design.html>`__. |
| 147 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 148 | Swapping operation |
| 149 | ================== |
| 150 | This operation can be set with the ``MCUBOOT_UPGRADE_STRATEGY`` compile time |
| 151 | switch (see `Build time configuration`_). With swapping image upgrade strategy |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 152 | the active image is also stored in the primary slot and it will always be |
| 153 | started by the bootloader. If the bootloader finds a valid image in the |
| 154 | secondary slot, which is marked for upgrade, then contents of the primary slot |
| 155 | and the secondary slot will be swapped, before starting the new image from the |
| 156 | primary slot. Scratch area is used as a temporary storage place during image |
| 157 | swapping. Update mark from the secondary slot is removed when the swapping is |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 158 | successful. The boot loader can revert the swapping as a fall-back mechanism to |
| 159 | recover the previous working firmware version after a faulty update. The swap |
| 160 | operation is fail-safe and resistant to power-cut failures. For more details |
| 161 | please refer to the MCUBoot |
| 162 | `documentation <https://www.mcuboot.com/mcuboot/design.html>`__. |
| 163 | |
| 164 | .. Note:: |
| 165 | |
| 166 | After a successful image upgrade the firmware can mark itself as "OK" at |
| 167 | runtime by setting the image_ok flag in the flash. When this happens, the |
| 168 | swap is made "permanent" and MCUBoot will then still choose to run it |
| 169 | during the next boot. Currently TF-M does not set the image_ok flag, |
| 170 | therefore the bootloader will always perform a "revert" (swap the images |
| 171 | back) during the next boot. |
| 172 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 173 | Non-swapping operation |
| 174 | ====================== |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 175 | This operation can be set with the ``MCUBOOT_UPGRADE_STRATEGY`` compile time |
| 176 | switch (see `Build time configuration`_). When enabling non-swapping operation |
| 177 | then the active image flag is moved between slots during firmware upgrade. If |
| 178 | firmware is executed-in-place (XIP), then two firmware images must be generated. |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 179 | One of them is linked to be executed from the primary slot memory region and the |
| 180 | other from the secondary slot. The firmware upgrade client, which downloads the |
| 181 | new image, must be aware, which slot hosts the active firmware and which acts as |
| 182 | a staging area and it is responsible for downloading the proper firmware image. |
| 183 | At boot time MCUBoot inspects the version number in the image header and passes |
| 184 | execution to the newer firmware version. New image must be marked for upgrade |
| 185 | which is automatically done by Python scripts at compile time. Image |
| 186 | verification is done the same way in all operational modes. If new image fails |
| 187 | during authentication then MCUBoot erases the memory slot and starts the other |
| 188 | image, after successful authentication. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 189 | |
| 190 | At build time automatically two binaries are generated:: |
| 191 | |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 192 | <build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin : Image linked for the primary slot memory partition |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 193 | |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 194 | <build_dir>/install/outputs/fvp/tfm_s_ns_signed_1.bin : Image linked for the secondary slot memory partition |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 195 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 196 | .. Note:: |
| 197 | |
| 198 | Only single image boot is supported with non-swapping upgrade mode. |
| 199 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 200 | RAM Loading firmware upgrade |
| 201 | ============================ |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 202 | Musca-A supports an image upgrade mode that is separate to the other (overwrite, |
| 203 | swapping and non-swapping) modes. This is the ``RAM loading`` mode (please refer |
| 204 | to the table below). Like the non-swapping mode, this selects the newest image |
| 205 | by reading the image version numbers in the image headers, but instead of |
| 206 | executing it in place, the newest image is copied to RAM for execution. The load |
| 207 | address, the location in RAM where the image is copied to, is stored in the |
| 208 | image header. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 209 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 210 | .. Note:: |
| 211 | |
| 212 | Only single image boot is supported with RAM loading upgrade mode. |
| 213 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 214 | Summary of different modes for image upgrade |
| 215 | ============================================ |
| 216 | Different implementations of the image upgrade operation (whether through |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 217 | overwriting, swapping, non-swapping or loading into RAM and executing from |
| 218 | there) are supported by the platforms. The table below shows which of these |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 219 | modes are supported by which platforms: |
| 220 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 221 | +----------+-----------------+----------------------------------------------------------+ |
| 222 | | | Without BL2 [1]_| With BL2 [2]_ | |
| 223 | +==========+=================+===============+==========+=============+=================+ |
| 224 | | | XIP | XIP | XIP | XIP | Not XIP | |
| 225 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 226 | | | | Overwrite [3]_| Swap [4]_| No-swap [5]_| RAM loading [6]_| |
| 227 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 228 | | AN521 | Yes | Yes | Yes | Yes | No | |
| 229 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 230 | | AN519 | Yes | Yes | Yes | Yes | No | |
| 231 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
Marton Berke | 6fd21f1 | 2019-07-02 13:43:07 +0200 | [diff] [blame] | 232 | | AN539 | Yes | Yes | Yes | Yes | No | |
| 233 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 234 | | Musca-A | No | No | No | No | Yes | |
| 235 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 236 | | Musca-B1 | Yes | No | No | Yes | No | |
| 237 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 238 | | AN524 | Yes | No | No | Yes | No | |
| 239 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 240 | |
| 241 | .. [1] To disable BL2, please turn off the ``BL2`` compiler switch in the |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 242 | build configuration file (``bl2/ext/mcuboot/MCUBootConfig.cmake``) or |
| 243 | in the command line |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 244 | |
| 245 | .. [2] BL2 is enabled by default |
| 246 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 247 | .. [3] The image executes in-place (XIP) and is in Overwrite mode for image |
| 248 | update by default |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 249 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 250 | .. [4] To enable XIP Swap mode, assign the "SWAP" string to the |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 251 | ``MCUBOOT_UPGRADE_STRATEGY`` configuration variable in the build |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 252 | configuration file, or include this macro definition in the command line |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 253 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 254 | .. [5] To enable XIP No-swap, assign the "NO_SWAP" string to the |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 255 | ``MCUBOOT_UPGRADE_STRATEGY`` configuration variable in the build |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 256 | configuration file, or include this macro definition in the command line |
| 257 | |
| 258 | .. [6] To enable RAM loading, assign the "RAM_LOADING" string to the |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 259 | ``MCUBOOT_UPGRADE_STRATEGY`` configuration variable in the build |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 260 | configuration file, or include this macro definition in the command line |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 261 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 262 | ******************* |
| 263 | Multiple image boot |
| 264 | ******************* |
| 265 | It is possible to update the firmware images independently to support the |
| 266 | scenario when secure and non-secure images are provided by different vendors. |
| 267 | Multiple image boot is supported only together with the overwrite and swap |
| 268 | firmware upgrade modes. |
| 269 | |
| 270 | It is possible to describe the dependencies of the images on each other in |
| 271 | order to avoid a faulty upgrade when incompatible versions would be installed. |
| 272 | These dependencies are part of the image manifest area. |
| 273 | The dependencies are composed from two parts: |
| 274 | |
| 275 | - **Image identifier:** The number of the image which the current image (whose |
| 276 | manifest area contains the dependency entry) depends on. The image identifier |
| 277 | starts from 0. |
| 278 | |
| 279 | - **Minimum version:** The minimum version of other image must be present on |
| 280 | the device by the end of the upgrade (both images might be updated at the |
| 281 | same time). |
| 282 | |
| 283 | Dependencies can be added to the images at compile time with the following |
| 284 | compile time switches: |
| 285 | |
| 286 | - ``S_IMAGE_MIN_VER`` It is added to the non-secure image and specifies the |
| 287 | minimum required version of the secure image. |
| 288 | - ``NS_IMAGE_MIN_VER`` It is added to the secure image and specifies the |
| 289 | minimum required version of the non-secure image. |
| 290 | |
| 291 | Example of how to provide the secure image minimum version:: |
| 292 | |
| 293 | cmake -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG -DS_IMAGE_MIN_VER=1.2.3+4 ../ |
| 294 | |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 295 | ******************** |
| 296 | Signature algorithms |
| 297 | ******************** |
| 298 | MbedTLS library is used to sign the images. The list of supported signing |
| 299 | algorithms: |
Tamas Ban | e7efdc6 | 2019-06-05 13:14:52 +0100 | [diff] [blame] | 300 | |
| 301 | - `RSA-2048` |
| 302 | - `RSA-3072`: default |
| 303 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 304 | Example keys stored in: |
| 305 | |
| 306 | - ``root-rsa-2048.pem`` : Used to sign single image (S+NS) or secure image |
| 307 | in case of multiple image boot |
| 308 | - ``root-rsa-2048_1.pem`` : Used to sign non-secure image in case of multiple |
| 309 | image boot |
| 310 | - ``root-rsa-3072.pem`` : Used to sign single image (S+NS) or secure image |
| 311 | in case of multiple image boot |
| 312 | - ``root-rsa-3072_1.pem`` : Used to sign non-secure image in case of multiple |
| 313 | image boot |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 314 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 315 | ************************ |
| 316 | Build time configuration |
| 317 | ************************ |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 318 | MCUBoot related compile time switches can be set in the build configuration |
| 319 | file:: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 320 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 321 | bl2/ext/mcuboot/MCUBootConfig.cmake |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 322 | |
| 323 | Compile time switches: |
| 324 | |
| 325 | - BL2 (default: True): |
| 326 | - **True:** TF-M built together with bootloader. MCUBoot is executed after |
| 327 | reset and it authenticates TF-M and starts secure code. |
| 328 | - **False:** TF-M built without bootloader. Secure image linked to the |
| 329 | beginning of the device memory and executed after reset. If it is false |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 330 | then using any of the further compile time switches is invalid. |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 331 | - MCUBOOT_UPGRADE_STRATEGY (default: "OVERWRITE_ONLY"): |
| 332 | - **"OVERWRITE_ONLY":** Default firmware upgrade operation with overwrite. |
| 333 | - **"SWAP":** Activate swapping firmware upgrade operation. |
| 334 | - **"NO_SWAP":** Activate non-swapping firmware upgrade operation. |
| 335 | - **"RAM_LOADING":** Activate RAM loading firmware upgrade operation, where |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 336 | the latest image is copied to RAM and runs from there instead of being |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 337 | executed in-place. |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 338 | - MCUBOOT_SIGNATURE_TYPE (default: RSA-3072): |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 339 | - **RSA-3072:** Image is signed with RSA-3072 algorithm |
| 340 | - **RSA-2048:** Image is signed with RSA-2048 algorithm |
| 341 | - MCUBOOT_IMAGE_NUMBER (default: 2): |
| 342 | - **1:** Single image boot, secure and non-secure images are signed and |
| 343 | updated together. |
| 344 | - **2:** Multiple image boot, secure and non-secure images are signed and |
| 345 | updatable independently. |
| 346 | - MCUBOOT_HW_KEY (default: True): |
| 347 | - **True:** The hash of public key is provisioned to the SoC and the image |
| 348 | manifest contains the whole public key. MCUBoot validates the key before |
| 349 | using it for firmware authentication, it calculates the hash of public key |
| 350 | from the manifest and compare against the retrieved key-hash from the |
| 351 | hardware. This way MCUBoot is independent from the public key(s). |
| 352 | Key(s) can be provisioned any time and by different parties. |
| 353 | - **False:** The whole public key is embedded to the bootloader code and the |
| 354 | image manifest contains only the hash of the public key. MCUBoot validates |
| 355 | the key before using it for firmware authentication, it calculates the |
| 356 | hash of built-in public key and compare against the retrieved key-hash |
| 357 | from the image manifest. After this the bootloader can verify that the |
| 358 | image was signed with a private key that corresponds to the retrieved |
| 359 | key-hash (it can have more public keys embedded in and it may have to look |
| 360 | for the matching one). All the public key(s) must be known at MCUBoot |
| 361 | build time. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 362 | |
| 363 | Image versioning |
| 364 | ================ |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 365 | An image version number is written to its header by one of the Python scripts, |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 366 | and this number is used by the bootloader when the non-swapping or RAM loading |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 367 | mode is enabled. It is also used in case of multiple image boot when the |
| 368 | bootloader checks the image dependencies if any have been added to the images. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 369 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 370 | The version number of the image (single image boot) can manually be passed in |
| 371 | through the command line in the cmake configuration step:: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 372 | |
| 373 | cmake -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG -DIMAGE_VERSION=1.2.3+4 ../ |
| 374 | |
| 375 | Alternatively, the version number can be less specific (e.g 1, 1.2, or 1.2.3), |
| 376 | where the missing numbers are automatically set to zero. The image version |
| 377 | number argument is optional, and if it is left out, then the version numbers of |
| 378 | the image(s) being built in the same directory will automatically change. In |
| 379 | this case, the last component (the build number) automatically increments from |
| 380 | the previous one: 0.0.0+1 -> 0.0.0+2, for as many times as the build is re-ran, |
| 381 | **until a number is explicitly provided**. If automatic versioning is in place |
| 382 | and then an image version number is provided for the first time, the new number |
| 383 | will take precedence and be used instead. All subsequent image versions are |
| 384 | then set to the last number that has been specified, and the build number would |
| 385 | stop incrementing. Any new version numbers that are provided will overwrite |
| 386 | the previous one: 0.0.0+1 -> 0.0.0+2. Note: To re-apply automatic image |
| 387 | versioning, please start a clean build without specifying the image version |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 388 | number at all. In case of multiple image boot there are separate compile time |
| 389 | switches for both images to provide their version: ``IMAGE_VERSION_S`` and |
| 390 | ``IMAGE_VERSION_NS``. These must be used instead of ``IMAGE_VERSION``. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 391 | |
David Vincze | 060968d | 2019-05-23 01:13:14 +0200 | [diff] [blame] | 392 | Security counter |
| 393 | ================ |
| 394 | Each signed image contains a security counter in its manifest. It is used by the |
| 395 | bootloader and its aim is to have an independent (from the image version) |
| 396 | counter to ensure rollback protection by comparing the new image's security |
| 397 | counter against the original (currently active) image's security counter during |
| 398 | the image upgrade process. It is added to the manifest (to the TLV area that is |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 399 | appended to the end of the image) by one of the Python scripts when signing the |
David Vincze | 060968d | 2019-05-23 01:13:14 +0200 | [diff] [blame] | 400 | image. The value of the security counter is security critical data and it is in |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 401 | the integrity protected part of the image. The last valid security counter |
| 402 | should always be stored in a non-volatile and trusted component of the device |
| 403 | and its value should always be increased if a security flaw was fixed in the |
| 404 | current image version. The value of the security counter (single image boot) can |
| 405 | be specified at build time in the cmake configuration step:: |
David Vincze | 060968d | 2019-05-23 01:13:14 +0200 | [diff] [blame] | 406 | |
| 407 | cmake -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG -DSECURITY_COUNTER=42 ../ |
| 408 | |
| 409 | The security counter can be independent from the image version, but not |
| 410 | necessarily. Alternatively, if it is not specified at build time with the |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 411 | ``SECURITY_COUNTER`` option the Python script will automatically generate it |
David Vincze | 060968d | 2019-05-23 01:13:14 +0200 | [diff] [blame] | 412 | from the image version number (not including the build number) and this value |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 413 | will be added to the signed image. In case of multiple image boot there are |
| 414 | separate compile time switches for both images to provide their security counter |
| 415 | value: ``SECURITY_COUNTER_S`` and ``SECURITY_COUNTER_NS``. These must be used |
| 416 | instead of ``SECURITY_COUNTER``. If these are not defined then the security |
| 417 | counter values will be derived from the corresponding image version similar to |
| 418 | the single image boot. |
| 419 | |
| 420 | *************************** |
| 421 | Signing the images manually |
| 422 | *************************** |
| 423 | Normally the build system handles the signing (computing hash over the image |
| 424 | and security critical manifest data and then signing the hash) of the firmware |
| 425 | images. However, the images also can be signed manually by using the ``imgtool`` |
| 426 | Python program which is located in the ``bl2/ext/mcuboot/scripts`` directory. |
| 427 | Issue the ``python3 imgtool.py sign --help`` command in the directory for more |
| 428 | information about the mandatory and optional arguments. The tool takes an image |
| 429 | in binary or Intel Hex format and adds a header and trailer that MCUBoot is |
| 430 | expecting. In case of single image boot after a successful build the |
| 431 | ``tfm_full.bin`` build artifact (contains the concatenated secure and non-secure |
| 432 | images) must be passed to the script and in case of multiple image boot the |
| 433 | ``tfm_s.bin`` and ``tfm_ns.bin`` binaries can be passed to prepare the signed |
| 434 | images. |
| 435 | |
| 436 | Signing the secure image manually in case of multiple image boot |
| 437 | ================================================================ |
| 438 | |
| 439 | :: |
| 440 | |
| 441 | python3 bl2/ext/mcuboot/scripts/imgtool.py sign \ |
| 442 | --layout <build_dir>/image_macros_preprocessed_s.c \ |
| 443 | -k <tfm_dir>/bl2/ext/mcuboot/root-rsa-3072.pem \ |
| 444 | --public-key-format full \ |
| 445 | --align 1 \ |
| 446 | -v 1.2.3+4 \ |
| 447 | -d "(1,1.2.3+0)" \ |
| 448 | -s 42 \ |
| 449 | -H 0x400 \ |
| 450 | <build_dir>/install/outputs/AN521/tfm_s.bin \ |
| 451 | <build_dir>/tfm_s_signed.bin |
David Vincze | 060968d | 2019-05-23 01:13:14 +0200 | [diff] [blame] | 452 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 453 | ************************ |
| 454 | Testing firmware upgrade |
| 455 | ************************ |
| 456 | As downloading the new firmware image is out of scope for MCUBoot, the update |
| 457 | process is started from a state where the original and the new image are already |
| 458 | programmed to the appropriate memory slots. To generate the original and a new |
| 459 | firmware package, TF-M is built twice with different build configurations. |
| 460 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 461 | Overwriting firmware upgrade |
Tamas Ban | e7efdc6 | 2019-06-05 13:14:52 +0100 | [diff] [blame] | 462 | ============================ |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 463 | Run TF-M build twice with ``MCUBOOT_IMAGE_NUMBER`` set to "1" in both cases |
| 464 | (single image boot), but with two different build configurations: default and |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 465 | regression. Save the artifacts between builds, because second run can overwrite |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 466 | original binaries. Download default build to the primary slot and regression |
| 467 | build to the secondary slot. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 468 | |
| 469 | Executing firmware upgrade on FVP_MPS2_AEMv8M |
| 470 | --------------------------------------------- |
| 471 | .. code-block:: bash |
| 472 | |
| 473 | <DS5_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \ |
| 474 | --parameter fvp_mps2.platform_type=2 \ |
| 475 | --parameter cpu0.baseline=0 \ |
| 476 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 477 | --parameter cpu0.semihosting-enable=0 \ |
| 478 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 479 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 480 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 481 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 482 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 483 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 484 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 485 | --application cpu0=<build_dir>/bl2/ext/mcuboot/mcuboot.axf \ |
| 486 | --data cpu0=<default_build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10080000 \ |
| 487 | --data cpu0=<regresssion_build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10180000 |
| 488 | |
| 489 | Executing firmware upgrade on SSE 200 FPGA on MPS2 board |
| 490 | -------------------------------------------------------- |
| 491 | |
| 492 | :: |
| 493 | |
| 494 | TITLE: Versatile Express Images Configuration File |
| 495 | [IMAGES] |
| 496 | TOTALIMAGES: 3 ;Number of Images (Max: 32) |
| 497 | IMAGE0ADDRESS: 0x00000000 |
| 498 | IMAGE0FILE: \Software\mcuboot.axf ; BL2 bootloader |
| 499 | IMAGE1ADDRESS: 0x10080000 |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 500 | IMAGE1FILE: \Software\tfm_sig1.bin ; TF-M default test binary blob |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 501 | IMAGE2ADDRESS: 0x10180000 |
| 502 | IMAGE2FILE: \Software\tfm_sig2.bin ; TF-M regression test binary blob |
| 503 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 504 | The following message will be shown in case of successful firmware upgrade: |
| 505 | |
| 506 | :: |
| 507 | |
| 508 | [INF] Starting bootloader |
| 509 | [INF] Swap type: test |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 510 | [INF] Image upgrade secondary slot -> primary slot |
| 511 | [INF] Erasing the primary slot |
| 512 | [INF] Copying the secondary slot to the primary slot: 0x100000 bytes |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 513 | [INF] Bootloader chainload address offset: 0x80000 |
| 514 | [INF] Jumping to the first image slot |
| 515 | [Sec Thread] Secure image initializing! |
| 516 | |
| 517 | #### Execute test suites for the Secure area #### |
| 518 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 519 | ... |
| 520 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 521 | To update the secure and non-secure images separately (multiple image boot), |
| 522 | set the ``MCUBOOT_IMAGE_NUMBER`` switch to "2" (this is the default |
| 523 | configuration value) and follow the same instructions as in case of single image |
| 524 | boot. |
| 525 | |
| 526 | Executing multiple firmware upgrades on SSE 200 FPGA on MPS2 board |
| 527 | ------------------------------------------------------------------ |
| 528 | |
| 529 | :: |
| 530 | |
| 531 | TITLE: Versatile Express Images Configuration File |
| 532 | [IMAGES] |
| 533 | TOTALIMAGES: 4 ;Number of Images (Max: 32) |
| 534 | IMAGE0ADDRESS: 0x00000000 |
| 535 | IMAGE0FILE: \Software\mcuboot.axf ; BL2 bootloader |
| 536 | IMAGE1ADDRESS: 0x10080000 |
| 537 | IMAGE1FILE: \Software\tfm_sign.bin ; TF-M default test binary blob |
| 538 | IMAGE2ADDRESS: 0x10180000 |
| 539 | IMAGE2FILE: \Software\tfm_ss1.bin ; TF-M regression test secure (signed) image |
| 540 | IMAGE3ADDRESS: 0x10200000 |
| 541 | IMAGE3FILE: \Software\tfm_nss1.bin ; TF-M regression test non-secure (signed) image |
| 542 | |
| 543 | Note that both the concatenated binary blob (the images are signed separately |
| 544 | and then concatenated) and the separate signed images can be downloaded to the |
| 545 | device because on this platform (AN521) both the primary slots and the secondary |
| 546 | slots are contiguous areas in the Flash (see `Integration with TF-M`_). The |
| 547 | following message will be shown in case of successful firmware upgrades: |
| 548 | |
| 549 | :: |
| 550 | |
| 551 | [INF] Starting bootloader |
| 552 | [INF] Swap type: test |
| 553 | [INF] Swap type: test |
| 554 | [INF] Image upgrade secondary slot -> primary slot |
| 555 | [INF] Erasing the primary slot |
| 556 | [INF] Copying the secondary slot to the primary slot: 0x80000 bytes |
| 557 | [INF] Image upgrade secondary slot -> primary slot |
| 558 | [INF] Erasing the primary slot |
| 559 | [INF] Copying the secondary slot to the primary slot: 0x80000 bytes |
| 560 | [INF] Bootloader chainload address offset: 0x80000 |
| 561 | [INF] Jumping to the first image slot |
| 562 | [Sec Thread] Secure image initializing! |
| 563 | TFM level is: 1 |
| 564 | [Sec Thread] Jumping to non-secure code... |
| 565 | |
| 566 | #### Execute test suites for the Secure area #### |
| 567 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 568 | ... |
| 569 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 570 | Swapping firmware upgrade |
| 571 | ============================= |
| 572 | Follow the same instructions and platform related configurations as in case of |
| 573 | overwriting build including these changes: |
| 574 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 575 | - Set the ``MCUBOOT_UPGRADE_STRATEGY`` compile time switch to "SWAP" |
| 576 | before build. |
| 577 | - Set the ``MCUBOOT_IMAGE_NUMBER`` compile time switch to "1" (single image |
| 578 | boot) or "2" (multiple image boot) before build. |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 579 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 580 | During single image boot the following message will be shown in case of |
| 581 | successful firmware upgrade, ``Swap type: test`` indicates that images were |
| 582 | swapped: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 583 | |
| 584 | :: |
| 585 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 586 | [INF] Starting bootloader |
| 587 | [INF] Image 0: magic= good, copy_done=0x3, image_ok=0x3 |
| 588 | [INF] Scratch: magic= bad, copy_done=0x0, image_ok=0x2 |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 589 | [INF] Boot source: primary slot |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 590 | [INF] Swap type: test |
| 591 | [INF] Bootloader chainload address offset: 0x80000 |
| 592 | [INF] Jumping to the first image slot |
| 593 | [Sec Thread] Secure image initializing! |
| 594 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 595 | #### Execute test suites for the Secure area #### |
| 596 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 597 | ... |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 598 | |
| 599 | Non-swapping firmware upgrade |
| 600 | ============================= |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 601 | Follow the same instructions and platform related configurations as in case of |
| 602 | overwriting build including these changes: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 603 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 604 | - Set the ``MCUBOOT_UPGRADE_STRATEGY`` compile time switch to "NO_SWAP" |
| 605 | before build. |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 606 | - Make sure the image version number was increased between the two build runs |
| 607 | either by specifying it manually or by checking in the build log that it was |
| 608 | incremented automatically. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 609 | |
| 610 | Executing firmware upgrade on FVP_MPS2_AEMv8M |
| 611 | --------------------------------------------- |
| 612 | |
| 613 | .. code-block:: bash |
| 614 | |
| 615 | <DS5_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \ |
| 616 | --parameter fvp_mps2.platform_type=2 \ |
| 617 | --parameter cpu0.baseline=0 \ |
| 618 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 619 | --parameter cpu0.semihosting-enable=0 \ |
| 620 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 621 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 622 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 623 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 624 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 625 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 626 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 627 | --application cpu0=<build_dir>/bl2/ext/mcuboot/mcuboot.axf \ |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 628 | --data cpu0=<default_build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10080000 \ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 629 | --data cpu0=<regresssion_build_dir>/install/outputs/fvp/tfm_s_ns_signed_1.bin@0x10180000 |
| 630 | |
| 631 | Executing firmware upgrade on SSE 200 FPGA on MPS2 board |
| 632 | -------------------------------------------------------- |
| 633 | |
| 634 | :: |
| 635 | |
| 636 | TITLE: Versatile Express Images Configuration File |
| 637 | [IMAGES] |
| 638 | TOTALIMAGES: 3 ;Number of Images (Max: 32) |
| 639 | IMAGE0ADDRESS: 0x00000000 |
| 640 | IMAGE0FILE: \Software\mcuboot.axf ; BL2 bootloader |
| 641 | IMAGE1ADDRESS: 0x10080000 |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 642 | IMAGE1FILE: \Software\tfm_sign.bin ; TF-M default test binary blob |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 643 | IMAGE2ADDRESS: 0x10180000 |
| 644 | IMAGE2FILE: \Software\tfm_sig1.bin ; TF-M regression test binary blob |
| 645 | |
| 646 | Executing firmware upgrade on Musca-B1 board |
| 647 | -------------------------------------------- |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 648 | After the two images have been built, they can be concatenated to create the |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 649 | combined image using ``srec_cat``: |
| 650 | |
| 651 | - Linux:: |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 652 | |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 653 | srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 tfm_sign_1.bin -Binary -offset 0xA0E0000 -o tfm.hex -Intel |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 654 | |
| 655 | - Windows:: |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 656 | |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 657 | srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 tfm_sign_1.bin -Binary -offset 0xA0E0000 -o tfm.hex -Intel |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 658 | |
| 659 | The following message will be shown in case of successful firmware upgrade, |
| 660 | notice that image with higher version number (``version=1.2.3.5``) is executed: |
| 661 | |
| 662 | :: |
| 663 | |
| 664 | [INF] Starting bootloader |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 665 | [INF] Image 0: version=1.2.3.4, magic= good, image_ok=0x3 |
| 666 | [INF] Image 1: version=1.2.3.5, magic= good, image_ok=0x3 |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 667 | [INF] Booting image from the secondary slot |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 668 | [INF] Bootloader chainload address offset: 0xa0000 |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 669 | [INF] Jumping to the first image slot |
| 670 | [Sec Thread] Secure image initializing! |
| 671 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 672 | #### Execute test suites for the Secure area #### |
| 673 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 674 | ... |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 675 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 676 | Executing firmware upgrade on CoreLink SSE-200 Subsystem for MPS3 (AN524) |
| 677 | ------------------------------------------------------------------------- |
| 678 | |
| 679 | :: |
| 680 | |
| 681 | TITLE: Arm MPS3 FPGA prototyping board Images Configuration File |
| 682 | |
| 683 | [IMAGES] |
| 684 | TOTALIMAGES: 3 ;Number of Images (Max: 32) |
| 685 | |
| 686 | IMAGE0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE |
| 687 | IMAGE0ADDRESS: 0x00000000 |
| 688 | IMAGE0FILE: \SOFTWARE\mcuboot.bin ;BL2 bootloader |
| 689 | IMAGE1UPDATE: AUTO |
| 690 | IMAGE1ADDRESS: 0x00040000 |
| 691 | IMAGE1FILE: \SOFTWARE\tfm_sig0.bin ;TF-M example application binary blob |
| 692 | IMAGE2UPDATE: AUTO |
| 693 | IMAGE2ADDRESS: 0x000C0000 |
| 694 | IMAGE2FILE: \SOFTWARE\tfm_sig1.bin ;TF-M regression test binary blob |
| 695 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 696 | RAM loading firmware upgrade |
| 697 | ============================ |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 698 | To enable RAM loading, please set ``MCUBOOT_UPGRADE_STRATEGY`` to "RAM_LOADING" |
| 699 | (either in the configuration file or through the command line), and then specify |
| 700 | a destination load address in RAM where the image can be copied to and executed |
| 701 | from. The ``IMAGE_LOAD_ADDRESS`` macro must be specified in the target dependent |
| 702 | files, for example with Musca-A, its ``flash_layout.h`` file in the ``platform`` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 703 | folder should include ``#define IMAGE_LOAD_ADDRESS #0x10020000`` |
| 704 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 705 | Executing firmware upgrade on Musca-A board |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 706 | -------------------------------------------- |
| 707 | After two images have been built, they can be concatenated to create the |
| 708 | combined image using ``srec_cat``: |
| 709 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 710 | - Linux:: |
| 711 | |
| 712 | srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0x200000 tfm_sign_old.bin -Binary -offset 0x220000 tfm_sign_new.bin -Binary -offset 0x320000 -o tfm.hex -Intel |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 713 | |
| 714 | - Windows:: |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 715 | |
David Vincze | 9c60901 | 2019-08-22 13:37:21 +0200 | [diff] [blame] | 716 | srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0x200000 tfm_sign_old.bin -Binary -offset 0x220000 tfm_sign_new.bin -Binary -offset 0x320000 -o tfm.hex -Intel |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 717 | |
| 718 | The following message will be shown in case of successful firmware upgrade when, |
| 719 | RAM loading is enabled, notice that image with higher version number |
| 720 | (``version=0.0.0.2``) is executed: |
| 721 | |
| 722 | :: |
| 723 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 724 | [INF] Starting bootloader |
| 725 | [INF] Image 0: version=0.0.0.1, magic= good, image_ok=0x3 |
| 726 | [INF] Image 1: version=0.0.0.2, magic= good, image_ok=0x3 |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 727 | [INF] Image has been copied from the secondary slot in flash to SRAM address 0x10020000 |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 728 | [INF] Booting image from SRAM at address 0x10020000 |
| 729 | [INF] Bootloader chainload address offset: 0x20000 |
| 730 | [INF] Jumping to the first image slot |
| 731 | [Sec Thread] Secure image initializing! |
| 732 | |
| 733 | -------------- |
| 734 | |
| 735 | *Copyright (c) 2018-2019, Arm Limited. All rights reserved.* |