Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 1 | ############################## |
| 2 | Trusted Firmware M secure boot |
| 3 | ############################## |
| 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 | |
| 11 | ******************************* |
| 12 | Second stage bootloader in TF-M |
| 13 | ******************************* |
| 14 | To implement secure boot functionality an external project MCUBoot has been |
| 15 | integrated to TF-M. For further information please refer to the |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 16 | `MCUBoot homepage <https://www.mcuboot.com/>`__. Original source-code is |
| 17 | available at `GitHub <https://github.com/JuulLabs-OSS/mcuboot>`__. This document |
| 18 | contains information about MCUBoot modifications and how MCUBoot has been |
| 19 | integrated to TF-M. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 20 | |
| 21 | Bootloader is started when CPU is released from reset. It runs in secure mode. |
| 22 | It authenticates the firmware image by hash (SHA-256) and digital signature |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 23 | (RSA-3072) validation. Public key, that the checks happens against, is built |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 24 | into the bootloader image. Metadata of the image is delivered together with the |
| 25 | image itself in a header and trailer section. In case of successful |
| 26 | authentication, bootloader passes execution to the secure image. Execution never |
| 27 | returns to bootloader until next reset. |
| 28 | |
| 29 | 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] | 30 | and private key is in ``root-rsa-3072.pem``. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 31 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 32 | .. Warning:: |
| 33 | DO NOT use them in production code, they are exclusively for testing! |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 34 | |
| 35 | Private key must be stored in a safe place outside of the repository. |
| 36 | ``Imgtool.py`` can be used to generate new key pairs. |
| 37 | |
| 38 | The bootloader handles the secure and non-secure images as a single blob which |
| 39 | is contiguous in the device memory. At compile time these images are |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 40 | concatenated and signed with RSA-3072 digital signature. Preparation of payload |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 41 | is done by Python scripts: ``bl2/ext/mcuboot/scripts/``. At the end of a |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 42 | successful build signed TF-M payload can be found in: |
| 43 | ``<build_dir>/install/outputs/fvp/tfm_sign.bin`` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 44 | |
| 45 | ********************* |
| 46 | Integration with TF-M |
| 47 | ********************* |
| 48 | MCUBoot assumes a predefined memory layout which is described below (applicable |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 49 | for AN521). It is mandatory to define the primary slot and the secondary slot |
| 50 | partitions, but their size can be changed:: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 51 | |
| 52 | - 0x0000_0000 - 0x0007_FFFF: BL2 bootloader - MCUBoot |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 53 | - 0x0008_0000 - 0x000F_FFFF: Primary slot : Single binary blob: |
| 54 | Secure + Non-Secure image; |
| 55 | Primary memory partition |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 56 | - 0x0008_0000 - 0x0008_03FF: Common image header |
| 57 | - 0x0008_0400 - 0x0008_xxxx: Secure image |
| 58 | - 0x0008_xxxx - 0x0010_03FF: Padding (with 0xFF) |
| 59 | - 0x0010_0400 - 0x0010_xxxx: Non-secure image |
| 60 | - 0x0010_xxxx - 0x0010_xxxx: Hash value(SHA256) and RSA signature |
| 61 | of combined image |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 62 | |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 63 | - 0x0018_0000 - 0x0027_FFFF: Secondary slot : Secure + Non-Secure image; |
| 64 | Secondary memory partition, structured |
| 65 | identically to the primary slot |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 66 | - 0x0028_0000 - 0x0037_FFFF: Scratch area, only used during image swapping |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 67 | |
| 68 | ************************** |
| 69 | Firmware upgrade operation |
| 70 | ************************** |
| 71 | MCUBoot handles only the firmware authenticity check after start-up and the |
| 72 | firmware switch part of the firmware update process. Downloading the new version |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 73 | of the firmware is out-of-scope for MCUBoot. MCUBoot supports three different |
| 74 | ways to switch to the new firmware and it is assumed that firmware images are |
| 75 | executed-in-place (XIP). The default behaviour is the overwrite-based image |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 76 | upgrade. In this case the active firmware is always executed from the primary |
| 77 | slot and the secondary slot is a staging area for new images. Before executing |
| 78 | the new firmware image, the content of the primary slot must be overwritten with |
| 79 | the content of the secondary slot (the new firmware image). The second option is |
| 80 | the image swapping strategy when the content of the two memory slots must be |
| 81 | physically swapped. This needs the scratch area to be defined in the memory |
| 82 | layout. The third option is the non-swapping version, which eliminates the |
| 83 | complexity of image swapping and its administration. Active image can be |
| 84 | executed from either memory slot, but new firmware must be linked to the address |
| 85 | space of the proper (currently inactive) memory slot. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 86 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 87 | Overwrite operation |
Tamas Ban | e7efdc6 | 2019-06-05 13:14:52 +0100 | [diff] [blame] | 88 | =================== |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 89 | Active image is stored in the primary slot, and this image is started always by |
| 90 | the bootloader. Therefore images must be linked to the primary slot. If the |
| 91 | bootloader finds a valid image in the secondary slot, which is marked for |
| 92 | upgrade, then the content of the primary slot will be simply overwritten with |
| 93 | the content of the secondary slot, before starting the new image from the |
| 94 | primary slot. After the content of the primary slot has been successfully |
| 95 | overwritten, the header and trailer of the new image in the secondary slot is |
| 96 | erased to prevent the triggering of another unncessary image uprade after a |
| 97 | restart. The overwrite operation is fail-safe and resistant to power-cut |
| 98 | failures. For more details please refer to the MCUBoot |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 99 | `documentation <https://www.mcuboot.com/mcuboot/design.html>`__. |
| 100 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 101 | Swapping operation |
| 102 | ================== |
| 103 | This operation can be set with the ``MCUBOOT_UPGRADE_STRATEGY`` compile time |
| 104 | switch (see `Build time configuration`_). With swapping image upgrade strategy |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 105 | the active image is also stored in the primary slot and it will always be |
| 106 | started by the bootloader. If the bootloader finds a valid image in the |
| 107 | secondary slot, which is marked for upgrade, then contents of the primary slot |
| 108 | and the secondary slot will be swapped, before starting the new image from the |
| 109 | primary slot. Scratch area is used as a temporary storage place during image |
| 110 | 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] | 111 | successful. The boot loader can revert the swapping as a fall-back mechanism to |
| 112 | recover the previous working firmware version after a faulty update. The swap |
| 113 | operation is fail-safe and resistant to power-cut failures. For more details |
| 114 | please refer to the MCUBoot |
| 115 | `documentation <https://www.mcuboot.com/mcuboot/design.html>`__. |
| 116 | |
| 117 | .. Note:: |
| 118 | |
| 119 | After a successful image upgrade the firmware can mark itself as "OK" at |
| 120 | runtime by setting the image_ok flag in the flash. When this happens, the |
| 121 | swap is made "permanent" and MCUBoot will then still choose to run it |
| 122 | during the next boot. Currently TF-M does not set the image_ok flag, |
| 123 | therefore the bootloader will always perform a "revert" (swap the images |
| 124 | back) during the next boot. |
| 125 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 126 | Non-swapping operation |
| 127 | ====================== |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 128 | This operation can be set with the ``MCUBOOT_UPGRADE_STRATEGY`` compile time |
| 129 | switch (see `Build time configuration`_). When enabling non-swapping operation |
| 130 | then the active image flag is moved between slots during firmware upgrade. If |
| 131 | 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^] | 132 | One of them is linked to be executed from the primary slot memory region and the |
| 133 | other from the secondary slot. The firmware upgrade client, which downloads the |
| 134 | new image, must be aware, which slot hosts the active firmware and which acts as |
| 135 | a staging area and it is responsible for downloading the proper firmware image. |
| 136 | At boot time MCUBoot inspects the version number in the image header and passes |
| 137 | execution to the newer firmware version. New image must be marked for upgrade |
| 138 | which is automatically done by Python scripts at compile time. Image |
| 139 | verification is done the same way in all operational modes. If new image fails |
| 140 | during authentication then MCUBoot erases the memory slot and starts the other |
| 141 | image, after successful authentication. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 142 | |
| 143 | At build time automatically two binaries are generated:: |
| 144 | |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 145 | <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] | 146 | |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 147 | <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] | 148 | |
| 149 | RAM Loading firmware upgrade |
| 150 | ============================ |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 151 | Musca-A supports an image upgrade mode that is separate to the other (overwrite, |
| 152 | swapping and non-swapping) modes. This is the ``RAM loading`` mode (please refer |
| 153 | to the table below). Like the non-swapping mode, this selects the newest image |
| 154 | by reading the image version numbers in the image headers, but instead of |
| 155 | executing it in place, the newest image is copied to RAM for execution. The load |
| 156 | address, the location in RAM where the image is copied to, is stored in the |
| 157 | image header. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 158 | |
| 159 | Summary of different modes for image upgrade |
| 160 | ============================================ |
| 161 | Different implementations of the image upgrade operation (whether through |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 162 | overwriting, swapping, non-swapping or loading into RAM and executing from |
| 163 | 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] | 164 | modes are supported by which platforms: |
| 165 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 166 | +----------+-----------------+----------------------------------------------------------+ |
| 167 | | | Without BL2 [1]_| With BL2 [2]_ | |
| 168 | +==========+=================+===============+==========+=============+=================+ |
| 169 | | | XIP | XIP | XIP | XIP | Not XIP | |
| 170 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 171 | | | | Overwrite [3]_| Swap [4]_| No-swap [5]_| RAM loading [6]_| |
| 172 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 173 | | AN521 | Yes | Yes | Yes | Yes | No | |
| 174 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 175 | | AN519 | Yes | Yes | Yes | Yes | No | |
| 176 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 177 | | Musca-A | No | No | No | No | Yes | |
| 178 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
| 179 | | Musca-B1 | Yes | No | No | Yes | No | |
| 180 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 181 | | AN524 | Yes | No | No | Yes | No | |
| 182 | +----------+-----------------+---------------+----------+-------------+-----------------+ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 183 | |
| 184 | .. [1] To disable BL2, please turn off the ``BL2`` compiler switch in the |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 185 | top-level configuration file or in the command line |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 186 | |
| 187 | .. [2] BL2 is enabled by default |
| 188 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 189 | .. [3] The image executes in-place (XIP) and is in Overwrite mode for image |
| 190 | update by default |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 191 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 192 | .. [4] To enable XIP Swap mode, assign the "SWAP" string to the |
| 193 | ``MCUBOOT_UPGRADE_STRATEGY`` configuration variable in the top-level |
| 194 | configuration file, or include this macro definition in the command line |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 195 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 196 | .. [5] To enable XIP No-swap, assign the "NO_SWAP" string to the |
| 197 | ``MCUBOOT_UPGRADE_STRATEGY`` configuration variable in the top-level |
| 198 | configuration file, or include this macro definition in the command line |
| 199 | |
| 200 | .. [6] To enable RAM loading, assign the "RAM_LOADING" string to the |
| 201 | ``MCUBOOT_UPGRADE_STRATEGY`` configuration variable in the top-level |
| 202 | configuration file, or include this macro definition in the command line |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 203 | |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 204 | ******************** |
| 205 | Signature algorithms |
| 206 | ******************** |
| 207 | MbedTLS library is used to sign the images. The list of supported signing |
| 208 | algorithms: |
Tamas Ban | e7efdc6 | 2019-06-05 13:14:52 +0100 | [diff] [blame] | 209 | |
| 210 | - `RSA-2048` |
| 211 | - `RSA-3072`: default |
| 212 | |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 213 | Example keys stored in ``root-rsa-2048.pem`` and ``root-rsa-3072.pem``. |
| 214 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 215 | ************************ |
| 216 | Build time configuration |
| 217 | ************************ |
| 218 | MCUBoot related compile time switches can be set in the high level build |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 219 | configuration file:: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 220 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 221 | CommonConfig.cmake |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 222 | |
| 223 | Compile time switches: |
| 224 | |
| 225 | - BL2 (default: True): |
| 226 | - **True:** TF-M built together with bootloader. MCUBoot is executed after |
| 227 | reset and it authenticates TF-M and starts secure code. |
| 228 | - **False:** TF-M built without bootloader. Secure image linked to the |
| 229 | beginning of the device memory and executed after reset. If it is false |
| 230 | then using any of the further compile time switches are invalid. |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 231 | - MCUBOOT_UPGRADE_STRATEGY (default: "OVERWRITE_ONLY"): |
| 232 | - **"OVERWRITE_ONLY":** Default firmware upgrade operation with overwrite. |
| 233 | - **"SWAP":** Activate swapping firmware upgrade operation. |
| 234 | - **"NO_SWAP":** Activate non-swapping firmware upgrade operation. |
| 235 | - **"RAM_LOADING":** Activate RAM loading firmware upgrade operation, where |
| 236 | latest image is copied to RAM and runs from there instead of being |
| 237 | executed in-place. |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 238 | - MCUBOOT_SIGNATURE_TYPE (default: RSA-3072): |
| 239 | - **RSA-3072** Image is signed with RSA-3072 algorithm |
| 240 | - **RSA-2048** Image is signed with RSA-2048 algorithm |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 241 | |
| 242 | Image versioning |
| 243 | ================ |
| 244 | 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] | 245 | and this number is used by the bootloader when the non-swapping or RAM loading |
| 246 | mode is enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 247 | |
| 248 | The version number of the image can manually be passed in through the command |
| 249 | line in the cmake configuration step:: |
| 250 | |
| 251 | cmake -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG -DIMAGE_VERSION=1.2.3+4 ../ |
| 252 | |
| 253 | Alternatively, the version number can be less specific (e.g 1, 1.2, or 1.2.3), |
| 254 | where the missing numbers are automatically set to zero. The image version |
| 255 | number argument is optional, and if it is left out, then the version numbers of |
| 256 | the image(s) being built in the same directory will automatically change. In |
| 257 | this case, the last component (the build number) automatically increments from |
| 258 | the previous one: 0.0.0+1 -> 0.0.0+2, for as many times as the build is re-ran, |
| 259 | **until a number is explicitly provided**. If automatic versioning is in place |
| 260 | and then an image version number is provided for the first time, the new number |
| 261 | will take precedence and be used instead. All subsequent image versions are |
| 262 | then set to the last number that has been specified, and the build number would |
| 263 | stop incrementing. Any new version numbers that are provided will overwrite |
| 264 | the previous one: 0.0.0+1 -> 0.0.0+2. Note: To re-apply automatic image |
| 265 | versioning, please start a clean build without specifying the image version |
| 266 | number at all. |
| 267 | |
David Vincze | 060968d | 2019-05-23 01:13:14 +0200 | [diff] [blame] | 268 | Security counter |
| 269 | ================ |
| 270 | Each signed image contains a security counter in its manifest. It is used by the |
| 271 | bootloader and its aim is to have an independent (from the image version) |
| 272 | counter to ensure rollback protection by comparing the new image's security |
| 273 | counter against the original (currently active) image's security counter during |
| 274 | the image upgrade process. It is added to the manifest (to the TLV area that is |
| 275 | appended to the end of the image) by one of the python scripts when signing the |
| 276 | image. The value of the security counter is security critical data and it is in |
| 277 | the integrity protected part of the image. The last valid security counter is |
| 278 | always stored in a non-volatile and trusted component of the device and its |
| 279 | value should always be increased if a security flaw was fixed in the current |
| 280 | image version. The value of the security counter can be specified at build time |
| 281 | in the cmake configuration step:: |
| 282 | |
| 283 | cmake -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG -DSECURITY_COUNTER=42 ../ |
| 284 | |
| 285 | The security counter can be independent from the image version, but not |
| 286 | necessarily. Alternatively, if it is not specified at build time with the |
| 287 | ``SECURITY_COUNTER`` option the python script will automatically generate it |
| 288 | from the image version number (not including the build number) and this value |
| 289 | will be added to the signed image. |
| 290 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 291 | ************************ |
| 292 | Testing firmware upgrade |
| 293 | ************************ |
| 294 | As downloading the new firmware image is out of scope for MCUBoot, the update |
| 295 | process is started from a state where the original and the new image are already |
| 296 | programmed to the appropriate memory slots. To generate the original and a new |
| 297 | firmware package, TF-M is built twice with different build configurations. |
| 298 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 299 | Overwriting firmware upgrade |
Tamas Ban | e7efdc6 | 2019-06-05 13:14:52 +0100 | [diff] [blame] | 300 | ============================ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 301 | Run TF-M build twice with two different build configuration: default and |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 302 | regression. Save the artifacts between builds, because second run can overwrite |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 303 | original binaries. Download default build to the primary slot and regression |
| 304 | build to the secondary slot. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 305 | |
| 306 | Executing firmware upgrade on FVP_MPS2_AEMv8M |
| 307 | --------------------------------------------- |
| 308 | .. code-block:: bash |
| 309 | |
| 310 | <DS5_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \ |
| 311 | --parameter fvp_mps2.platform_type=2 \ |
| 312 | --parameter cpu0.baseline=0 \ |
| 313 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 314 | --parameter cpu0.semihosting-enable=0 \ |
| 315 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 316 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 317 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 318 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 319 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 320 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 321 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 322 | --application cpu0=<build_dir>/bl2/ext/mcuboot/mcuboot.axf \ |
| 323 | --data cpu0=<default_build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10080000 \ |
| 324 | --data cpu0=<regresssion_build_dir>/install/outputs/fvp/tfm_s_ns_signed.bin@0x10180000 |
| 325 | |
| 326 | Executing firmware upgrade on SSE 200 FPGA on MPS2 board |
| 327 | -------------------------------------------------------- |
| 328 | |
| 329 | :: |
| 330 | |
| 331 | TITLE: Versatile Express Images Configuration File |
| 332 | [IMAGES] |
| 333 | TOTALIMAGES: 3 ;Number of Images (Max: 32) |
| 334 | IMAGE0ADDRESS: 0x00000000 |
| 335 | IMAGE0FILE: \Software\mcuboot.axf ; BL2 bootloader |
| 336 | IMAGE1ADDRESS: 0x10080000 |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 337 | IMAGE1FILE: \Software\tfm_sig1.bin ; TF-M default test binary blob |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 338 | IMAGE2ADDRESS: 0x10180000 |
| 339 | IMAGE2FILE: \Software\tfm_sig2.bin ; TF-M regression test binary blob |
| 340 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 341 | The following message will be shown in case of successful firmware upgrade: |
| 342 | |
| 343 | :: |
| 344 | |
| 345 | [INF] Starting bootloader |
| 346 | [INF] Swap type: test |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 347 | [INF] Image upgrade secondary slot -> primary slot |
| 348 | [INF] Erasing the primary slot |
| 349 | [INF] Copying the secondary slot to the primary slot: 0x100000 bytes |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 350 | [INF] Bootloader chainload address offset: 0x80000 |
| 351 | [INF] Jumping to the first image slot |
| 352 | [Sec Thread] Secure image initializing! |
| 353 | |
| 354 | #### Execute test suites for the Secure area #### |
| 355 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 356 | ... |
| 357 | |
| 358 | Swapping firmware upgrade |
| 359 | ============================= |
| 360 | Follow the same instructions and platform related configurations as in case of |
| 361 | overwriting build including these changes: |
| 362 | |
| 363 | - Set MCUBOOT\_SWAP compile time switch to true before build. |
| 364 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 365 | The following message will be shown in case of successful firmware upgrade, |
| 366 | ``Swap type: test`` indicates that images were swapped: |
| 367 | |
| 368 | :: |
| 369 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 370 | [INF] Starting bootloader |
| 371 | [INF] Image 0: magic= good, copy_done=0x3, image_ok=0x3 |
| 372 | [INF] Scratch: magic= bad, copy_done=0x0, image_ok=0x2 |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame^] | 373 | [INF] Boot source: primary slot |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 374 | [INF] Swap type: test |
| 375 | [INF] Bootloader chainload address offset: 0x80000 |
| 376 | [INF] Jumping to the first image slot |
| 377 | [Sec Thread] Secure image initializing! |
| 378 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 379 | #### Execute test suites for the Secure area #### |
| 380 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 381 | ... |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 382 | |
| 383 | Non-swapping firmware upgrade |
| 384 | ============================= |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 385 | Follow the same instructions as in case of overwriting build including these |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 386 | changes: |
| 387 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 388 | - Set the ``MCUBOOT_UPGRADE_STRATEGY`` compile time switch to "NO_SWAP" |
| 389 | before build. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 390 | - Increase the image version number between the two build run. |
| 391 | |
| 392 | Executing firmware upgrade on FVP_MPS2_AEMv8M |
| 393 | --------------------------------------------- |
| 394 | |
| 395 | .. code-block:: bash |
| 396 | |
| 397 | <DS5_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \ |
| 398 | --parameter fvp_mps2.platform_type=2 \ |
| 399 | --parameter cpu0.baseline=0 \ |
| 400 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 401 | --parameter cpu0.semihosting-enable=0 \ |
| 402 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 403 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 404 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 405 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 406 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 407 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 408 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 409 | --application cpu0=<build_dir>/bl2/ext/mcuboot/mcuboot.axf \ |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 410 | --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] | 411 | --data cpu0=<regresssion_build_dir>/install/outputs/fvp/tfm_s_ns_signed_1.bin@0x10180000 |
| 412 | |
| 413 | Executing firmware upgrade on SSE 200 FPGA on MPS2 board |
| 414 | -------------------------------------------------------- |
| 415 | |
| 416 | :: |
| 417 | |
| 418 | TITLE: Versatile Express Images Configuration File |
| 419 | [IMAGES] |
| 420 | TOTALIMAGES: 3 ;Number of Images (Max: 32) |
| 421 | IMAGE0ADDRESS: 0x00000000 |
| 422 | IMAGE0FILE: \Software\mcuboot.axf ; BL2 bootloader |
| 423 | IMAGE1ADDRESS: 0x10080000 |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 424 | IMAGE1FILE: \Software\tfm_sign.bin ; TF-M default test binary blob |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 425 | IMAGE2ADDRESS: 0x10180000 |
| 426 | IMAGE2FILE: \Software\tfm_sig1.bin ; TF-M regression test binary blob |
| 427 | |
| 428 | Executing firmware upgrade on Musca-B1 board |
| 429 | -------------------------------------------- |
| 430 | After two images have been built, they can be concatenated to create the |
| 431 | combined image using ``srec_cat``: |
| 432 | |
| 433 | - Linux:: |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 434 | |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 435 | 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] | 436 | |
| 437 | - Windows:: |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 438 | |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 439 | 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] | 440 | |
| 441 | The following message will be shown in case of successful firmware upgrade, |
| 442 | notice that image with higher version number (``version=1.2.3.5``) is executed: |
| 443 | |
| 444 | :: |
| 445 | |
| 446 | [INF] Starting bootloader |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 447 | [INF] Image 0: version=1.2.3.4, magic= good, image_ok=0x3 |
| 448 | [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^] | 449 | [INF] Booting image from the secondary slot |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 450 | [INF] Bootloader chainload address offset: 0xa0000 |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 451 | [INF] Jumping to the first image slot |
| 452 | [Sec Thread] Secure image initializing! |
| 453 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 454 | #### Execute test suites for the Secure area #### |
| 455 | Running Test Suite PSA protected storage S interface tests (TFM_SST_TEST_2XXX)... |
| 456 | ... |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 457 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 458 | Executing firmware upgrade on CoreLink SSE-200 Subsystem for MPS3 (AN524) |
| 459 | ------------------------------------------------------------------------- |
| 460 | |
| 461 | :: |
| 462 | |
| 463 | TITLE: Arm MPS3 FPGA prototyping board Images Configuration File |
| 464 | |
| 465 | [IMAGES] |
| 466 | TOTALIMAGES: 3 ;Number of Images (Max: 32) |
| 467 | |
| 468 | IMAGE0UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE |
| 469 | IMAGE0ADDRESS: 0x00000000 |
| 470 | IMAGE0FILE: \SOFTWARE\mcuboot.bin ;BL2 bootloader |
| 471 | IMAGE1UPDATE: AUTO |
| 472 | IMAGE1ADDRESS: 0x00040000 |
| 473 | IMAGE1FILE: \SOFTWARE\tfm_sig0.bin ;TF-M example application binary blob |
| 474 | IMAGE2UPDATE: AUTO |
| 475 | IMAGE2ADDRESS: 0x000C0000 |
| 476 | IMAGE2FILE: \SOFTWARE\tfm_sig1.bin ;TF-M regression test binary blob |
| 477 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 478 | RAM loading firmware upgrade |
| 479 | ============================ |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 480 | To enable RAM loading, please set ``MCUBOOT_UPGRADE_STRATEGY`` to "RAM_LOADING" |
| 481 | (either in the configuration file or through the command line), and then specify |
| 482 | a destination load address in RAM where the image can be copied to and executed |
| 483 | from. The ``IMAGE_LOAD_ADDRESS`` macro must be specified in the target dependent |
| 484 | 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] | 485 | folder should include ``#define IMAGE_LOAD_ADDRESS #0x10020000`` |
| 486 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 487 | Executing firmware upgrade on Musca-A board |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 488 | -------------------------------------------- |
| 489 | After two images have been built, they can be concatenated to create the |
| 490 | combined image using ``srec_cat``: |
| 491 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 492 | - Linux:: |
| 493 | |
| 494 | 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] | 495 | |
| 496 | - Windows:: |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 497 | |
| 498 | 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] | 499 | |
| 500 | The following message will be shown in case of successful firmware upgrade when, |
| 501 | RAM loading is enabled, notice that image with higher version number |
| 502 | (``version=0.0.0.2``) is executed: |
| 503 | |
| 504 | :: |
| 505 | |
David Vincze | 8a2a4e2 | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 506 | [INF] Starting bootloader |
| 507 | [INF] Image 0: version=0.0.0.1, magic= good, image_ok=0x3 |
| 508 | [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^] | 509 | [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] | 510 | [INF] Booting image from SRAM at address 0x10020000 |
| 511 | [INF] Bootloader chainload address offset: 0x20000 |
| 512 | [INF] Jumping to the first image slot |
| 513 | [Sec Thread] Secure image initializing! |
| 514 | |
| 515 | -------------- |
| 516 | |
| 517 | *Copyright (c) 2018-2019, Arm Limited. All rights reserved.* |