blob: f310baeeb4285a19a8a71d68dbd53d5be030de1f [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
Minos Galanakisac6b06c2020-03-19 12:57:02 +00008:ref:`docs/user_guides/tfm_sw_requirement: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
Minos Galanakisd09df4d2020-03-23 10:25:20 +000034 # If CMSIS was cloned before the git-lfs dependency was installed,
35 # use the following command to download the binaries.
36 cd CMSIS_5 && git lfs pull
37
Antonio de Angelis70ae80f2019-02-26 14:57:40 +000038.. Note::
39 `CMSIS_5` now uses `git-lfs` for storing large size binaries so the cloning
40 process has changed from previous releases. Please refer to the `CMSIS_5`
41 documentation for more details.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020042
Minos Galanakisac6b06c2020-03-19 12:57:02 +000043.. Note::
44 For building with Armclang compiler version 6.10.0, please follow the note
45 in :ref:`docs/user_guides/tfm_sw_requirement:External dependencies` section.
46
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020047Build steps for the AN521 target platform:
48==========================================
49.. code-block:: bash
50
51 cd <TF-M base folder>
52 cd trusted-firmware-m
53 mkdir cmake_build
54 cd cmake_build
55 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
56 cmake --build ./ -- install
57
58Regression Tests for the AN521 target platform
59==============================================
60*TF-M build regression tests on Linux*
61
62.. code-block:: bash
63
64 cd <TF-M base folder>
65 cd trusted-firmware-m
66 mkdir cmake_test
67 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +080068 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020069 cmake --build ./ -- install
70
71*TF-M build regression tests on Windows*
72
73.. code-block:: bash
74
75 cd <TF-M base folder>
76 cd trusted-firmware-m
77 mkdir cmake_test
78 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +080079 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020080 cmake --build ./ -- install
81
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +053082Build for PSA Developer API compliance tests
83============================================
84The build system provides the support for linking with prebuilt PSA Developer
85API compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``,
Jamie Fox6b6a19b2019-09-30 16:54:17 +010086``ConfigPsaApiTestIPC.cmake`` or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config
87file. The build system assumes that the PSA API compliance test suite is checked
88out at the same level of the TF-M root folder and the default name for the build
89folder has been used when compiling the PSA API compliance tests. Each set of
90tests for the Internal Trusted Storage, Secure Storage, Crypto and Attestation
91services needs to be enabled at the build configuration step by defining::
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020092
Jamie Fox6b6a19b2019-09-30 16:54:17 +010093 -DPSA_API_TEST_INTERNAL_TRUSTED_STORAGE=ON
Karl Zhang1895a2c2020-03-08 18:27:32 +080094 -DPSA_API_TEST_PROTECTED_STORAGE=ON
Jamie Fox6b6a19b2019-09-30 16:54:17 +010095 -DPSA_API_TEST_CRYPTO=ON
Karl Zhang1895a2c2020-03-08 18:27:32 +080096 -DPSA_API_TEST_INITIAL_ATTESTATION=ON
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020097
98respectively for the corresponding service. For example, to enable the PSA API
99tests for the Crypto service only:
100
101.. code-block:: bash
102
103 cd <TF-M base folder>
104 cd trusted-firmware-m
105 mkdir cmake_psa_test
106 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +0100107 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 +0200108 cmake --build ./ -- install
109
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530110Build for PSA FF (IPC) compliance tests
111=======================================
112
113The build system assumes that the PSA FF compliance test suite is checked out
114at the same level of the TF-M root folder and the default name for the build
115folder has been used when compiling the PSA FF compliance tests.
116
117Parse the PSA FF compliance tests partition manifests using a tool script named
118as ``tfm_parse_manifest_list.py``. This tool updates the TFM partitions data
119structure with PSA test suite partitions detail and creates the manifest output
120files that are required for the PSA test suite build. Using these manifest
121output files, build the PSA FF compliance tests as per the instructions
122given in the PSA FF compliance tests README.
123
124.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000125
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530126 cd <TF-M base folder>
127 cd trusted-firmware-m
Shawn Shanadfb80f2020-03-11 10:25:21 +0800128 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 +0530129
130The build system provides the support for linking with prebuilt PSA FF
131compliance NS and S test libraries when using the ``ConfigPsaApiTestIPC.cmake``
132or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config file. The PSA FF compliance
133tests need to be enabled at the build configuration step by defining::
134
135 -DPSA_API_TEST_IPC=ON.
136
137For example, to enable the PSA FF tests for ConfigPsaApiTestIPCTfmLevel2.cmake
138config :
139
140.. code-block:: bash
141
142 cd <TF-M base folder>
143 cd trusted-firmware-m
144 mkdir cmake_psa_test
145 cd cmake_psa_test
146 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTestIPCTfmLevel2.cmake` -DPSA_API_TEST_IPC=ON -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
147 cmake --build ./ -- install
148
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200149Location of build artifacts
150===========================
151The build system defines an API which allow easy usage of build
152artifacts. The ``install`` build target copies all files which might be needed
153as a dependency by external tools or build systems to the
154``<build_dir>/install/outputs``
155directory, with the following directory hierarchy:
156
157::
158
159 <build_dir>/install/outputs/fvp/
160 <build_dir>/install/outputs/<target_platform>/
161
162There is one folder for FVP testing, with more elaborate naming and
163there is an other for testing on target hardware platform (AN521, etc.), where
164naming convention is aligned with 8.3 format. The dependency tree of
165``install`` build target ensures a proper update (i.e. build) of all output
166files before the actual installation step takes place. As such it is suggested
167to use this build target to build TF-M.
168
169Export dependency files for NS applications
170-------------------------------------------
171An NS application requires a number of files to interface with TF-M.
172The build system exports these files as part of the ``install`` target and
173places them in to a single directory::
174
175 <build_dir>/install/export/tfm
176
177Further details on how to integrate a new NS app with TF-M are available in the
178:doc:`integration guide <tfm_integration_guide>`.
179
180Building the documentation
181==========================
182Please ensure the dependencies for building the firmware and the
183documentation are installed as explained in the
184:doc:`software requirements <tfm_sw_requirement>`.
185
186Building PDF output is optional and can be disabled by removing LaTex from the
187PATH.
188
189.. Note::
190 For building the documentation all tools needed to build the firmware must
191 be available.
192
193Building the Reference Manual
194-----------------------------
195.. code-block:: bash
196
197 cd <TF-M base folder>
198 mkdir cmake_doc
199 cd cmake_doc
200 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
201 cmake --build ./ -- install_doc
202
203The documentation files will be available under the directory::
204
205 cmake_doc/install/doc/reference_manual
206
207Building the User Guide
208-----------------------
209.. code-block:: bash
210
211 cd <TF-M base folder>
212 mkdir cmake_doc
213 cd cmake_doc
214 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
215 cmake --build ./ -- install_userguide
216
217The documentation files will be available under the directory::
218
219 cmake_doc/install/doc/user_guide
220
Galanakis, Minos757139a2019-11-11 15:00:11 +0000221*********************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000222Configuring the build
223*********************
224The build configuration for TF-M is provided to the build system using command
225line arguments:
226
227.. list-table::
228 :widths: 20 80
229
230 * - -DPROJ_CONFIG=<file>
231 - Specifies the way the application is built.
232
233 | <file> is the absolute path to configurations file
234 named as ``Config<APP_NAME>.cmake``.
235 | i.e. On Linux:
236 ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake```
237
238 * - -DTARGET_PLATFORM=<target platform name>
239 - Specifies the target platform.
240 Supported platforms:
241
242 - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
243 ``-DTARGET_PLATFORM=AN521``
244 - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
245 ``-DTARGET_PLATFORM=AN519``
Marton Berke8aae06f2019-11-25 16:46:12 +0100246 - Arm SSE-123 Example Subsystem for MPS2+ (AN539)
247 ``-DTARGET_PLATFORM=AN539``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000248 - Musca-A test chip board (Cortex-M33 SSE-200 subsystem)
249 ``-DTARGET_PLATFORM=MUSCA_A``
250 - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
251 ``-DTARGET_PLATFORM=MUSCA_B1``
Marton Berke8aae06f2019-11-25 16:46:12 +0100252 - Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem)
253 ``-DTARGET_PLATFORM=MUSCA_S1``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000254 - Cortex-M33 SSE-200 subsystem for MPS3 (AN524)
255 ``-DTARGET_PLATFORM=AN524``
Chris Brandb42fed52019-12-02 16:10:17 -0800256 - Cypress CYS0644ABZI-S2D44 board (PSoC64 platform)
257 ``-DTARGET_PLATFORM=psoc64``
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000258 See :doc:`Cypress PSoC 64 platform specifics </platform/ext/target/cypress/psoc64/cypress_psoc64_spec>`
Marton Berkee9803662019-11-11 14:11:05 +0100259 - DesignStart FPGA on Cloud: Cortex-M33 based platform (SSE-200_AWS platform)
260 ``-DTARGET_PLATFORM=SSE-200_AWS``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000261
262 * - -DCOMPILER=<compiler name>
263 - Specifies the compiler toolchain
264 The possible values are:
265
266 - ``ARMCLANG``
267 - ``GNUARM``
268 * - -DCMAKE_BUILD_TYPE=<build type>
269 - Configures debugging support.
270 The possible values are:
271
272 - ``Debug``
273 - ``Release``
274 - ``Relwithdebinfo``
275 - ``Minsizerel``
Raef Coles1bb168e2019-10-17 09:04:55 +0100276 * - -DMBEDCRYPTO_DEBUG=<ON|OFF>
Raef Colesa657a9c2019-10-24 14:36:43 +0100277 - Enables debug symbols for Mbed Crypto library. If a cryptographic
278 accelerator is enabled then this will also enable debug symbols and
279 logging for any accelerator libraries.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000280 * - -DBUILD_DWARF_VERSION=<dwarf version>
281 - Configures DWARF version.
282 The possible values are:
283
284 - 2
285 - 3
286 - 4
287
288.. Note::
289 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
290 without BL2 bootloader.
291
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000292**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800293Configurations
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000294**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800295Configurations files under `configs` are TF-M provided configurations for building.
296They are used by the `-DPROJ_CONFIG` argument for the build command line.
297The following table describes the differences between the configurations:
298
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000299+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
300| Configuration | Model [1]_ | TF-M LVL [2]_ | Regression [3]_ | Core Test [4]_ | IPC Test [5]_ | PSA API Test [6]_ | Comment |
301+========================+============+===============+=================+================+===============+===================+=========================+
302| Default | Library | 1 | No | No | No | No | TF-M, no tests |
303+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
304| Regression | Library | 1 | Yes | Yes | No | No | TF-M & Regression tests |
305+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
306| CoreIPC | IPC | 1 | No | No | No | No | TF-M, no tests |
307+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
308| CoreIPCTfmLevel2 | IPC | 2 | No | No | No | No | TF-M, no tests |
309+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
310| RegressionIPC | IPC | 1 | Yes | Yes | Yes | No | TF-M & Regression tests |
311+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
312| RegressionIPCTfmLevel2 | IPC | 2 | Yes | Yes | Yes | No | TF-M & Regression tests |
313+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
314| PsaApiTest | Library | 1 | No | No | No | Yes | TF-M & PSA API tests |
315+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
316| PsaApiTestIPC | IPC | 1 | No | No | No | Yes | TF-M & PSA API tests |
317+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
318| PsaApiTestIPCTfmLevel2 | IPC | 2 | No | No | No | Yes | TF-M & PSA API tests |
319+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
Kevin Pengd9d19202020-01-15 19:34:39 +0800320
321.. [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.
322
323.. [2] The TF-M isolation level `TFM_LVL`. Currently Library model supports level 1. IPC model supports level 1 and 2.
324
325.. [3] Build regression tests or not: `REGRESSION`.
326
327.. [4] Build core tests or not: `CORE_TEST`.
328
329.. [5] Build IPC tests or not: `IPC_TEST`. It can be only enabled in IPC model
330
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000331.. [6] Build for PSA API compliance tests or not: `PSA_API_TEST`.
Kevin Pengd9d19202020-01-15 19:34:39 +0800332
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200333--------------
334
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000335*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*