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