blob: 29982c0d68240ce49ded84107406ef6a626a2ee1 [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 Galanakise4094012020-06-12 14:25:34 +01008:ref:`docs/getting_started/tfm_sw_requirement:External dependencies` section.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02009
Galanakis, Minos757139a2019-11-11 15:00:11 +000010The configuration-table
Minos Galanakise4094012020-06-12 14:25:34 +010011:ref:`docs/getting_started/tfm_build_instruction:Configuring the build` section
Galanakis, Minos757139a2019-11-11 15:00:11 +000012explains 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
Leonardo Sandovald7f72d52020-07-28 18:02:34 -050029 cd <base folder>
Minos Galanakis0f39fa52020-06-08 16:53:53 +010030 git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
Soby Mathew07ef6e42020-07-20 21:09:23 +010031 git clone https://github.com/ARMmbed/mbedtls.git -b mbedtls-2.23.0
Kevin Peng6710c822020-05-21 16:52:14 +080032 git clone https://git.trustedfirmware.org/TF-M/tf-m-tests.git
David Vincze91e7ac82020-06-25 15:30:32 +020033 git clone https://github.com/JuulLabs-OSS/mcuboot.git -b v1.6.0
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020034
Minos Galanakisac6b06c2020-03-19 12:57:02 +000035.. Note::
36 For building with Armclang compiler version 6.10.0, please follow the note
Minos Galanakise4094012020-06-12 14:25:34 +010037 in :ref:`docs/getting_started/tfm_sw_requirement:External dependencies` section.
Minos Galanakisac6b06c2020-03-19 12:57:02 +000038
TTornblomb9e5ed02020-02-13 16:53:15 +010039.. Note::
40 For building with the IAR toolchain, please see the notes in
41 :doc:`software requirements <tfm_build_instruction_iar>`
42
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020043Build steps for the AN521 target platform:
44==========================================
45.. code-block:: bash
46
Leonardo Sandovald7f72d52020-07-28 18:02:34 -050047 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020048 cd trusted-firmware-m
49 mkdir cmake_build
50 cd cmake_build
51 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
52 cmake --build ./ -- install
53
54Regression Tests for the AN521 target platform
55==============================================
56*TF-M build regression tests on Linux*
57
58.. code-block:: bash
59
Leonardo Sandovald7f72d52020-07-28 18:02:34 -050060 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020061 cd trusted-firmware-m
62 mkdir cmake_test
63 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +080064 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020065 cmake --build ./ -- install
66
67*TF-M build regression tests on Windows*
68
69.. code-block:: bash
70
Leonardo Sandovald7f72d52020-07-28 18:02:34 -050071 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020072 cd trusted-firmware-m
73 mkdir cmake_test
74 cd cmake_test
Ken Liue40f9a22019-06-03 16:42:47 +080075 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020076 cmake --build ./ -- install
77
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +053078Build for PSA Developer API compliance tests
79============================================
80The build system provides the support for linking with prebuilt PSA Developer
81API compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``,
Jamie Fox6b6a19b2019-09-30 16:54:17 +010082``ConfigPsaApiTestIPC.cmake`` or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config
83file. The build system assumes that the PSA API compliance test suite is checked
84out at the same level of the TF-M root folder and the default name for the build
85folder has been used when compiling the PSA API compliance tests. Each set of
Kevin Pengc6d74502020-03-04 16:55:37 +080086tests for the Internal Trusted Storage, Protected Storage, Crypto and Attestation
Jamie Fox6b6a19b2019-09-30 16:54:17 +010087services needs to be enabled at the build configuration step by defining::
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020088
Jamie Fox6b6a19b2019-09-30 16:54:17 +010089 -DPSA_API_TEST_INTERNAL_TRUSTED_STORAGE=ON
Karl Zhang1895a2c2020-03-08 18:27:32 +080090 -DPSA_API_TEST_PROTECTED_STORAGE=ON
Vinay Kumar Kotegowder75641062020-04-24 16:44:12 +053091 -DPSA_API_TEST_STORAGE=ON
Jamie Fox6b6a19b2019-09-30 16:54:17 +010092 -DPSA_API_TEST_CRYPTO=ON
Karl Zhang1895a2c2020-03-08 18:27:32 +080093 -DPSA_API_TEST_INITIAL_ATTESTATION=ON
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020094
95respectively for the corresponding service. For example, to enable the PSA API
96tests for the Crypto service only:
97
98.. code-block:: bash
99
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500100 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200101 cd trusted-firmware-m
102 mkdir cmake_psa_test
103 cd cmake_psa_test
Antonio de Angelis0169b9f2019-06-28 11:37:24 +0100104 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 +0200105 cmake --build ./ -- install
106
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530107Build for PSA FF (IPC) compliance tests
108=======================================
109
110The build system assumes that the PSA FF compliance test suite is checked out
111at the same level of the TF-M root folder and the default name for the build
112folder has been used when compiling the PSA FF compliance tests.
113
114Parse the PSA FF compliance tests partition manifests using a tool script named
115as ``tfm_parse_manifest_list.py``. This tool updates the TFM partitions data
116structure with PSA test suite partitions detail and creates the manifest output
117files that are required for the PSA test suite build. Using these manifest
118output files, build the PSA FF compliance tests as per the instructions
119given in the PSA FF compliance tests README.
120
121.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000122
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500123 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530124 cd trusted-firmware-m
Shawn Shanadfb80f2020-03-11 10:25:21 +0800125 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 +0530126
127The build system provides the support for linking with prebuilt PSA FF
128compliance NS and S test libraries when using the ``ConfigPsaApiTestIPC.cmake``
129or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config file. The PSA FF compliance
130tests need to be enabled at the build configuration step by defining::
131
132 -DPSA_API_TEST_IPC=ON.
133
134For example, to enable the PSA FF tests for ConfigPsaApiTestIPCTfmLevel2.cmake
135config :
136
137.. code-block:: bash
138
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500139 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530140 cd trusted-firmware-m
141 mkdir cmake_psa_test
142 cd cmake_psa_test
143 cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTestIPCTfmLevel2.cmake` -DPSA_API_TEST_IPC=ON -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../
144 cmake --build ./ -- install
145
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200146Location of build artifacts
147===========================
148The build system defines an API which allow easy usage of build
149artifacts. The ``install`` build target copies all files which might be needed
150as a dependency by external tools or build systems to the
151``<build_dir>/install/outputs``
152directory, with the following directory hierarchy:
153
154::
155
156 <build_dir>/install/outputs/fvp/
157 <build_dir>/install/outputs/<target_platform>/
158
159There is one folder for FVP testing, with more elaborate naming and
160there is an other for testing on target hardware platform (AN521, etc.), where
161naming convention is aligned with 8.3 format. The dependency tree of
162``install`` build target ensures a proper update (i.e. build) of all output
163files before the actual installation step takes place. As such it is suggested
164to use this build target to build TF-M.
165
166Export dependency files for NS applications
167-------------------------------------------
168An NS application requires a number of files to interface with TF-M.
169The build system exports these files as part of the ``install`` target and
170places them in to a single directory::
171
172 <build_dir>/install/export/tfm
173
174Further details on how to integrate a new NS app with TF-M are available in the
175:doc:`integration guide <tfm_integration_guide>`.
176
177Building the documentation
178==========================
179Please ensure the dependencies for building the firmware and the
180documentation are installed as explained in the
181:doc:`software requirements <tfm_sw_requirement>`.
182
183Building PDF output is optional and can be disabled by removing LaTex from the
184PATH.
185
186.. Note::
187 For building the documentation all tools needed to build the firmware must
188 be available.
189
190Building the Reference Manual
191-----------------------------
192.. code-block:: bash
193
194 cd <TF-M base folder>
195 mkdir cmake_doc
196 cd cmake_doc
197 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
198 cmake --build ./ -- install_doc
199
200The documentation files will be available under the directory::
201
202 cmake_doc/install/doc/reference_manual
203
204Building the User Guide
205-----------------------
206.. code-block:: bash
207
208 cd <TF-M base folder>
209 mkdir cmake_doc
210 cd cmake_doc
211 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
212 cmake --build ./ -- install_userguide
213
214The documentation files will be available under the directory::
215
216 cmake_doc/install/doc/user_guide
217
Galanakis, Minos757139a2019-11-11 15:00:11 +0000218*********************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000219Configuring the build
220*********************
221The build configuration for TF-M is provided to the build system using command
222line arguments:
223
224.. list-table::
225 :widths: 20 80
226
227 * - -DPROJ_CONFIG=<file>
228 - Specifies the way the application is built.
229
230 | <file> is the absolute path to configurations file
231 named as ``Config<APP_NAME>.cmake``.
232 | i.e. On Linux:
233 ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake```
234
235 * - -DTARGET_PLATFORM=<target platform name>
236 - Specifies the target platform.
237 Supported platforms:
238
239 - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
240 ``-DTARGET_PLATFORM=AN521``
241 - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
242 ``-DTARGET_PLATFORM=AN519``
Marton Berke8aae06f2019-11-25 16:46:12 +0100243 - Arm SSE-123 Example Subsystem for MPS2+ (AN539)
244 ``-DTARGET_PLATFORM=AN539``
Marton Berke07fc95f2020-08-18 15:24:14 +0200245 - Corstone-300 Ecosystem FVP (Cortex-M55 SSE-300 MPS2+)
Mark Horvath9a5a9b92019-11-29 15:57:55 +0100246 ``-DTARGET_PLATFORM=FVP_SSE300_MPS2``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000247 - Musca-A test chip board (Cortex-M33 SSE-200 subsystem)
248 ``-DTARGET_PLATFORM=MUSCA_A``
249 - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
250 ``-DTARGET_PLATFORM=MUSCA_B1``
Marton Berke8aae06f2019-11-25 16:46:12 +0100251 - Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem)
252 ``-DTARGET_PLATFORM=MUSCA_S1``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000253 - Cortex-M33 SSE-200 subsystem for MPS3 (AN524)
254 ``-DTARGET_PLATFORM=AN524``
Chris Brandb42fed52019-12-02 16:10:17 -0800255 - Cypress CYS0644ABZI-S2D44 board (PSoC64 platform)
256 ``-DTARGET_PLATFORM=psoc64``
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000257 See :doc:`Cypress PSoC 64 platform specifics </platform/ext/target/cypress/psoc64/cypress_psoc64_spec>`
Marton Berkee9803662019-11-11 14:11:05 +0100258 - DesignStart FPGA on Cloud: Cortex-M33 based platform (SSE-200_AWS platform)
259 ``-DTARGET_PLATFORM=SSE-200_AWS``
Ludovic Barre8a77bdd2020-03-26 19:53:07 +0100260 - DISCO_L562QE board (Cortex-M33 STM32L562)
261 ``-DTARGET_PLATFORM=STM_DISCO_L562QE``
262 See :doc:`STM32L5xx platform specifics </platform/ext/target/stm/stm32l5xx/readme>`
263 - NUCLEO_L552ZE_Q (Cortex-M33 STM32L552)
Michel Jaouen85700322020-07-03 11:53:41 +0200264 ``-DTARGET_PLATFORM=STM_NUCLEO_L552ZE_Q``
Ludovic Barre8a77bdd2020-03-26 19:53:07 +0100265 See :doc:`STM32L5xx platform specifics </platform/ext/target/stm/stm32l5xx/readme>`
Galanakis, Minos757139a2019-11-11 15:00:11 +0000266
267 * - -DCOMPILER=<compiler name>
268 - Specifies the compiler toolchain
269 The possible values are:
270
271 - ``ARMCLANG``
272 - ``GNUARM``
273 * - -DCMAKE_BUILD_TYPE=<build type>
274 - Configures debugging support.
275 The possible values are:
276
277 - ``Debug``
278 - ``Release``
279 - ``Relwithdebinfo``
280 - ``Minsizerel``
Raef Coles1bb168e2019-10-17 09:04:55 +0100281 * - -DMBEDCRYPTO_DEBUG=<ON|OFF>
Soby Mathew07ef6e42020-07-20 21:09:23 +0100282 - Enables debug symbols for Mbed Crypto(MbedTLS) library. If a
283 cryptographic accelerator is enabled then this will also enable
284 debug symbols and logging for any accelerator libraries.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000285 * - -DBUILD_DWARF_VERSION=<dwarf version>
286 - Configures DWARF version.
287 The possible values are:
288
289 - 2
290 - 3
291 - 4
292
293.. Note::
294 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
295 without BL2 bootloader.
296
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000297**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800298Configurations
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000299**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800300Configurations files under `configs` are TF-M provided configurations for building.
301They are used by the `-DPROJ_CONFIG` argument for the build command line.
302The following table describes the differences between the configurations:
303
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000304+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
305| Configuration | Model [1]_ | TF-M LVL [2]_ | Regression [3]_ | Core Test [4]_ | IPC Test [5]_ | PSA API Test [6]_ | Comment |
306+========================+============+===============+=================+================+===============+===================+=========================+
307| Default | Library | 1 | No | No | No | No | TF-M, no tests |
308+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
309| Regression | Library | 1 | Yes | Yes | No | No | TF-M & Regression tests |
310+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
311| CoreIPC | IPC | 1 | No | No | No | No | TF-M, no tests |
312+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
313| CoreIPCTfmLevel2 | IPC | 2 | No | No | No | No | TF-M, no tests |
314+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
315| RegressionIPC | IPC | 1 | Yes | Yes | Yes | No | TF-M & Regression tests |
316+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
317| RegressionIPCTfmLevel2 | IPC | 2 | Yes | Yes | Yes | No | TF-M & Regression tests |
318+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
319| PsaApiTest | Library | 1 | No | No | No | Yes | TF-M & PSA API tests |
320+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
321| PsaApiTestIPC | IPC | 1 | No | No | No | Yes | TF-M & PSA API tests |
322+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
323| PsaApiTestIPCTfmLevel2 | IPC | 2 | No | No | No | Yes | TF-M & PSA API tests |
324+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
David Huc51e7c52020-06-01 10:45:52 +0800325| DefaultProfileS | Library | 1 | No | No | No | No | TF-M Profile Small, |
David Hu2cbf5df2020-06-15 10:41:44 +0800326| | | | | | | | no tests [7]_ |
David Huc51e7c52020-06-01 10:45:52 +0800327+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
328| RegressionProfileS | Library | 1 | Yes | Yes | No | No | TF-M Profile Small & |
David Hu2cbf5df2020-06-15 10:41:44 +0800329| | | | | | | | Regression tests [7]_ |
David Huc51e7c52020-06-01 10:45:52 +0800330+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
Kevin Pengd9d19202020-01-15 19:34:39 +0800331
332.. [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.
333
334.. [2] The TF-M isolation level `TFM_LVL`. Currently Library model supports level 1. IPC model supports level 1 and 2.
335
336.. [3] Build regression tests or not: `REGRESSION`.
337
338.. [4] Build core tests or not: `CORE_TEST`.
339
340.. [5] Build IPC tests or not: `IPC_TEST`. It can be only enabled in IPC model
341
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000342.. [6] Build for PSA API compliance tests or not: `PSA_API_TEST`.
Kevin Pengd9d19202020-01-15 19:34:39 +0800343
David Hu2cbf5df2020-06-15 10:41:44 +0800344.. [7] Profile Small config doesn't cover all the platforms. Please check
345 Profile Small config files to find out the supported platforms.
346
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200347--------------
348
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000349*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*