blob: 6232b3bd28451c33f67da1b44ae6221a82f52db5 [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
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.
Edison Ai75d69c82019-07-09 18:50:41 +080055 * - -DBUILD_DWARF_VERSION=<dwarf version>
56 - Configures DWARF version.
57 The possible values are:
58
59 - 2
60 - 3
61 - 4
Antonio de Angelisee774c22019-05-03 13:44:01 +010062
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020063.. Note::
64 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
65 without BL2 bootloader.
66
67*******************
68External dependency
69*******************
Antonio de Angelis70ae80f2019-02-26 14:57:40 +000070- `CMSIS_5` is used to import RTX for the example non-secure app
Antonio de Angelisee774c22019-05-03 13:44:01 +010071- Mbed TLS and Mbed Crypto are used as crypto libraries on the secure side
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020072
73****************
74TF-M build steps
75****************
76TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source
77build environment. The instructions are below.
78
79.. Note::
80
81 It is recommended to build each different build configurations in separate
82 directories.
83
84Getting the source-code
85=======================
86.. code-block:: bash
87
88 cd <TF-M base folder>
89 git clone https://git.trustedfirmware.org/trusted-firmware-m.git
90 git clone https://github.com/ARMmbed/mbedtls.git -b mbedtls-2.7.9
Antonio de Angelis2e7d2962019-06-27 11:30:04 +010091 git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-1.1.0
Antonio de Angelis70ae80f2019-02-26 14:57:40 +000092 git clone https://github.com/ARM-software/CMSIS_5.git -b 5.5.0
93
94.. Note::
95 `CMSIS_5` now uses `git-lfs` for storing large size binaries so the cloning
96 process has changed from previous releases. Please refer to the `CMSIS_5`
97 documentation for more details.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020098
99Build steps for the AN521 target platform:
100==========================================
101.. code-block:: bash
102
103 cd <TF-M base folder>
104 cd trusted-firmware-m
105 mkdir cmake_build
106 cd cmake_build
107 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
108 cmake --build ./ -- install
109
110Regression Tests for the AN521 target platform
111==============================================
112*TF-M build regression tests on Linux*
113
114.. code-block:: bash
115
116 cd <TF-M base folder>
117 cd trusted-firmware-m
118 mkdir cmake_test
119 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800120 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200121 cmake --build ./ -- install
122
123*TF-M build regression tests on Windows*
124
125.. code-block:: bash
126
127 cd <TF-M base folder>
128 cd trusted-firmware-m
129 mkdir cmake_test
130 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800131 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200132 cmake --build ./ -- install
133
134Build for PSA API compliance tests
135==================================
136The build system provides the support for linking with prebuilt PSA API
Jamie Fox6b6a19b2019-09-30 16:54:17 +0100137compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``,
138``ConfigPsaApiTestIPC.cmake`` or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config
139file. The build system assumes that the PSA API compliance test suite is checked
140out at the same level of the TF-M root folder and the default name for the build
141folder has been used when compiling the PSA API compliance tests. Each set of
142tests for the Internal Trusted Storage, Secure Storage, Crypto and Attestation
143services needs to be enabled at the build configuration step by defining::
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200144
Jamie Fox6b6a19b2019-09-30 16:54:17 +0100145 -DPSA_API_TEST_INTERNAL_TRUSTED_STORAGE=ON
146 -DPSA_API_TEST_SECURE_STORAGE=ON
147 -DPSA_API_TEST_CRYPTO=ON
148 -DPSA_API_TEST_ATTESTATION=ON
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200149
150respectively for the corresponding service. For example, to enable the PSA API
151tests for the Crypto service only:
152
153.. code-block:: bash
154
155 cd <TF-M base folder>
156 cd trusted-firmware-m
157 mkdir cmake_psa_test
158 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +0100159 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 +0200160 cmake --build ./ -- install
161
162Location of build artifacts
163===========================
164The build system defines an API which allow easy usage of build
165artifacts. The ``install`` build target copies all files which might be needed
166as a dependency by external tools or build systems to the
167``<build_dir>/install/outputs``
168directory, with the following directory hierarchy:
169
170::
171
172 <build_dir>/install/outputs/fvp/
173 <build_dir>/install/outputs/<target_platform>/
174
175There is one folder for FVP testing, with more elaborate naming and
176there is an other for testing on target hardware platform (AN521, etc.), where
177naming convention is aligned with 8.3 format. The dependency tree of
178``install`` build target ensures a proper update (i.e. build) of all output
179files before the actual installation step takes place. As such it is suggested
180to use this build target to build TF-M.
181
182Export dependency files for NS applications
183-------------------------------------------
184An NS application requires a number of files to interface with TF-M.
185The build system exports these files as part of the ``install`` target and
186places them in to a single directory::
187
188 <build_dir>/install/export/tfm
189
190Further details on how to integrate a new NS app with TF-M are available in the
191:doc:`integration guide <tfm_integration_guide>`.
192
193Building the documentation
194==========================
195Please ensure the dependencies for building the firmware and the
196documentation are installed as explained in the
197:doc:`software requirements <tfm_sw_requirement>`.
198
199Building PDF output is optional and can be disabled by removing LaTex from the
200PATH.
201
202.. Note::
203 For building the documentation all tools needed to build the firmware must
204 be available.
205
206Building the Reference Manual
207-----------------------------
208.. code-block:: bash
209
210 cd <TF-M base folder>
211 mkdir cmake_doc
212 cd cmake_doc
213 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
214 cmake --build ./ -- install_doc
215
216The documentation files will be available under the directory::
217
218 cmake_doc/install/doc/reference_manual
219
220Building the User Guide
221-----------------------
222.. code-block:: bash
223
224 cd <TF-M base folder>
225 mkdir cmake_doc
226 cd cmake_doc
227 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
228 cmake --build ./ -- install_userguide
229
230The documentation files will be available under the directory::
231
232 cmake_doc/install/doc/user_guide
233
234--------------
235
236*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*