blob: f3502512f2691e578bbc1148edf64b68070b41e5 [file] [log] [blame]
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02001######################
2TF-M build instruction
3######################
4Please make sure you have all required software installed as explained in the
5:doc:`software requirements <tfm_sw_requirement>`.
6
7*********************
8Configuring the build
9*********************
10The build configuration for TF-M is provided to the build system using command
11line arguments:
12
13.. list-table::
14 :widths: 20 80
15
16 * - -DPROJ_CONFIG=<file>
17 - Specifies the way the application is built.
Antonio de Angelisee774c22019-05-03 13:44:01 +010018
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020019 | <file> is the absolute path to configurations file
20 named as ``Config<APP_NAME>.cmake``.
21 | i.e. On Linux:
Ken Liue40f9a22019-06-03 16:42:47 +080022 ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake```
Antonio de Angelisee774c22019-05-03 13:44:01 +010023
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020024 * - -DTARGET_PLATFORM=<target platform name>
25 - Specifies the target platform.
26 Supported platforms:
Antonio de Angelisee774c22019-05-03 13:44:01 +010027
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020028 - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
29 ``-DTARGET_PLATFORM=AN521``
30 - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
31 ``-DTARGET_PLATFORM=AN519``
Jamie Foxb8a92702019-06-05 17:19:31 +010032 - Musca-A test chip board (Cortex-M33 SSE-200 subsystem)
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020033 ``-DTARGET_PLATFORM=MUSCA_A``
34 - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
35 ``-DTARGET_PLATFORM=MUSCA_B1``
Kevin Peng0a142112018-09-21 10:42:22 +080036 - Cortex-M33 SSE-200 subsystem for MPS3 (AN524)
37 ``-DTARGET_PLATFORM=AN524``
Antonio de Angelisee774c22019-05-03 13:44:01 +010038
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020039 * - -DCOMPILER=<compiler name>
40 - Specifies the compiler toolchain
41 The possible values are:
Antonio de Angelisee774c22019-05-03 13:44:01 +010042
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020043 - ``ARMCLANG``
44 - ``GNUARM``
45 * - -DCMAKE_BUILD_TYPE=<build type>
46 - Configures debugging support.
47 The possible values are:
Antonio de Angelisee774c22019-05-03 13:44:01 +010048
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020049 - ``Debug``
50 - ``Release``
51 - ``Relwithdebinfo``
52 - ``Minsizerel``
53 * - -DMBEDTLS_DEBUG=<ON|OFF>
Antonio de Angelisee774c22019-05-03 13:44:01 +010054 - Enables debug symbols for the Mbed TLS and Mbed Crypto libraries.
55
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020056.. Note::
57 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
58 without BL2 bootloader.
59
60*******************
61External dependency
62*******************
Antonio de Angelis70ae80f2019-02-26 14:57:40 +000063- `CMSIS_5` is used to import RTX for the example non-secure app
Antonio de Angelisee774c22019-05-03 13:44:01 +010064- Mbed TLS and Mbed Crypto are used as crypto libraries on the secure side
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020065
66****************
67TF-M build steps
68****************
69TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source
70build environment. The instructions are below.
71
72.. Note::
73
74 It is recommended to build each different build configurations in separate
75 directories.
76
77Getting the source-code
78=======================
79.. code-block:: bash
80
81 cd <TF-M base folder>
82 git clone https://git.trustedfirmware.org/trusted-firmware-m.git
83 git clone https://github.com/ARMmbed/mbedtls.git -b mbedtls-2.7.9
Antonio de Angelisee774c22019-05-03 13:44:01 +010084 git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-1.0.0
Antonio de Angelis70ae80f2019-02-26 14:57:40 +000085 git clone https://github.com/ARM-software/CMSIS_5.git -b 5.5.0
86
87.. Note::
88 `CMSIS_5` now uses `git-lfs` for storing large size binaries so the cloning
89 process has changed from previous releases. Please refer to the `CMSIS_5`
90 documentation for more details.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020091
92Build steps for the AN521 target platform:
93==========================================
94.. code-block:: bash
95
96 cd <TF-M base folder>
97 cd trusted-firmware-m
98 mkdir cmake_build
99 cd cmake_build
100 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
101 cmake --build ./ -- install
102
103Regression Tests for the AN521 target platform
104==============================================
105*TF-M build regression tests on Linux*
106
107.. code-block:: bash
108
109 cd <TF-M base folder>
110 cd trusted-firmware-m
111 mkdir cmake_test
112 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800113 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200114 cmake --build ./ -- install
115
116*TF-M build regression tests on Windows*
117
118.. code-block:: bash
119
120 cd <TF-M base folder>
121 cd trusted-firmware-m
122 mkdir cmake_test
123 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800124 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200125 cmake --build ./ -- install
126
127Build for PSA API compliance tests
128==================================
129The build system provides the support for linking with prebuilt PSA API
130compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``
131config file. The build system assumes that the PSA API compliance test suite
132is checked out at the same level of the TF-M root folder and the default
133name for the build folder has been used when compiling the PSA API compliance
134tests. Each set of tests for the Secure Storage, Crypto and Attestation services
135needs to be enabled at the build configuration step by defining::
136
137 -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION
138
139respectively for the corresponding service. For example, to enable the PSA API
140tests for the Crypto service only:
141
142.. code-block:: bash
143
144 cd <TF-M base folder>
145 cd trusted-firmware-m
146 mkdir cmake_psa_test
147 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +0100148 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTest.cmake` -DPSA_API_TEST_CRYPTO=ON -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200149 cmake --build ./ -- install
150
151Location of build artifacts
152===========================
153The build system defines an API which allow easy usage of build
154artifacts. The ``install`` build target copies all files which might be needed
155as a dependency by external tools or build systems to the
156``<build_dir>/install/outputs``
157directory, with the following directory hierarchy:
158
159::
160
161 <build_dir>/install/outputs/fvp/
162 <build_dir>/install/outputs/<target_platform>/
163
164There is one folder for FVP testing, with more elaborate naming and
165there is an other for testing on target hardware platform (AN521, etc.), where
166naming convention is aligned with 8.3 format. The dependency tree of
167``install`` build target ensures a proper update (i.e. build) of all output
168files before the actual installation step takes place. As such it is suggested
169to use this build target to build TF-M.
170
171Export dependency files for NS applications
172-------------------------------------------
173An NS application requires a number of files to interface with TF-M.
174The build system exports these files as part of the ``install`` target and
175places them in to a single directory::
176
177 <build_dir>/install/export/tfm
178
179Further details on how to integrate a new NS app with TF-M are available in the
180:doc:`integration guide <tfm_integration_guide>`.
181
182Building the documentation
183==========================
184Please ensure the dependencies for building the firmware and the
185documentation are installed as explained in the
186:doc:`software requirements <tfm_sw_requirement>`.
187
188Building PDF output is optional and can be disabled by removing LaTex from the
189PATH.
190
191.. Note::
192 For building the documentation all tools needed to build the firmware must
193 be available.
194
195Building the Reference Manual
196-----------------------------
197.. code-block:: bash
198
199 cd <TF-M base folder>
200 mkdir cmake_doc
201 cd cmake_doc
202 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
203 cmake --build ./ -- install_doc
204
205The documentation files will be available under the directory::
206
207 cmake_doc/install/doc/reference_manual
208
209Building the User Guide
210-----------------------
211.. code-block:: bash
212
213 cd <TF-M base folder>
214 mkdir cmake_doc
215 cd cmake_doc
216 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
217 cmake --build ./ -- install_userguide
218
219The documentation files will be available under the directory::
220
221 cmake_doc/install/doc/user_guide
222
223--------------
224
225*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*