blob: 4c180c9c73ca40391fd5f6a29d8bbdbe599e187d [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.
18
19 | <file> is the absolute path to configurations file
20 named as ``Config<APP_NAME>.cmake``.
21 | i.e. On Linux:
22 ``-DPROJ_CONFIG=`readlink -f ../ConfigRegression.cmake```
23
24 * - -DTARGET_PLATFORM=<target platform name>
25 - Specifies the target platform.
26 Supported platforms:
27
28 - 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``
32 - Musca-A1 test chip board (Cortex-M33 SSE-200 subsystem)
33 ``-DTARGET_PLATFORM=MUSCA_A``
34 - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
35 ``-DTARGET_PLATFORM=MUSCA_B1``
36
37 * - -DCOMPILER=<compiler name>
38 - Specifies the compiler toolchain
39 The possible values are:
40
41 - ``ARMCLANG``
42 - ``GNUARM``
43 * - -DCMAKE_BUILD_TYPE=<build type>
44 - Configures debugging support.
45 The possible values are:
46
47 - ``Debug``
48 - ``Release``
49 - ``Relwithdebinfo``
50 - ``Minsizerel``
51 * - -DMBEDTLS_DEBUG=<ON|OFF>
52 - To enables debug symbols for the Mbed TLS library.
53
54.. 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
62- Mbed TLS is used as a crypto library on the secure side
63
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
82 git clone https://github.com/ARM-software/CMSIS_5.git -b 5.2.0
83
84Build steps for the AN521 target platform:
85==========================================
86.. code-block:: bash
87
88 cd <TF-M base folder>
89 cd trusted-firmware-m
90 mkdir cmake_build
91 cd cmake_build
92 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
93 cmake --build ./ -- install
94
95Regression Tests for the AN521 target platform
96==============================================
97*TF-M build regression tests on Linux*
98
99.. code-block:: bash
100
101 cd <TF-M base folder>
102 cd trusted-firmware-m
103 mkdir cmake_test
104 cd cmake_test
105 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
106 cmake --build ./ -- install
107
108*TF-M build regression tests on Windows*
109
110.. code-block:: bash
111
112 cd <TF-M base folder>
113 cd trusted-firmware-m
114 mkdir cmake_test
115 cd cmake_test
116 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
117 cmake --build ./ -- install
118
119Build for PSA API compliance tests
120==================================
121The build system provides the support for linking with prebuilt PSA API
122compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``
123config file. The build system assumes that the PSA API compliance test suite
124is checked out at the same level of the TF-M root folder and the default
125name for the build folder has been used when compiling the PSA API compliance
126tests. Each set of tests for the Secure Storage, Crypto and Attestation services
127needs to be enabled at the build configuration step by defining::
128
129 -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION
130
131respectively for the corresponding service. For example, to enable the PSA API
132tests for the Crypto service only:
133
134.. code-block:: bash
135
136 cd <TF-M base folder>
137 cd trusted-firmware-m
138 mkdir cmake_psa_test
139 cd cmake_psa_test
140 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../ConfigPsaApiTest.cmake` -DPSA_API_TEST_CRYPTO -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
141 cmake --build ./ -- install
142
143Location of build artifacts
144===========================
145The build system defines an API which allow easy usage of build
146artifacts. The ``install`` build target copies all files which might be needed
147as a dependency by external tools or build systems to the
148``<build_dir>/install/outputs``
149directory, with the following directory hierarchy:
150
151::
152
153 <build_dir>/install/outputs/fvp/
154 <build_dir>/install/outputs/<target_platform>/
155
156There is one folder for FVP testing, with more elaborate naming and
157there is an other for testing on target hardware platform (AN521, etc.), where
158naming convention is aligned with 8.3 format. The dependency tree of
159``install`` build target ensures a proper update (i.e. build) of all output
160files before the actual installation step takes place. As such it is suggested
161to use this build target to build TF-M.
162
163Export dependency files for NS applications
164-------------------------------------------
165An NS application requires a number of files to interface with TF-M.
166The build system exports these files as part of the ``install`` target and
167places them in to a single directory::
168
169 <build_dir>/install/export/tfm
170
171Further details on how to integrate a new NS app with TF-M are available in the
172:doc:`integration guide <tfm_integration_guide>`.
173
174Building the documentation
175==========================
176Please ensure the dependencies for building the firmware and the
177documentation are installed as explained in the
178:doc:`software requirements <tfm_sw_requirement>`.
179
180Building PDF output is optional and can be disabled by removing LaTex from the
181PATH.
182
183.. Note::
184 For building the documentation all tools needed to build the firmware must
185 be available.
186
187Building the Reference Manual
188-----------------------------
189.. code-block:: bash
190
191 cd <TF-M base folder>
192 mkdir cmake_doc
193 cd cmake_doc
194 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
195 cmake --build ./ -- install_doc
196
197The documentation files will be available under the directory::
198
199 cmake_doc/install/doc/reference_manual
200
201Building the User Guide
202-----------------------
203.. code-block:: bash
204
205 cd <TF-M base folder>
206 mkdir cmake_doc
207 cd cmake_doc
208 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
209 cmake --build ./ -- install_userguide
210
211The documentation files will be available under the directory::
212
213 cmake_doc/install/doc/user_guide
214
215--------------
216
217*Copyright (c) 2017-2019, Arm Limited. All rights reserved.*