blob: bb15f584d303fc0eb833991ae6fafe39e654d05d [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
Galanakis, Minos757139a2019-11-11 15:00:11 +00007The external dependecies are briefly listed in the
8:ref:`docs/user_guides/tfm_build_instruction:External dependencies` section.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02009
Galanakis, Minos757139a2019-11-11 15:00:11 +000010The configuration-table
11:ref:`docs/user_guides/tfm_build_instruction:Configuring the build` section
12explains all the supported build parameters:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020013
14****************
15TF-M build steps
16****************
17TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source
18build environment. The instructions are below.
19
20.. Note::
21
22 It is recommended to build each different build configurations in separate
23 directories.
24
25Getting the source-code
26=======================
27.. code-block:: bash
28
29 cd <TF-M base folder>
30 git clone https://git.trustedfirmware.org/trusted-firmware-m.git
Antonio de Angelis04debbd2019-10-14 12:12:52 +010031 git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-3.0.1
Antonio de Angelis70ae80f2019-02-26 14:57:40 +000032 git clone https://github.com/ARM-software/CMSIS_5.git -b 5.5.0
33
34.. Note::
35 `CMSIS_5` now uses `git-lfs` for storing large size binaries so the cloning
36 process has changed from previous releases. Please refer to the `CMSIS_5`
37 documentation for more details.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020038
39Build steps for the AN521 target platform:
40==========================================
41.. code-block:: bash
42
43 cd <TF-M base folder>
44 cd trusted-firmware-m
45 mkdir cmake_build
46 cd cmake_build
47 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
48 cmake --build ./ -- install
49
50Regression Tests for the AN521 target platform
51==============================================
52*TF-M build regression tests on Linux*
53
54.. code-block:: bash
55
56 cd <TF-M base folder>
57 cd trusted-firmware-m
58 mkdir cmake_test
59 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +080060 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020061 cmake --build ./ -- install
62
63*TF-M build regression tests on Windows*
64
65.. code-block:: bash
66
67 cd <TF-M base folder>
68 cd trusted-firmware-m
69 mkdir cmake_test
70 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +080071 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020072 cmake --build ./ -- install
73
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +053074Build for PSA Developer API compliance tests
75============================================
76The build system provides the support for linking with prebuilt PSA Developer
77API compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``,
Jamie Fox6b6a19b2019-09-30 16:54:17 +010078``ConfigPsaApiTestIPC.cmake`` or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config
79file. The build system assumes that the PSA API compliance test suite is checked
80out at the same level of the TF-M root folder and the default name for the build
81folder has been used when compiling the PSA API compliance tests. Each set of
82tests for the Internal Trusted Storage, Secure Storage, Crypto and Attestation
83services needs to be enabled at the build configuration step by defining::
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020084
Jamie Fox6b6a19b2019-09-30 16:54:17 +010085 -DPSA_API_TEST_INTERNAL_TRUSTED_STORAGE=ON
Karl Zhang1895a2c2020-03-08 18:27:32 +080086 -DPSA_API_TEST_PROTECTED_STORAGE=ON
Jamie Fox6b6a19b2019-09-30 16:54:17 +010087 -DPSA_API_TEST_CRYPTO=ON
Karl Zhang1895a2c2020-03-08 18:27:32 +080088 -DPSA_API_TEST_INITIAL_ATTESTATION=ON
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020089
90respectively for the corresponding service. For example, to enable the PSA API
91tests for the Crypto service only:
92
93.. code-block:: bash
94
95 cd <TF-M base folder>
96 cd trusted-firmware-m
97 mkdir cmake_psa_test
98 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +010099 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 +0200100 cmake --build ./ -- install
101
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530102Build for PSA FF (IPC) compliance tests
103=======================================
104
105The build system assumes that the PSA FF compliance test suite is checked out
106at the same level of the TF-M root folder and the default name for the build
107folder has been used when compiling the PSA FF compliance tests.
108
109Parse the PSA FF compliance tests partition manifests using a tool script named
110as ``tfm_parse_manifest_list.py``. This tool updates the TFM partitions data
111structure with PSA test suite partitions detail and creates the manifest output
112files that are required for the PSA test suite build. Using these manifest
113output files, build the PSA FF compliance tests as per the instructions
114given in the PSA FF compliance tests README.
115
116.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000117
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530118 cd <TF-M base folder>
119 cd trusted-firmware-m
Shawn Shanadfb80f2020-03-11 10:25:21 +0800120 python tools/tfm_parse_manifest_list.py -m tools/tfm_psa_ff_test_manifest_list.yaml append
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530121
122The build system provides the support for linking with prebuilt PSA FF
123compliance NS and S test libraries when using the ``ConfigPsaApiTestIPC.cmake``
124or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config file. The PSA FF compliance
125tests need to be enabled at the build configuration step by defining::
126
127 -DPSA_API_TEST_IPC=ON.
128
129For example, to enable the PSA FF tests for ConfigPsaApiTestIPCTfmLevel2.cmake
130config :
131
132.. code-block:: bash
133
134 cd <TF-M base folder>
135 cd trusted-firmware-m
136 mkdir cmake_psa_test
137 cd cmake_psa_test
138 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTestIPCTfmLevel2.cmake` -DPSA_API_TEST_IPC=ON -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
139 cmake --build ./ -- install
140
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200141Location of build artifacts
142===========================
143The build system defines an API which allow easy usage of build
144artifacts. The ``install`` build target copies all files which might be needed
145as a dependency by external tools or build systems to the
146``<build_dir>/install/outputs``
147directory, with the following directory hierarchy:
148
149::
150
151 <build_dir>/install/outputs/fvp/
152 <build_dir>/install/outputs/<target_platform>/
153
154There is one folder for FVP testing, with more elaborate naming and
155there is an other for testing on target hardware platform (AN521, etc.), where
156naming convention is aligned with 8.3 format. The dependency tree of
157``install`` build target ensures a proper update (i.e. build) of all output
158files before the actual installation step takes place. As such it is suggested
159to use this build target to build TF-M.
160
161Export dependency files for NS applications
162-------------------------------------------
163An NS application requires a number of files to interface with TF-M.
164The build system exports these files as part of the ``install`` target and
165places them in to a single directory::
166
167 <build_dir>/install/export/tfm
168
169Further details on how to integrate a new NS app with TF-M are available in the
170:doc:`integration guide <tfm_integration_guide>`.
171
172Building the documentation
173==========================
174Please ensure the dependencies for building the firmware and the
175documentation are installed as explained in the
176:doc:`software requirements <tfm_sw_requirement>`.
177
178Building PDF output is optional and can be disabled by removing LaTex from the
179PATH.
180
181.. Note::
182 For building the documentation all tools needed to build the firmware must
183 be available.
184
185Building the Reference Manual
186-----------------------------
187.. code-block:: bash
188
189 cd <TF-M base folder>
190 mkdir cmake_doc
191 cd cmake_doc
192 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
193 cmake --build ./ -- install_doc
194
195The documentation files will be available under the directory::
196
197 cmake_doc/install/doc/reference_manual
198
199Building the User Guide
200-----------------------
201.. code-block:: bash
202
203 cd <TF-M base folder>
204 mkdir cmake_doc
205 cd cmake_doc
206 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
207 cmake --build ./ -- install_userguide
208
209The documentation files will be available under the directory::
210
211 cmake_doc/install/doc/user_guide
212
Galanakis, Minos757139a2019-11-11 15:00:11 +0000213*********************
214External dependencies
215*********************
216- `CMSIS_5` is used to import RTX for the example non-secure app
217- `Mbed Crypto` is used as crypto library on the secure side
218
219*********************
220Configuring the build
221*********************
222The build configuration for TF-M is provided to the build system using command
223line arguments:
224
225.. list-table::
226 :widths: 20 80
227
228 * - -DPROJ_CONFIG=<file>
229 - Specifies the way the application is built.
230
231 | <file> is the absolute path to configurations file
232 named as ``Config<APP_NAME>.cmake``.
233 | i.e. On Linux:
234 ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake```
235
236 * - -DTARGET_PLATFORM=<target platform name>
237 - Specifies the target platform.
238 Supported platforms:
239
240 - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
241 ``-DTARGET_PLATFORM=AN521``
242 - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
243 ``-DTARGET_PLATFORM=AN519``
Marton Berke8aae06f2019-11-25 16:46:12 +0100244 - Arm SSE-123 Example Subsystem for MPS2+ (AN539)
245 ``-DTARGET_PLATFORM=AN539``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000246 - Musca-A test chip board (Cortex-M33 SSE-200 subsystem)
247 ``-DTARGET_PLATFORM=MUSCA_A``
248 - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
249 ``-DTARGET_PLATFORM=MUSCA_B1``
Marton Berke8aae06f2019-11-25 16:46:12 +0100250 - Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem)
251 ``-DTARGET_PLATFORM=MUSCA_S1``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000252 - Cortex-M33 SSE-200 subsystem for MPS3 (AN524)
253 ``-DTARGET_PLATFORM=AN524``
Chris Brandb42fed52019-12-02 16:10:17 -0800254 - Cypress CYS0644ABZI-S2D44 board (PSoC64 platform)
255 ``-DTARGET_PLATFORM=psoc64``
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000256 See :doc:`Cypress PSoC 64 platform specifics </platform/ext/target/cypress/psoc64/cypress_psoc64_spec>`
Marton Berkee9803662019-11-11 14:11:05 +0100257 - DesignStart FPGA on Cloud: Cortex-M33 based platform (SSE-200_AWS platform)
258 ``-DTARGET_PLATFORM=SSE-200_AWS``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000259
260 * - -DCOMPILER=<compiler name>
261 - Specifies the compiler toolchain
262 The possible values are:
263
264 - ``ARMCLANG``
265 - ``GNUARM``
266 * - -DCMAKE_BUILD_TYPE=<build type>
267 - Configures debugging support.
268 The possible values are:
269
270 - ``Debug``
271 - ``Release``
272 - ``Relwithdebinfo``
273 - ``Minsizerel``
Raef Coles1bb168e2019-10-17 09:04:55 +0100274 * - -DMBEDCRYPTO_DEBUG=<ON|OFF>
Raef Colesa657a9c2019-10-24 14:36:43 +0100275 - Enables debug symbols for Mbed Crypto library. If a cryptographic
276 accelerator is enabled then this will also enable debug symbols and
277 logging for any accelerator libraries.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000278 * - -DBUILD_DWARF_VERSION=<dwarf version>
279 - Configures DWARF version.
280 The possible values are:
281
282 - 2
283 - 3
284 - 4
285
286.. Note::
287 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
288 without BL2 bootloader.
289
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000290**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800291Configurations
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000292**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800293Configurations files under `configs` are TF-M provided configurations for building.
294They are used by the `-DPROJ_CONFIG` argument for the build command line.
295The following table describes the differences between the configurations:
296
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000297+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
298| Configuration | Model [1]_ | TF-M LVL [2]_ | Regression [3]_ | Core Test [4]_ | IPC Test [5]_ | PSA API Test [6]_ | Comment |
299+========================+============+===============+=================+================+===============+===================+=========================+
300| Default | Library | 1 | No | No | No | No | TF-M, no tests |
301+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
302| Regression | Library | 1 | Yes | Yes | No | No | TF-M & Regression tests |
303+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
304| CoreIPC | IPC | 1 | No | No | No | No | TF-M, no tests |
305+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
306| CoreIPCTfmLevel2 | IPC | 2 | No | No | No | No | TF-M, no tests |
307+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
308| RegressionIPC | IPC | 1 | Yes | Yes | Yes | No | TF-M & Regression tests |
309+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
310| RegressionIPCTfmLevel2 | IPC | 2 | Yes | Yes | Yes | No | TF-M & Regression tests |
311+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
312| PsaApiTest | Library | 1 | No | No | No | Yes | TF-M & PSA API tests |
313+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
314| PsaApiTestIPC | IPC | 1 | No | No | No | Yes | TF-M & PSA API tests |
315+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
316| PsaApiTestIPCTfmLevel2 | IPC | 2 | No | No | No | Yes | TF-M & PSA API tests |
317+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
Kevin Pengd9d19202020-01-15 19:34:39 +0800318
319.. [1] Which TF-M Model is set: `CORE_IPC`. If `CORE_IPC` is set to true then the model is IPC model, otherwise it's library model.
320
321.. [2] The TF-M isolation level `TFM_LVL`. Currently Library model supports level 1. IPC model supports level 1 and 2.
322
323.. [3] Build regression tests or not: `REGRESSION`.
324
325.. [4] Build core tests or not: `CORE_TEST`.
326
327.. [5] Build IPC tests or not: `IPC_TEST`. It can be only enabled in IPC model
328
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000329.. [6] Build for PSA API compliance tests or not: `PSA_API_TEST`.
Kevin Pengd9d19202020-01-15 19:34:39 +0800330
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200331--------------
332
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000333*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*