blob: fd21f7bffc4c17f5c43c3bfd1b8536a1d55e1ca3 [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``
Antonio de Angelisee774c22019-05-03 13:44:01 +010036
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020037 * - -DCOMPILER=<compiler name>
38 - Specifies the compiler toolchain
39 The possible values are:
Antonio de Angelisee774c22019-05-03 13:44:01 +010040
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020041 - ``ARMCLANG``
42 - ``GNUARM``
43 * - -DCMAKE_BUILD_TYPE=<build type>
44 - Configures debugging support.
45 The possible values are:
Antonio de Angelisee774c22019-05-03 13:44:01 +010046
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020047 - ``Debug``
48 - ``Release``
49 - ``Relwithdebinfo``
50 - ``Minsizerel``
51 * - -DMBEDTLS_DEBUG=<ON|OFF>
Antonio de Angelisee774c22019-05-03 13:44:01 +010052 - Enables debug symbols for the Mbed TLS and Mbed Crypto libraries.
53
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020054.. Note::
55 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
56 without BL2 bootloader.
57
58*******************
59External dependency
60*******************
61- CMSIS_5 is used to import RTX for the example non-secure app
Antonio de Angelisee774c22019-05-03 13:44:01 +010062- Mbed TLS and Mbed Crypto are used as crypto libraries on the secure side
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020063
64****************
65TF-M build steps
66****************
67TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source
68build environment. The instructions are below.
69
70.. Note::
71
72 It is recommended to build each different build configurations in separate
73 directories.
74
75Getting the source-code
76=======================
77.. code-block:: bash
78
79 cd <TF-M base folder>
80 git clone https://git.trustedfirmware.org/trusted-firmware-m.git
81 git clone https://github.com/ARMmbed/mbedtls.git -b mbedtls-2.7.9
Antonio de Angelisee774c22019-05-03 13:44:01 +010082 git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-1.0.0
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020083 git clone https://github.com/ARM-software/CMSIS_5.git -b 5.2.0
84
85Build steps for the AN521 target platform:
86==========================================
87.. code-block:: bash
88
89 cd <TF-M base folder>
90 cd trusted-firmware-m
91 mkdir cmake_build
92 cd cmake_build
93 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
94 cmake --build ./ -- install
95
96Regression Tests for the AN521 target platform
97==============================================
98*TF-M build regression tests on Linux*
99
100.. code-block:: bash
101
102 cd <TF-M base folder>
103 cd trusted-firmware-m
104 mkdir cmake_test
105 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800106 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200107 cmake --build ./ -- install
108
109*TF-M build regression tests on Windows*
110
111.. code-block:: bash
112
113 cd <TF-M base folder>
114 cd trusted-firmware-m
115 mkdir cmake_test
116 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +0800117 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200118 cmake --build ./ -- install
119
120Build for PSA API compliance tests
121==================================
122The build system provides the support for linking with prebuilt PSA API
123compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``
124config file. The build system assumes that the PSA API compliance test suite
125is checked out at the same level of the TF-M root folder and the default
126name for the build folder has been used when compiling the PSA API compliance
127tests. Each set of tests for the Secure Storage, Crypto and Attestation services
128needs to be enabled at the build configuration step by defining::
129
130 -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION
131
132respectively for the corresponding service. For example, to enable the PSA API
133tests for the Crypto service only:
134
135.. code-block:: bash
136
137 cd <TF-M base folder>
138 cd trusted-firmware-m
139 mkdir cmake_psa_test
140 cd cmake_psa_test
Ken Liue40f9a22019-06-03 16:42:47 +0800141 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTest.cmake` -DPSA_API_TEST_CRYPTO -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200142 cmake --build ./ -- install
143
144Location of build artifacts
145===========================
146The build system defines an API which allow easy usage of build
147artifacts. The ``install`` build target copies all files which might be needed
148as a dependency by external tools or build systems to the
149``<build_dir>/install/outputs``
150directory, with the following directory hierarchy:
151
152::
153
154 <build_dir>/install/outputs/fvp/
155 <build_dir>/install/outputs/<target_platform>/
156
157There is one folder for FVP testing, with more elaborate naming and
158there is an other for testing on target hardware platform (AN521, etc.), where
159naming convention is aligned with 8.3 format. The dependency tree of
160``install`` build target ensures a proper update (i.e. build) of all output
161files before the actual installation step takes place. As such it is suggested
162to use this build target to build TF-M.
163
164Export dependency files for NS applications
165-------------------------------------------
166An NS application requires a number of files to interface with TF-M.
167The build system exports these files as part of the ``install`` target and
168places them in to a single directory::
169
170 <build_dir>/install/export/tfm
171
172Further details on how to integrate a new NS app with TF-M are available in the
173:doc:`integration guide <tfm_integration_guide>`.
174
175Building the documentation
176==========================
177Please ensure the dependencies for building the firmware and the
178documentation are installed as explained in the
179:doc:`software requirements <tfm_sw_requirement>`.
180
181Building PDF output is optional and can be disabled by removing LaTex from the
182PATH.
183
184.. Note::
185 For building the documentation all tools needed to build the firmware must
186 be available.
187
188Building the Reference Manual
189-----------------------------
190.. code-block:: bash
191
192 cd <TF-M base folder>
193 mkdir cmake_doc
194 cd cmake_doc
195 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
196 cmake --build ./ -- install_doc
197
198The documentation files will be available under the directory::
199
200 cmake_doc/install/doc/reference_manual
201
202Building the User Guide
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=ARMCLANG
210 cmake --build ./ -- install_userguide
211
212The documentation files will be available under the directory::
213
214 cmake_doc/install/doc/user_guide
215
216--------------
217
218*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*