Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 1 | Building TF-A Tests |
| 2 | =================== |
| 3 | |
| 4 | - Before building TF-A Tests, the environment variable ``CROSS_COMPILE`` must |
| 5 | point to the cross compiler. |
| 6 | |
| 7 | For AArch64: |
| 8 | |
| 9 | :: |
| 10 | |
| 11 | export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- |
| 12 | |
| 13 | For AArch32: |
| 14 | |
| 15 | :: |
| 16 | |
| 17 | export CROSS_COMPILE=<path-to-aarch32-gcc>/bin/arm-eabi- |
| 18 | |
| 19 | - Change to the root directory of the TF-A Tests source tree and build. |
| 20 | |
| 21 | For AArch64: |
| 22 | |
| 23 | :: |
| 24 | |
| 25 | make PLAT=<platform> |
| 26 | |
| 27 | For AArch32: |
| 28 | |
| 29 | :: |
| 30 | |
| 31 | make PLAT=<platform> ARCH=aarch32 |
| 32 | |
| 33 | Notes: |
| 34 | |
| 35 | - If ``PLAT`` is not specified, ``fvp`` is assumed by default. See the |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 36 | `TF-A documentation`_ for more information on available build |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 37 | options. |
| 38 | |
| 39 | - By default this produces a release version of the build. To produce a |
| 40 | debug version instead, build the code with ``DEBUG=1``. |
| 41 | |
| 42 | - The build process creates products in a ``build/`` directory tree, |
| 43 | building the objects and binaries for each test image in separate |
| 44 | sub-directories. The following binary files are created from the |
| 45 | corresponding ELF files: |
| 46 | |
| 47 | - ``build/<platform>/<build-type>/tftf.bin`` |
| 48 | - ``build/<platform>/<build-type>/ns_bl1u.bin`` |
| 49 | - ``build/<platform>/<build-type>/ns_bl2u.bin`` |
| 50 | - ``build/<platform>/<build-type>/el3_payload.bin`` |
| 51 | - ``build/<platform>/<build-type>/cactus_mm.bin`` |
| 52 | - ``build/<platform>/<build-type>/cactus.bin`` |
| 53 | - ``build/<platform>/<build-type>/ivy.bin`` |
| 54 | - ``build/<platform>/<build-type>/quark.bin`` |
| 55 | |
| 56 | where ``<platform>`` is the name of the chosen platform and ``<build-type>`` |
| 57 | is either ``debug`` or ``release``. The actual number of images might differ |
| 58 | depending on the platform. |
| 59 | |
| 60 | Refer to the sections below for more information about each image. |
| 61 | |
| 62 | - Build products for a specific build variant can be removed using: |
| 63 | |
| 64 | :: |
| 65 | |
| 66 | make DEBUG=<D> PLAT=<platform> clean |
| 67 | |
| 68 | ... where ``<D>`` is ``0`` or ``1``, as specified when building. |
| 69 | |
| 70 | The build tree can be removed completely using: |
| 71 | |
| 72 | :: |
| 73 | |
| 74 | make realclean |
| 75 | |
| 76 | - Use the following command to list all supported build commands: |
| 77 | |
| 78 | :: |
| 79 | |
| 80 | make help |
| 81 | |
| 82 | TFTF test image |
| 83 | ``````````````` |
| 84 | |
| 85 | ``tftf.bin`` is the main test image to exercise the TF-A features. The other |
| 86 | test images provided in this repository are optional dependencies that TFTF |
| 87 | needs to test some specific features. |
| 88 | |
| 89 | ``tftf.bin`` may be built independently of the other test images using the |
| 90 | following command: |
| 91 | |
| 92 | :: |
| 93 | |
| 94 | make PLAT=<platform> tftf |
| 95 | |
| 96 | In TF-A boot flow, ``tftf.bin`` replaces the ``BL33`` image and should be |
| 97 | injected in the FIP image. This might be achieved by running the following |
| 98 | command from the TF-A root directory: |
| 99 | |
| 100 | :: |
| 101 | |
| 102 | BL33=tftf.bin make PLAT=<platform> fip |
| 103 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 104 | Please refer to the `TF-A documentation`_ for further details. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 105 | |
| 106 | NS_BL1U and NS_BL2U test images |
| 107 | ``````````````````````````````` |
| 108 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 109 | ``ns_bl1u.bin`` and ``ns_bl2u.bin`` are test images that exercise the *Firmware |
| 110 | Update (FWU)* feature of TF-A [#]_. Throughout this document, they will be |
| 111 | referred as the *FWU test images*. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 112 | |
| 113 | In addition to updating the firmware, the FWU test images also embed some tests |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 114 | that exercise the FWU state machine implemented in the TF-A. They send valid |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 115 | and invalid SMC requests to the TF-A BL1 image in order to test its robustness. |
| 116 | |
| 117 | NS_BL1U test image |
| 118 | '''''''''''''''''' |
| 119 | |
| 120 | The ``NS_BL1U`` image acts as the `Application Processor (AP) Firmware Update |
| 121 | Boot ROM`. This typically is the first software agent executing on the AP in the |
| 122 | Normal World during a firmware update operation. Its primary purpose is to load |
| 123 | subsequent firmware update images from an external interface, such as NOR Flash, |
| 124 | and communicate with ``BL1`` to authenticate those images. |
| 125 | |
| 126 | The ``NS_BL1U`` test image provided in this repository performs the following |
| 127 | tasks: |
| 128 | |
| 129 | - Load FWU images from external non-volatile storage (typically flash memory) |
| 130 | to Non-Secure RAM. |
| 131 | |
| 132 | - Request TF-A BL1 to copy these images in Secure RAM and authenticate them. |
| 133 | |
| 134 | - Jump to ``NS_BL2U`` which carries out the next steps in the firmware update |
| 135 | process. |
| 136 | |
| 137 | This image may be built independently of the other test images using the |
| 138 | following command: |
| 139 | |
| 140 | :: |
| 141 | |
| 142 | make PLAT=<platform> ns_bl1u |
| 143 | |
| 144 | NS_BL2U test image |
| 145 | '''''''''''''''''' |
| 146 | |
| 147 | The ``NS_BL2U`` image acts as the `AP Firmware Updater`. Its primary |
| 148 | responsibility is to load a new set of firmware images from an external |
| 149 | interface and write them into non-volatile storage. |
| 150 | |
| 151 | The ``NS_BL2U`` test image provided in this repository overrides the original |
| 152 | FIP image stored in flash with the backup FIP image (see below). |
| 153 | |
| 154 | This image may be built independently of the other test images using the |
| 155 | following command: |
| 156 | |
| 157 | :: |
| 158 | |
| 159 | make PLAT=<platform> ns_bl2u |
| 160 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 161 | .. _build_putting_together: |
| 162 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 163 | Putting it all together |
| 164 | ''''''''''''''''''''''' |
| 165 | |
| 166 | The FWU test images should be used in conjunction with the TFTF image, as the |
| 167 | latter initiates the FWU process by corrupting the FIP image and resetting the |
| 168 | target. Once the FWU process is complete, TFTF takes over again and checks that |
| 169 | the firmware was successfully updated. |
| 170 | |
| 171 | To sum up, 3 images must be built out of the TF-A Tests repository in order to |
| 172 | test the TF-A Firmware Update feature: |
| 173 | |
| 174 | - ``ns_bl1u.bin`` |
| 175 | - ``ns_bl2u.bin`` |
| 176 | - ``tftf.bin`` |
| 177 | |
| 178 | Once that's done, they must be combined in the right way. |
| 179 | |
| 180 | - ``ns_bl1u.bin`` is a standalone image and does not require any further |
| 181 | processing. |
| 182 | |
| 183 | - ``ns_bl2u.bin`` must be injected into the ``FWU_FIP`` image. This might be |
| 184 | achieved by setting ``NS_BL2U=ns_bl2u.bin`` when building the ``FWU_FIP`` |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 185 | image out of the TF-A repository. Please refer to the section Building FIP |
| 186 | images with support for Trusted Board Boot in the `TF-A documentation`_. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 187 | |
| 188 | - ``tftf.bin`` must be injected in the standard FIP image, as explained |
| 189 | in section `TFTF test image`_. |
| 190 | |
| 191 | Additionally, on Juno platform, the FWU FIP must contain a ``SCP_BL2U`` image. |
| 192 | This image can simply be a copy of the standard ``SCP_BL2`` image if no specific |
| 193 | firmware update operations need to be carried on the SCP side. |
| 194 | |
| 195 | Finally, the backup FIP image must be created. This can simply be a copy of the |
| 196 | standard FIP image, which means that the Firmware Update process will restore |
| 197 | the original, uncorrupted FIP image. |
| 198 | |
| 199 | EL3 test payload |
| 200 | ```````````````` |
| 201 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 202 | ``el3_payload.bin`` is a test image exercising the alternative EL3 payload boot |
| 203 | flow in TF-A. Refer to the `EL3 test payload README file`_ for more details |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 204 | about its behaviour and how to build and run it. |
| 205 | |
| 206 | SPM test images |
| 207 | ``````````````` |
| 208 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 209 | This repository contains 3 Secure Partitions that exercise the Secure Partition |
| 210 | Manager (SPM) in TF-A [#]_. Cactus-MM is designed to test the SPM |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 211 | implementation based on the `ARM Management Mode Interface`_ (MM), while Cactus |
| 212 | and Ivy can test the SPM implementation based on the SPCI and SPRT draft |
| 213 | specifications. Note that it isn't possible to use both communication mechanisms |
| 214 | at once: If Cactus-MM is used Cactus and Ivy can't be used. |
| 215 | |
| 216 | They run in Secure-EL0 and perform the following tasks: |
| 217 | |
| 218 | - Test that TF-A has correctly setup the secure partition environment: They |
| 219 | should be allowed to perform cache maintenance operations, access floating |
| 220 | point registers, etc. |
| 221 | |
| 222 | - Test that TF-A accepts to change data access permissions and instruction |
| 223 | permissions on behalf of the Secure Partitions for memory regions the latter |
| 224 | owns. |
| 225 | |
| 226 | - Test communication with SPM through either MM, or both SPCI and SPRT. |
| 227 | |
| 228 | They are only supported on AArch64 FVP. They can be built independently of the |
| 229 | other test images using the following command: |
| 230 | |
| 231 | :: |
| 232 | |
| 233 | make PLAT=fvp cactus ivy cactus_mm |
| 234 | |
| 235 | In the TF-A boot flow, the partitions replace the ``BL32`` image and should be |
| 236 | injected in the FIP image. To test SPM-MM with Cactus-MM, it is enough to use |
| 237 | ``cactus_mm.bin`` as BL32 image. To test the SPM based on SPCI and SPRT, it is |
| 238 | needed to use ``sp_tool`` to build a Secure Partition package that can be used |
| 239 | as BL32 image. |
| 240 | |
| 241 | To run the full set of tests in the Secure Partitions, they should be used in |
| 242 | conjunction with the TFTF image. |
| 243 | |
| 244 | For SPM-MM, build TF-A following the `TF-A SPM User Guide`_ and the following |
| 245 | commands can be used to build the tests: |
| 246 | |
| 247 | :: |
| 248 | |
| 249 | # TF-A-Tests repository: |
| 250 | |
| 251 | make PLAT=fvp TESTS=spm-mm tftf cactus_mm |
| 252 | |
| 253 | For SPM based on SPCI and SPRT, build TF-A following the `TF-A SPM User Guide`_ |
| 254 | and the following commands can be used to build the tests: |
| 255 | |
| 256 | :: |
| 257 | |
| 258 | # TF-A-Tests repository: |
| 259 | |
| 260 | make PLAT=fvp TESTS=spm tftf cactus ivy |
| 261 | |
| 262 | # TF-A repository: |
| 263 | |
| 264 | make sptool |
| 265 | |
| 266 | tools/sptool/sptool -o sp_package.bin \ |
| 267 | -i path/to/cactus.bin:path/to/cactus.dtb \ |
| 268 | -i path/to/ivy.bin:path/to/ivy.dtb |
| 269 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 270 | Please refer to the `TF-A documentation`_ for further details. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 271 | |
| 272 | -------------- |
| 273 | |
| 274 | .. [#] Therefore, the Trusted Board Boot feature must be enabled in TF-A for |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 275 | the FWU test images to work. Please refer the `TF-A documentation`_ for |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 276 | further details. |
| 277 | |
| 278 | .. [#] Therefore, the Secure Partition Manager must be enabled in TF-A for |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 279 | any of the test Secure Partitions to work. Please refer to the |
| 280 | `TF-A documentation`_ for further details. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 281 | |
| 282 | -------------- |
| 283 | |
| 284 | *Copyright (c) 2019, Arm Limited. All rights reserved.* |
| 285 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 286 | .. _EL3 test payload README file: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/el3_payload/README |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 287 | .. _ARM Management Mode Interface: http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 288 | .. _TF-A documentation: https://trustedfirmware-a.readthedocs.org |
| 289 | .. _TF-A SPM User Guide: https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-design.html#building-tf-a-with-secure-partition-support |