blob: b817353b74ea3f821b9d6ac9e22f0dbbdd17a30a [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*******************
63- 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
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020085 git clone https://github.com/ARM-software/CMSIS_5.git -b 5.2.0
86
87Build steps for the AN521 target platform:
88==========================================
89.. code-block:: bash
90
91 cd <TF-M base folder>
92 cd trusted-firmware-m
93 mkdir cmake_build
94 cd cmake_build
95 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
96 cmake --build ./ -- install
97
98Regression Tests for the AN521 target platform
99==============================================
100*TF-M build regression tests on Linux*
101
102.. code-block:: bash
103
104 cd <TF-M base folder>
105 cd trusted-firmware-m
106 mkdir cmake_test
107 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800108 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200109 cmake --build ./ -- install
110
111*TF-M build regression tests on Windows*
112
113.. code-block:: bash
114
115 cd <TF-M base folder>
116 cd trusted-firmware-m
117 mkdir cmake_test
118 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800119 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200120 cmake --build ./ -- install
121
122Build for PSA API compliance tests
123==================================
124The build system provides the support for linking with prebuilt PSA API
125compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``
126config file. The build system assumes that the PSA API compliance test suite
127is checked out at the same level of the TF-M root folder and the default
128name for the build folder has been used when compiling the PSA API compliance
129tests. Each set of tests for the Secure Storage, Crypto and Attestation services
130needs to be enabled at the build configuration step by defining::
131
132 -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION
133
134respectively for the corresponding service. For example, to enable the PSA API
135tests for the Crypto service only:
136
137.. code-block:: bash
138
139 cd <TF-M base folder>
140 cd trusted-firmware-m
141 mkdir cmake_psa_test
142 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +0100143 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 +0200144 cmake --build ./ -- install
145
146Location of build artifacts
147===========================
148The build system defines an API which allow easy usage of build
149artifacts. The ``install`` build target copies all files which might be needed
150as a dependency by external tools or build systems to the
151``<build_dir>/install/outputs``
152directory, with the following directory hierarchy:
153
154::
155
156 <build_dir>/install/outputs/fvp/
157 <build_dir>/install/outputs/<target_platform>/
158
159There is one folder for FVP testing, with more elaborate naming and
160there is an other for testing on target hardware platform (AN521, etc.), where
161naming convention is aligned with 8.3 format. The dependency tree of
162``install`` build target ensures a proper update (i.e. build) of all output
163files before the actual installation step takes place. As such it is suggested
164to use this build target to build TF-M.
165
166Export dependency files for NS applications
167-------------------------------------------
168An NS application requires a number of files to interface with TF-M.
169The build system exports these files as part of the ``install`` target and
170places them in to a single directory::
171
172 <build_dir>/install/export/tfm
173
174Further details on how to integrate a new NS app with TF-M are available in the
175:doc:`integration guide <tfm_integration_guide>`.
176
177Building the documentation
178==========================
179Please ensure the dependencies for building the firmware and the
180documentation are installed as explained in the
181:doc:`software requirements <tfm_sw_requirement>`.
182
183Building PDF output is optional and can be disabled by removing LaTex from the
184PATH.
185
186.. Note::
187 For building the documentation all tools needed to build the firmware must
188 be available.
189
190Building the Reference Manual
191-----------------------------
192.. code-block:: bash
193
194 cd <TF-M base folder>
195 mkdir cmake_doc
196 cd cmake_doc
197 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
198 cmake --build ./ -- install_doc
199
200The documentation files will be available under the directory::
201
202 cmake_doc/install/doc/reference_manual
203
204Building the User Guide
205-----------------------
206.. code-block:: bash
207
208 cd <TF-M base folder>
209 mkdir cmake_doc
210 cd cmake_doc
211 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
212 cmake --build ./ -- install_userguide
213
214The documentation files will be available under the directory::
215
216 cmake_doc/install/doc/user_guide
217
218--------------
219
220*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*