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