blob: efc9acb5512d0b1c0b627a17cdcc68dedd88a233 [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
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100221- ``ns_bl1u.bin``
222- ``ns_bl2u.bin``
223- ``tftf.bin``
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200224
225Once that's done, they must be combined in the right way.
226
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100227- ``ns_bl1u.bin`` is a standalone image and does not require any further
228 processing.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200229
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100230- ``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.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200234
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100235- ``tftf.bin`` must be injected in the standard FIP image, as explained
236 in section `TFTF test image`_.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200237
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
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100330 - 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.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200334
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100335 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.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200338
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
Sandrine Bailleux43ded0f2018-10-03 17:15:05 +0200383- ``TESTS``: Set of tests to run. Use the following command to list all
384 possible sets of tests:
385
386 ::
387
388 make help_tests
389
390 If no set of tests is specified, the standard tests will be selected (see
391 ``tftf/tests/tests-standard.xml``).
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200392
393- ``USE_NVM``: Used to select the location of test results. It can take either 0
394 (RAM) or 1 (non-volatile memory like flash) as test results storage. Default
395 value is 0, as writing to the flash significantly slows tests down.
396
397FWU test images build options
398'''''''''''''''''''''''''''''
399
400- ``FIRMWARE_UPDATE``: Whether the Firmware Update test images (i.e.
401 ``NS_BL1U`` and ``NS_BL2U``) should be built. The default value is 0. The
402 platform makefile is free to override this value if Firmware Update is
403 supported on this platform.
404
405Checking source code style
406--------------------------
407
408When making changes to the source for submission to the project, the source must
409be in compliance with the Linux style guide. To assist with this, the project
410Makefile provides two targets, which both utilise the ``checkpatch.pl`` script
411that ships with the Linux source tree.
412
413To check the entire source tree, you must first download copies of
414``checkpatch.pl``, ``spelling.txt`` and ``const_structs.checkpatch`` available
415in the `Linux master tree`_ scripts directory, then set the ``CHECKPATCH``
416environment variable to point to ``checkpatch.pl`` (with the other 2 files in
417the same directory).
418
419Then use the following command:
420
421::
422
423 make CHECKPATCH=<path-to-linux>/linux/scripts/checkpatch.pl checkcodebase
424
425To limit the coding style checks to your local changes, use:
426
427::
428
429 make CHECKPATCH=<path-to-linux>/linux/scripts/checkpatch.pl checkpatch
430
431By default, this will check all patches between ``origin/master`` and your local
432branch. If you wish to use a different reference commit, this can be specified
433using the ``BASE_COMMIT`` variable.
434
435Running the TF-A Tests
436----------------------
437
438Refer to the sections `Running the software on FVP`_ and `Running the software
439on Juno`_ in `TF-A User Guide`_. The same instructions mostly apply to run the
440TF-A Tests on those 2 platforms. The difference is that the following images are
441not needed here:
442
443- Normal World bootloader. The TFTF replaces it in the boot flow;
444
445- Linux Kernel;
446
447- Device tree;
448
449- Filesystem.
450
451In other words, only the following software images are needed:
452
453- ``BL1`` firmware image;
454
455- ``FIP`` image containing the following images:
John Tsichritzis4586e0d2018-10-18 10:00:28 +0100456
457 - ``BL2``;
458 - ``SCP_BL2`` if required by the platform (e.g. Juno);
459 - ``BL31``;
460 - ``BL32`` (optional);
461 - ``tftf.bin`` (standing as the BL33 image).
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200462
463Running the FWU tests
464`````````````````````
465
466As previously mentioned in section `Putting it all together`_, there are a
467couple of extra images involved when running the FWU tests. They need to be
468loaded at the right addresses, which depend on the platform.
469
470FVP
471'''
472
473In addition to the usual BL1 and FIP images, the following extra images must be
474loaded:
475
476- ``NS_BL1U`` image at address ``0x0BEB8000`` (i.e. NS_BL1U_BASE macro in TF-A)
477- ``FWU_FIP`` image at address ``0x08400000`` (i.e. NS_BL2U_BASE macro in TF-A)
478- ``Backup FIP`` image at address ``0x09000000`` (i.e. FIP_BKP_ADDRESS macro in
479 TF-A tests).
480
481An example script is provided in `scripts/run_fwu_fvp.sh`_.
482
483Juno
484''''
485
486The same set of extra images and load addresses apply for Juno as for FVP.
487
488The new images must be programmed in flash memory by adding some entries in the
489``SITE1/HBI0262x/images.txt`` configuration file on the Juno SD card (where
490``x`` depends on the revision of the Juno board). Refer to the `Juno Getting
491Started Guide`_, section 2.3 "Flash memory programming" for more
492information. Users should ensure these do not overlap with any other entries in
493the file.
494
495Addresses in this file are expressed as an offset from the base address of the
496flash (that is, ``0x08000000``).
497
498::
499
500 NOR10UPDATE: AUTO ; Image Update:NONE/AUTO/FORCE
501 NOR10ADDRESS: 0x00400000 ; Image Flash Address
502 NOR10FILE: \SOFTWARE\fwu_fip.bin ; Image File Name
503 NOR10LOAD: 00000000 ; Image Load Address
504 NOR10ENTRY: 00000000 ; Image Entry Point
505
506 NOR11UPDATE: AUTO ; Image Update:NONE/AUTO/FORCE
507 NOR11ADDRESS: 0x03EB8000 ; Image Flash Address
508 NOR11FILE: \SOFTWARE\ns_bl1u.bin ; Image File Name
509 NOR11LOAD: 00000000 ; Image Load Address
510 NOR11ENTRY: 00000000 ; Image Load Address
511
512 NOR12UPDATE: AUTO ; Image Update:NONE/AUTO/FORCE
513 NOR12ADDRESS: 0x01000000 ; Image Flash Address
514 NOR12FILE: \SOFTWARE\backup_fip.bin ; Image File Name
515 NOR12LOAD: 00000000 ; Image Load Address
516 NOR12ENTRY: 00000000 ; Image Entry Point
517
518--------------
519
520.. [#] Therefore, the Trusted Board Boot feature must be enabled in TF-A for
521 the FWU test images to work. Please refer the `TF-A User guide`_ for
522 further details.
523
524.. [#] Therefore, the Secure Partition Manager must be enabled in TF-A for
525 Cactus to work. Please refer to the `TF-A User guide`_ for further
526 details.
527
528--------------
529
530*Copyright (c) 2018, Arm Limited. All rights reserved.*
531
532.. _Development Studio 5 (DS-5): https://developer.arm.com/products/software-development-tools/ds-5-development-studio
533
534.. _FVP models: https://developer.arm.com/products/system-design/fixed-virtual-platforms
535
536.. _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
537.. _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
538
539.. _Linux master tree: https://github.com/torvalds/linux/tree/master/
540
541.. _TF-A: https://www.github.com/ARM-software/arm-trusted-firmware
542.. _Trusted Firmware-A (TF-A): TF-A_
543.. _EL3 payload boot flow: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#el3-payloads-alternative-boot-flow
544.. _TF-A User Guide: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst
545.. _Firmware Update: FWU_
546.. _FWU: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/firmware-update.rst
547.. _FWU state machine: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/firmware-update.rst#fwu-state-machine
548.. _Running the software on FVP: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#running-the-software-on-fvp
549.. _Running the software on Juno: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/user-guide.rst#running-the-software-on-juno
550.. _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
551.. _Secure partition Manager: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/secure-partition-manager-design.rst
552
553.. _EL3 test payload README file: ../el3_payload/README
554.. _scripts/run_fwu_fvp.sh: ../scripts/run_fwu_fvp.sh
555
556.. _ARM Management Mode Interface: http://infocenter.arm.com/help/topic/com.arm.doc.den0060a/DEN0060A_ARM_MM_Interface_Specification.pdf
557.. _Juno Getting Started Guide: http://infocenter.arm.com/help/topic/com.arm.doc.dui0928e/DUI0928E_juno_arm_development_platform_gsg.pdf