blob: c8eca674987e0fc79f832e3ed94254db4b350101 [file] [log] [blame]
Jimmy Brisson0862f012020-04-02 15:19:12 -05001Building 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 Brisson4844dc92020-04-02 15:19:34 -050036 `TF-A documentation`_ for more information on available build
Jimmy Brisson0862f012020-04-02 15:19:12 -050037 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
82TFTF test image
83```````````````
84
85``tftf.bin`` is the main test image to exercise the TF-A features. The other
86test images provided in this repository are optional dependencies that TFTF
87needs to test some specific features.
88
89``tftf.bin`` may be built independently of the other test images using the
90following command:
91
92::
93
94 make PLAT=<platform> tftf
95
96In TF-A boot flow, ``tftf.bin`` replaces the ``BL33`` image and should be
97injected in the FIP image. This might be achieved by running the following
98command from the TF-A root directory:
99
100::
101
Leonardo Sandovalabf254f2020-06-29 17:46:28 -0500102 BL33=<path/to/tftf.bin> make PLAT=<platform> fip
Jimmy Brisson0862f012020-04-02 15:19:12 -0500103
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500104Please refer to the `TF-A documentation`_ for further details.
Jimmy Brisson0862f012020-04-02 15:19:12 -0500105
Soby Mathew2a5b1502022-11-02 04:29:07 +0000106Realm payload test image
107````````````````````````
108
109``realm.bin`` is the realm payload test image and is packaged along with
110tftf for Realm Management Extension (RME) testing. This can be built using
111the following command:
112
113::
114
115 make PLAT=<platform> realm
116
117The generated ``realm.bin`` needs to be packaged as part of ``tftf.bin`` to
118be used as a single BL33 image and can be done using the following command:
119
120::
121
122 make PLAT=<platform> pack_realm
123
124Please refer to the `TF-A RME documentation`_ for build and run instructions.
125
Jimmy Brisson0862f012020-04-02 15:19:12 -0500126NS_BL1U and NS_BL2U test images
127```````````````````````````````
128
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500129``ns_bl1u.bin`` and ``ns_bl2u.bin`` are test images that exercise the *Firmware
130Update (FWU)* feature of TF-A [#]_. Throughout this document, they will be
131referred as the *FWU test images*.
Jimmy Brisson0862f012020-04-02 15:19:12 -0500132
133In addition to updating the firmware, the FWU test images also embed some tests
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500134that exercise the FWU state machine implemented in the TF-A. They send valid
Jimmy Brisson0862f012020-04-02 15:19:12 -0500135and invalid SMC requests to the TF-A BL1 image in order to test its robustness.
136
137NS_BL1U test image
138''''''''''''''''''
139
140The ``NS_BL1U`` image acts as the `Application Processor (AP) Firmware Update
141Boot ROM`. This typically is the first software agent executing on the AP in the
142Normal World during a firmware update operation. Its primary purpose is to load
143subsequent firmware update images from an external interface, such as NOR Flash,
144and communicate with ``BL1`` to authenticate those images.
145
146The ``NS_BL1U`` test image provided in this repository performs the following
147tasks:
148
149- Load FWU images from external non-volatile storage (typically flash memory)
150 to Non-Secure RAM.
151
152- Request TF-A BL1 to copy these images in Secure RAM and authenticate them.
153
154- Jump to ``NS_BL2U`` which carries out the next steps in the firmware update
155 process.
156
157This image may be built independently of the other test images using the
158following command:
159
160::
161
162 make PLAT=<platform> ns_bl1u
163
164NS_BL2U test image
165''''''''''''''''''
166
167The ``NS_BL2U`` image acts as the `AP Firmware Updater`. Its primary
168responsibility is to load a new set of firmware images from an external
169interface and write them into non-volatile storage.
170
171The ``NS_BL2U`` test image provided in this repository overrides the original
172FIP image stored in flash with the backup FIP image (see below).
173
174This image may be built independently of the other test images using the
175following command:
176
177::
178
179 make PLAT=<platform> ns_bl2u
180
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500181.. _build_putting_together:
182
Jimmy Brisson0862f012020-04-02 15:19:12 -0500183Putting it all together
184'''''''''''''''''''''''
185
186The FWU test images should be used in conjunction with the TFTF image, as the
187latter initiates the FWU process by corrupting the FIP image and resetting the
188target. Once the FWU process is complete, TFTF takes over again and checks that
189the firmware was successfully updated.
190
191To sum up, 3 images must be built out of the TF-A Tests repository in order to
192test the TF-A Firmware Update feature:
193
194- ``ns_bl1u.bin``
195- ``ns_bl2u.bin``
196- ``tftf.bin``
197
198Once that's done, they must be combined in the right way.
199
200- ``ns_bl1u.bin`` is a standalone image and does not require any further
201 processing.
202
203- ``ns_bl2u.bin`` must be injected into the ``FWU_FIP`` image. This might be
204 achieved by setting ``NS_BL2U=ns_bl2u.bin`` when building the ``FWU_FIP``
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500205 image out of the TF-A repository. Please refer to the section Building FIP
206 images with support for Trusted Board Boot in the `TF-A documentation`_.
Jimmy Brisson0862f012020-04-02 15:19:12 -0500207
208- ``tftf.bin`` must be injected in the standard FIP image, as explained
209 in section `TFTF test image`_.
210
211Additionally, on Juno platform, the FWU FIP must contain a ``SCP_BL2U`` image.
212This image can simply be a copy of the standard ``SCP_BL2`` image if no specific
213firmware update operations need to be carried on the SCP side.
214
215Finally, the backup FIP image must be created. This can simply be a copy of the
216standard FIP image, which means that the Firmware Update process will restore
217the original, uncorrupted FIP image.
218
219EL3 test payload
220````````````````
221
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500222``el3_payload.bin`` is a test image exercising the alternative EL3 payload boot
223flow in TF-A. Refer to the `EL3 test payload README file`_ for more details
Jimmy Brisson0862f012020-04-02 15:19:12 -0500224about its behaviour and how to build and run it.
225
226SPM test images
227```````````````
228
Olivier Depreza7573662021-05-07 18:58:03 +0200229This repository contains three sample Secure Partitions (SP) meant to be used
230with one implementation of a Secure Partition Manager (SPM):
Jimmy Brisson0862f012020-04-02 15:19:12 -0500231
Olivier Depreza7573662021-05-07 18:58:03 +0200232- Cactus-MM
233- Cactus and Ivy
Jimmy Brisson0862f012020-04-02 15:19:12 -0500234
235They are only supported on AArch64 FVP. They can be built independently of the
236other test images using the following command:
237
238::
239
240 make PLAT=fvp cactus ivy cactus_mm
241
Jimmy Brisson0862f012020-04-02 15:19:12 -0500242To run the full set of tests in the Secure Partitions, they should be used in
243conjunction with the TFTF image.
244
Olivier Depreza7573662021-05-07 18:58:03 +0200245Please refer to the `TF-A documentation`_ for further details.
246
247Cactus-MM
248'''''''''
249
250Cactus-MM is designed to test the TF-A EL3 SPM implementation
251(`TF-A Secure Partition Manager (MM)`_) based on the
252`Arm Management Mode Interface`_ (MM)
253
254This SP runs in Secure-EL0 and performs the following tasks:
255
256- Test that TF-A has correctly setup the secure partition environment: it
257 should be allowed to perform cache maintenance operations, access floating
258 point registers, etc.
259
260- Test that TF-A accepts to change data access permissions and instruction
261 permissions on behalf of the Secure Partition for memory regions the latter
262 owns.
263
264- Test communication with SPM through MM interface.
265
266In the TF-A boot flow, the partition replaces the ``BL32`` image and should be
267injected in the FIP image. To test SPM-MM with Cactus-MM, it is enough to use
268``cactus_mm.bin`` as BL32 image.
269
270For SPM-MM, build TF-A following `Building TF-A Secure Partition Manager (MM)`_ and the following
Jimmy Brisson0862f012020-04-02 15:19:12 -0500271commands can be used to build the tests:
272
273::
274
275 # TF-A-Tests repository:
276
277 make PLAT=fvp TESTS=spm-mm tftf cactus_mm
278
Olivier Depreza7573662021-05-07 18:58:03 +0200279Cactus and Ivy
280''''''''''''''
281
282Cactus and Ivy are designed to test the FF-A based SPM implementation with
283secure virtualization enabled. Refer to `Arm Firmware Framework for Armv8-A`_
284
285In the TF-A reference code base, BL31 implements the SPMD and BL32 the SPMC.
286The SPMC runs at S-EL2 and acts as a partition manager for multiple secure
287partitions (`TF-A Secure Partition Manager (FF-A)`_):
288
289- Cactus is a sample FF-A compliant S-EL1 partition. As a matter of providing
290 a realistic test harness, three instances of the same partition binary are
291 launched as separate SPs (hence assigned three different FF-A IDs
292 corresponding each to a different secure partition). Each secure partition
293 instance has a separate manifest (`Cactus sample manifest`_,
294 `Cactus secondary manifest`_, `Cactus tertiary manifest`_ ). First two
295 instances are MP SPs. Third instance is a UP SP. Each instance runs a set
296 of built-in tests at boot time. They exercise SP to SPMC FF-A interfaces
297 contained in the secure world. The partition interacts with the SPMC through
298 SMC. Once the NWd and TFTF are started, another set of run-time tests
299 exercise the normal world to secure world primitives.
300- Ivy is a specific kind of S-EL1 UP partition, where the S-EL1 exception level
301 consists of a thin shim layer. The applicative part of the partition is held
302 at S-EL0. The shim provides early bootstrap code, MMU configuration and a
303 vector table trapping S-EL0 requests. The application interacts with the shim
304 through FF-A protocol by the use of SVC instruction. The shim relays the
305 request to the SPMC by an SMC. The S-EL0 application doesn't require knowledge
306 of the shim, and can be self contained.
307
308This picture illustrates the test setup:
309
310.. image:: ../resources/tftf-cactus.png
311
312To build TFTF with SPM tests, Cactus and Ivy use:
Jimmy Brisson0862f012020-04-02 15:19:12 -0500313
314::
315
316 # TF-A-Tests repository:
317
318 make PLAT=fvp TESTS=spm tftf cactus ivy
319
Jimmy Brisson0862f012020-04-02 15:19:12 -0500320--------------
321
322.. [#] Therefore, the Trusted Board Boot feature must be enabled in TF-A for
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500323 the FWU test images to work. Please refer the `TF-A documentation`_ for
Jimmy Brisson0862f012020-04-02 15:19:12 -0500324 further details.
325
Jimmy Brisson0862f012020-04-02 15:19:12 -0500326--------------
327
Olivier Depreza7573662021-05-07 18:58:03 +0200328*Copyright (c) 2019-2021, Arm Limited. All rights reserved.*
Jimmy Brisson0862f012020-04-02 15:19:12 -0500329
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500330.. _EL3 test payload README file: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/el3_payload/README
Olivier Depreza7573662021-05-07 18:58:03 +0200331.. _Arm Management Mode Interface: https://developer.arm.com/documentation/den0060/a/
332.. _Arm Firmware Framework for Armv8-A: https://developer.arm.com/docs/den0077/latest
Jimmy Brisson4844dc92020-04-02 15:19:34 -0500333.. _TF-A documentation: https://trustedfirmware-a.readthedocs.org
Soby Mathew2a5b1502022-11-02 04:29:07 +0000334.. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html
Olivier Depreza7573662021-05-07 18:58:03 +0200335.. _TF-A Secure Partition Manager (FF-A): https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager.html
336.. _TF-A Secure Partition Manager (MM): https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html
337.. _Building TF-A Secure Partition Manager (MM): https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html#building-tf-a-with-secure-partition-support
338.. _Cactus sample manifest: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus.dts?h=v2.5-rc1
339.. _Cactus secondary manifest: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts?h=v2.5-rc1
340.. _Cactus tertiary manifest: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts?h=v2.5-rc1