blob: 33aefd791caff72784fa70f146076f4d32b08e5f [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.
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
137compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``
138config file. The build system assumes that the PSA API compliance test suite
139is checked out at the same level of the TF-M root folder and the default
140name for the build folder has been used when compiling the PSA API compliance
141tests. Each set of tests for the Secure Storage, Crypto and Attestation services
142needs to be enabled at the build configuration step by defining::
143
144 -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION
145
146respectively for the corresponding service. For example, to enable the PSA API
147tests for the Crypto service only:
148
149.. code-block:: bash
150
151 cd <TF-M base folder>
152 cd trusted-firmware-m
153 mkdir cmake_psa_test
154 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +0100155 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 +0200156 cmake --build ./ -- install
157
158Location of build artifacts
159===========================
160The build system defines an API which allow easy usage of build
161artifacts. The ``install`` build target copies all files which might be needed
162as a dependency by external tools or build systems to the
163``<build_dir>/install/outputs``
164directory, with the following directory hierarchy:
165
166::
167
168 <build_dir>/install/outputs/fvp/
169 <build_dir>/install/outputs/<target_platform>/
170
171There is one folder for FVP testing, with more elaborate naming and
172there is an other for testing on target hardware platform (AN521, etc.), where
173naming convention is aligned with 8.3 format. The dependency tree of
174``install`` build target ensures a proper update (i.e. build) of all output
175files before the actual installation step takes place. As such it is suggested
176to use this build target to build TF-M.
177
178Export dependency files for NS applications
179-------------------------------------------
180An NS application requires a number of files to interface with TF-M.
181The build system exports these files as part of the ``install`` target and
182places them in to a single directory::
183
184 <build_dir>/install/export/tfm
185
186Further details on how to integrate a new NS app with TF-M are available in the
187:doc:`integration guide <tfm_integration_guide>`.
188
189Building the documentation
190==========================
191Please ensure the dependencies for building the firmware and the
192documentation are installed as explained in the
193:doc:`software requirements <tfm_sw_requirement>`.
194
195Building PDF output is optional and can be disabled by removing LaTex from the
196PATH.
197
198.. Note::
199 For building the documentation all tools needed to build the firmware must
200 be available.
201
202Building the Reference Manual
203-----------------------------
204.. code-block:: bash
205
206 cd <TF-M base folder>
207 mkdir cmake_doc
208 cd cmake_doc
209 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
210 cmake --build ./ -- install_doc
211
212The documentation files will be available under the directory::
213
214 cmake_doc/install/doc/reference_manual
215
216Building the User Guide
217-----------------------
218.. code-block:: bash
219
220 cd <TF-M base folder>
221 mkdir cmake_doc
222 cd cmake_doc
223 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
224 cmake --build ./ -- install_userguide
225
226The documentation files will be available under the directory::
227
228 cmake_doc/install/doc/user_guide
229
230--------------
231
232*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*