blob: b638c6872afaf8c92a3bb6b5ef919292236510b0 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001Trusted Firmware-A Tests - User Guide
2=====================================
3
4.. section-numbering::
5 :suffix: .
6
7.. contents::
8
9This document describes how to build the Trusted Firmware-A Tests (TF-A Tests)
10and run them on a set of platforms. It assumes that the reader has previous
11experience building and running the `Trusted Firmware-A (TF-A)`_.
12
13Host machine requirements
14-------------------------
15
16The minimum recommended machine specification for building the software and
17running the `FVP models`_ is a dual-core processor running at 2GHz with 12GB of
18RAM. For best performance, use a machine with a quad-core processor running at
192.6GHz with 16GB of RAM.
20
21The software has been tested on Ubuntu 16.04 LTS (64-bit). Packages used for
22building the software were installed from that distribution unless otherwise
23specified.
24
25Tools
26-----
27
28Install the required packages to build TF-A Tests with the following command:
29
30::
31
32 sudo apt-get install build-essential make git perl libxml-libxml-perl
33
34Download and install the GNU cross-toolchain from Linaro. The TF-A Tests have
35been tested with version 6.2-2016.11 (gcc 6.2):
36
37- `AArch32 GNU cross-toolchain`_
38- `AArch64 GNU cross-toolchain`_
39
40In addition, the following optional packages and tools may be needed:
41
42- For debugging, Arm `Development Studio 5 (DS-5)`_.
43
44Getting the TF-A Tests source code
45----------------------------------
46
47Download the TF-A Tests source code using the following command:
48
49::
50
51 git clone https://git.trustedfirmware.org/tf-a-tests.git
52
53Building TF-A Tests
54-------------------
55
56- Before building TF-A Tests, the environment variable ``CROSS_COMPILE`` must
57 point to the Linaro cross compiler.
58
59 For AArch64:
60
61 ::
62
63 export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-linux-gnu-
64
65 For AArch32:
66
67 ::
68
69 export CROSS_COMPILE=<path-to-aarch32-gcc>/bin/arm-linux-gnueabihf-
70
71- Change to the root directory of the TF-A Tests source tree and build.
72
73 For AArch64:
74
75 ::
76
77 make PLAT=<platform>
78
79 For AArch32:
80
81 ::
82
83 make PLAT=<platform> ARCH=aarch32
84
85 Notes:
86
87 - If ``PLAT`` is not specified, ``fvp`` is assumed by default. See the
88 `Summary of build options`_ for more information on available build
89 options.
90
91 - By default this produces a release version of the build. To produce a
92 debug version instead, build the code with ``DEBUG=1``.
93
94 - The build process creates products in a ``build/`` directory tree,
95 building the objects and binaries for each test image in separate
96 sub-directories. The following binary files are created from the
97 corresponding ELF files:
98
99 - ``build/<platform>/<build-type>/tftf.bin``
100 - ``build/<platform>/<build-type>/ns_bl1u.bin``
101 - ``build/<platform>/<build-type>/ns_bl2u.bin``
102 - ``build/<platform>/<build-type>/el3_payload.bin``
103 - ``build/<platform>/<build-type>/cactus.bin``
104
105 where ``<platform>`` is the name of the chosen platform and ``<build-type>``
106 is either ``debug`` or ``release``. The actual number of images might differ
107 depending on the platform.
108
109 Refer to the sections below for more information about each image.
110
111- Build products for a specific build variant can be removed using:
112
113 ::
114
115 make DEBUG=<D> PLAT=<platform> clean
116
117 ... where ``<D>`` is ``0`` or ``1``, as specified when building.
118
119 The build tree can be removed completely using:
120
121 ::
122
123 make realclean
124
125- Use the following command to list all supported build commands:
126
127 ::
128
129 make help
130
131TFTF test image
132```````````````
133
134``tftf.bin`` is the main test image to exercise the TF-A features. The other
135test images provided in this repository are optional dependencies that TFTF
136needs to test some specific features.
137
138``tftf.bin`` may be built independently of the other test images using the
139following command:
140
141::
142
143 make PLAT=<platform> tftf
144
145In TF-A boot flow, ``tftf.bin`` replaces the ``BL33`` image and should be
146injected in the FIP image. This might be achieved by running the following
147command from the TF-A root directory:
148
149::
150
151 BL33=tftf.bin make PLAT=<platform> fip
152
153Please refer to the `TF-A User guide`_ for further details.
154
155NS_BL1U and NS_BL2U test images
156```````````````````````````````
157
158``ns_bl1u.bin`` and ``ns_bl2u.bin`` are test images that exercise the `Firmware
159Update`_ (FWU) feature of TF-A [#]_. Throughout this document, they will be
160referred as the `FWU test images`.
161
162In addition to updating the firmware, the FWU test images also embed some tests
163that exercise the `FWU state machine`_ implemented in the TF-A. They send valid
164and invalid SMC requests to the TF-A BL1 image in order to test its robustness.
165
166NS_BL1U test image
167''''''''''''''''''
168
169The ``NS_BL1U`` image acts as the `Application Processor (AP) Firmware Update
170Boot ROM`. This typically is the first software agent executing on the AP in the
171Normal World during a firmware update operation. Its primary purpose is to load
172subsequent firmware update images from an external interface, such as NOR Flash,
173and communicate with ``BL1`` to authenticate those images.
174
175The ``NS_BL1U`` test image provided in this repository performs the following
176tasks:
177
178- Load FWU images from external non-volatile storage (typically flash memory)
179 to Non-Secure RAM.
180
181- Request TF-A BL1 to copy these images in Secure RAM and authenticate them.
182
183- Jump to ``NS_BL2U`` which carries out the next steps in the firmware update
184 process.
185
186This image may be built independently of the other test images using the
187following command:
188
189::
190
191 make PLAT=<platform> ns_bl1u
192
193NS_BL2U test image
194''''''''''''''''''
195
196The ``NS_BL2U`` image acts as the `AP Firmware Updater`. Its primary
197responsibility is to load a new set of firmware images from an external
198interface and write them into non-volatile storage.
199
200The ``NS_BL2U`` test image provided in this repository overrides the original
201FIP image stored in flash with the backup FIP image (see below).
202
203This image may be built independently of the other test images using the
204following command:
205
206::
207
208 make PLAT=<platform> ns_bl2u
209
210Putting it all together
211'''''''''''''''''''''''
212
213The FWU test images should be used in conjunction with the TFTF image, as the
214latter initiates the FWU process by corrupting the FIP image and resetting the
215target. Once the FWU process is complete, TFTF takes over again and checks that
216the firmware was successfully updated.
217
218To sum up, 3 images must be built out of the TF-A Tests repository in order to
219test the TF-A Firmware Update feature:
220
221 - ``ns_bl1u.bin``
222 - ``ns_bl2u.bin``
223 - ``tftf.bin``
224
225Once that's done, they must be combined in the right way.
226
227 - ``ns_bl1u.bin`` is a standalone image and does not require any further
228 processing.
229
230 - ``ns_bl2u.bin`` must be injected into the ``FWU_FIP`` image. This might be
231 achieved by setting ``NS_BL2U=ns_bl2u.bin`` when building the ``FWU_FIP``
232 image out of the TF-A repository. Please refer to the section `Building FIP
233 images with support for Trusted Board Boot`_ in the TF-A User Guide.
234
235 - ``tftf.bin`` must be injected in the standard FIP image, as explained
236 in section `TFTF test image`_.
237
238Additionally, on Juno platform, the FWU FIP must contain a ``SCP_BL2U`` image.
239This image can simply be a copy of the standard ``SCP_BL2`` image if no specific
240firmware update operations need to be carried on the SCP side.
241
242Finally, the backup FIP image must be created. This can simply be a copy of the
243standard FIP image, which means that the Firmware Update process will restore
244the original, uncorrupted FIP image.
245
246EL3 test payload
247````````````````
248
249``el3_payload.bin`` is a test image exercising the alternative `EL3 payload boot
250flow`_ in TF-A. Refer to the `EL3 test payload README file`_ for more details
251about its behaviour and how to build and run it.
252
253Cactus test image
254`````````````````
255
256``cactus.bin`` is a test secure partition that exercises the `Secure Partition
257Manager`_ (SPM) in TF-A [#]_. It runs in Secure-EL0. It performs the following
258tasks:
259
260- Test that TF-A has correctly setup the secure partition environment: Cactus
261 should be allowed to perform cache maintenance operations, access floating
262 point registers, etc.
263
264- Test that TF-A accepts to change data access permissions and instruction
265 permissions on behalf of Cactus for memory regions the latter owns.
266
267- Test communication with SPM through the `ARM Management Mode Interface`_.
268
269At the moment, Cactus is supported on AArch64 FVP only. It may be built
270independently of the other test images using the following command:
271
272::
273
274 make PLAT=fvp cactus
275
276In TF-A boot flow, Cactus replaces the ``BL32`` image and should be injected in
277the FIP image. This might be achieved by running the following command from
278the TF-A root directory:
279
280::
281
282 BL32=cactus.bin make PLAT=fvp fip
283
284Please refer to the `TF-A User guide`_ for further details.
285
286To run the full set of tests in Cactus, it should be used in conjunction with
287the TFTF image, as the latter sends the Management Mode requests that Cactus
288services.
289
290Summary of build options
291````````````````````````
292
293As much as possible, TF-A Tests dynamically detect the platform hardware
294components and available features. There are a few build options to select
295specific features where the dynamic detection falls short. This section lists
296them.
297
298Unless mentioned otherwise, these options are expected to be specified at the
299build command line and are not to be modified in any component makefiles.
300
301Note that the build system doesn't track dependencies for build options.
302Therefore, if any of the build options are changed from a previous build, a
303clean build must be performed.
304
305Build options shared across test images
306'''''''''''''''''''''''''''''''''''''''
307
308Most of the build options listed in this section apply to TFTF, the FWU test
309images and Cactus, unless otherwise specified. These do not influence the EL3
310payload, whose simplistic build system is mostly independent.
311
312- ``ARCH``: Choose the target build architecture for TF-A Tests. It can take
313 either ``aarch64`` or ``aarch32`` as values. By default, it is defined to
314 ``aarch64``. Not all test images support this build option.
315
316- ``ARM_ARCH_MAJOR``: The major version of Arm Architecture to target when
317 compiling TF-A Tests. Its value must be numeric, and defaults to 8.
318
319- ``ARM_ARCH_MINOR``: The minor version of Arm Architecture to target when
320 compiling TF-A Tests. Its value must be a numeric, and defaults to 0.
321
322- ``DEBUG``: Chooses between a debug and a release build. A debug build
323 typically embeds assertions checking the validity of some assumptions and its
324 output is more verbose. The option can take either 0 (release) or 1 (debug)
325 as values. 0 is the default.
326
327- ``ENABLE_ASSERTIONS``: This option controls whether calls to ``assert()`` are
328 compiled out.
329
330 - For debug builds, this option defaults to 1, and calls to ``assert()`` are
331 compiled in.
332 - For release builds, this option defaults to 0 and calls to ``assert()``
333 are compiled out.
334
335 This option can be set independently of ``DEBUG``. It can also be used to
336 hide any auxiliary code that is only required for the assertion and does not
337 fit in the assertion itself.
338
339- ``LOG_LEVEL``: Chooses the log level, which controls the amount of console log
340 output compiled into the build. This should be one of the following:
341
342 ::
343
344 0 (LOG_LEVEL_NONE)
345 10 (LOG_LEVEL_ERROR)
346 20 (LOG_LEVEL_NOTICE)
347 30 (LOG_LEVEL_WARNING)
348 40 (LOG_LEVEL_INFO)
349 50 (LOG_LEVEL_VERBOSE)
350
351 All log output up to and including the selected log level is compiled into
352 the build. The default value is 40 in debug builds and 20 in release builds.
353
354- ``PLAT``: Choose a platform to build TF-A Tests for. The chosen platform name
355 must be a subdirectory of any depth under ``plat/``, and must contain a
356 platform makefile named ``platform.mk``. For example, to build TF-A Tests for
357 the Arm Juno board, select ``PLAT=juno``.
358
359- ``V``: Verbose build. If assigned anything other than 0, the build commands
360 are printed. Default is 0.
361
362TFTF build options
363''''''''''''''''''
364
365- ``NEW_TEST_SESSION``: Choose whether a new test session should be started
366 every time or whether the framework should determine whether a previous
367 session was interrupted and resume it. It can take either 1 (always
368 start new session) or 0 (resume session as appropriate). 1 is the default.
369
370- ``SHELL_COLOR``: Choose whether text messages should use shell's color escape
371 sequences to ease identifying which CPU displays it. If enabled, this makes
372 each CPU write part of the message in a different color. It can take either
373 0 (disabled) or 1 (enabled) as values. 0 is the default.
374
375- ``TEST_REPORTS``: List of desired test reports. Test reports are described by
376 a space-separated list of colon-separated pairs of report destination and
377 report type. Valid destinations are: 'uart' and 'semihosting'. Valid report
378 types are 'raw' (text output) or 'junit' (XML Junit format). The default is
379 'uart:raw', that is a text report printed on the UART. Here's an example of
380 multiple reports: 'uart:raw semihosting:junit'. The files stored on
381 semihosting are named 'tftf_report_junit.xml' and 'tftf_report_raw.txt'.
382
383- ``TESTS_FILE``: Path to the XML file listing the tests to run. Default is
384 ``plat/<platform>/tests.xml`` if it exists, otherwise it falls back to
385 ``tftf/tests/tests-common.xml``.
386
387- ``USE_NVM``: Used to select the location of test results. It can take either 0
388 (RAM) or 1 (non-volatile memory like flash) as test results storage. Default
389 value is 0, as writing to the flash significantly slows tests down.
390
391FWU test images build options
392'''''''''''''''''''''''''''''
393
394- ``FIRMWARE_UPDATE``: Whether the Firmware Update test images (i.e.
395 ``NS_BL1U`` and ``NS_BL2U``) should be built. The default value is 0. The
396 platform makefile is free to override this value if Firmware Update is
397 supported on this platform.
398
399Checking source code style
400--------------------------
401
402When making changes to the source for submission to the project, the source must
403be in compliance with the Linux style guide. To assist with this, the project
404Makefile provides two targets, which both utilise the ``checkpatch.pl`` script
405that ships with the Linux source tree.
406
407To check the entire source tree, you must first download copies of
408``checkpatch.pl``, ``spelling.txt`` and ``const_structs.checkpatch`` available
409in the `Linux master tree`_ scripts directory, then set the ``CHECKPATCH``
410environment variable to point to ``checkpatch.pl`` (with the other 2 files in
411the same directory).
412
413Then use the following command:
414
415::
416
417 make CHECKPATCH=<path-to-linux>/linux/scripts/checkpatch.pl checkcodebase
418
419To limit the coding style checks to your local changes, use:
420
421::
422
423 make CHECKPATCH=<path-to-linux>/linux/scripts/checkpatch.pl checkpatch
424
425By default, this will check all patches between ``origin/master`` and your local
426branch. If you wish to use a different reference commit, this can be specified
427using the ``BASE_COMMIT`` variable.
428
429Running the TF-A Tests
430----------------------
431
432Refer to the sections `Running the software on FVP`_ and `Running the software
433on Juno`_ in `TF-A User Guide`_. The same instructions mostly apply to run the
434TF-A Tests on those 2 platforms. The difference is that the following images are
435not needed here:
436
437- Normal World bootloader. The TFTF replaces it in the boot flow;
438
439- Linux Kernel;
440
441- Device tree;
442
443- Filesystem.
444
445In other words, only the following software images are needed:
446
447- ``BL1`` firmware image;
448
449- ``FIP`` image containing the following images:
450 - ``BL2``;
451 - ``SCP_BL2`` if required by the platform (e.g. Juno);
452 - ``BL31``;
453 - ``BL32`` (optional);
454 - ``tftf.bin`` (standing as the BL33 image).
455
456Running the FWU tests
457`````````````````````
458
459As previously mentioned in section `Putting it all together`_, there are a
460couple of extra images involved when running the FWU tests. They need to be
461loaded at the right addresses, which depend on the platform.
462
463FVP
464'''
465
466In addition to the usual BL1 and FIP images, the following extra images must be
467loaded:
468
469- ``NS_BL1U`` image at address ``0x0BEB8000`` (i.e. NS_BL1U_BASE macro in TF-A)
470- ``FWU_FIP`` image at address ``0x08400000`` (i.e. NS_BL2U_BASE macro in TF-A)
471- ``Backup FIP`` image at address ``0x09000000`` (i.e. FIP_BKP_ADDRESS macro in
472 TF-A tests).
473
474An example script is provided in `scripts/run_fwu_fvp.sh`_.
475
476Juno
477''''
478
479The same set of extra images and load addresses apply for Juno as for FVP.
480
481The new images must be programmed in flash memory by adding some entries in the
482``SITE1/HBI0262x/images.txt`` configuration file on the Juno SD card (where
483``x`` depends on the revision of the Juno board). Refer to the `Juno Getting
484Started Guide`_, section 2.3 "Flash memory programming" for more
485information. Users should ensure these do not overlap with any other entries in
486the file.
487
488Addresses in this file are expressed as an offset from the base address of the
489flash (that is, ``0x08000000``).
490
491::
492
493 NOR10UPDATE: AUTO ; Image Update:NONE/AUTO/FORCE
494 NOR10ADDRESS: 0x00400000 ; Image Flash Address
495 NOR10FILE: \SOFTWARE\fwu_fip.bin ; Image File Name
496 NOR10LOAD: 00000000 ; Image Load Address
497 NOR10ENTRY: 00000000 ; Image Entry Point
498
499 NOR11UPDATE: AUTO ; Image Update:NONE/AUTO/FORCE
500 NOR11ADDRESS: 0x03EB8000 ; Image Flash Address
501 NOR11FILE: \SOFTWARE\ns_bl1u.bin ; Image File Name
502 NOR11LOAD: 00000000 ; Image Load Address
503 NOR11ENTRY: 00000000 ; Image Load Address
504
505 NOR12UPDATE: AUTO ; Image Update:NONE/AUTO/FORCE
506 NOR12ADDRESS: 0x01000000 ; Image Flash Address
507 NOR12FILE: \SOFTWARE\backup_fip.bin ; Image File Name
508 NOR12LOAD: 00000000 ; Image Load Address
509 NOR12ENTRY: 00000000 ; Image Entry Point
510
511--------------
512
513.. [#] Therefore, the Trusted Board Boot feature must be enabled in TF-A for
514 the FWU test images to work. Please refer the `TF-A User guide`_ for
515 further details.
516
517.. [#] Therefore, the Secure Partition Manager must be enabled in TF-A for
518 Cactus to work. Please refer to the `TF-A User guide`_ for further
519 details.
520
521--------------
522
523*Copyright (c) 2018, Arm Limited. All rights reserved.*
524
525.. _Development Studio 5 (DS-5): https://developer.arm.com/products/software-development-tools/ds-5-development-studio
526
527.. _FVP models: https://developer.arm.com/products/system-design/fixed-virtual-platforms
528
529.. _AArch32 GNU cross-toolchain: http://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/arm-linux-gnueabihf/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz
530.. _AArch64 GNU cross-toolchain: http://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/aarch64-linux-gnu/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu.tar.xz
531
532.. _Linux master tree: https://github.com/torvalds/linux/tree/master/
533
534.. _TF-A: https://www.github.com/ARM-software/arm-trusted-firmware
535.. _Trusted Firmware-A (TF-A): TF-A_
536.. _EL3 payload boot flow: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#el3-payloads-alternative-boot-flow
537.. _TF-A User Guide: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst
538.. _Firmware Update: FWU_
539.. _FWU: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/firmware-update.rst
540.. _FWU state machine: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/firmware-update.rst#fwu-state-machine
541.. _Running the software on FVP: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#running-the-software-on-fvp
542.. _Running the software on Juno: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#running-the-software-on-juno
543.. _Building FIP images with support for Trusted Board Boot: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#building-fip-images-with-support-for-trusted-board-boot
544.. _Secure partition Manager: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/secure-partition-manager-design.rst
545
546.. _EL3 test payload README file: ../el3_payload/README
547.. _scripts/run_fwu_fvp.sh: ../scripts/run_fwu_fvp.sh
548
549.. _ARM Management Mode Interface: http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf
550.. _Juno Getting Started Guide: http://infocenter.arm.com/help/topic/com.arm.doc.dui0928e/DUI0928E_juno_arm_development_platform_gsg.pdf