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