blob: a8e890b63c42669266363bb58ad4f732b3a11ca3 [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==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100179Please ensure the dependencies for building the documentation are installed
180as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
181requirements to build the firmware, are only required when using the CMAKE
182method
183
184There are currently two ways of building the documentation:
185- Using the CMake build system as custom targets
186- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
187
188Using the CMake build-system
189----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200190
191Building PDF output is optional and can be disabled by removing LaTex from the
192PATH.
193
194.. Note::
195 For building the documentation all tools needed to build the firmware must
196 be available.
197
198Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100199^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200200.. code-block:: bash
201
202 cd <TF-M base folder>
203 mkdir cmake_doc
204 cd cmake_doc
205 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM
206 cmake --build ./ -- install_doc
207
208The documentation files will be available under the directory::
209
210 cmake_doc/install/doc/reference_manual
211
212Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100213^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200214.. code-block:: bash
215
216 cd <TF-M base folder>
217 mkdir cmake_doc
218 cd cmake_doc
219 cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG
220 cmake --build ./ -- install_userguide
221
222The documentation files will be available under the directory::
223
224 cmake_doc/install/doc/user_guide
225
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100226Manually using documentation generation tools
227---------------------------------------------
228
229Invoking Sphinx-build will build both user_guide and reference_manual
230targets.
231
232.. code-block:: bash
233
234 # Build the documentation from build_docs directory
235 cd <TF-M base folder>/ build_docs/
236 sphinx-build ./ user_guide
237
238 # Build the documentation from a custom location
239 # setting the build_docs as input
240
241 # Note that using this method will still generate the reference manual
242 # to the <TF-M base folder>/build_docs/reference_manual
243 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
244 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
245
Galanakis, Minos757139a2019-11-11 15:00:11 +0000246*********************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000247Configuring the build
248*********************
249The build configuration for TF-M is provided to the build system using command
250line arguments:
251
252.. list-table::
253 :widths: 20 80
254
255 * - -DPROJ_CONFIG=<file>
256 - Specifies the way the application is built.
257
258 | <file> is the absolute path to configurations file
259 named as ``Config<APP_NAME>.cmake``.
260 | i.e. On Linux:
261 ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake```
262
263 * - -DTARGET_PLATFORM=<target platform name>
264 - Specifies the target platform.
265 Supported platforms:
266
267 - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521)
268 ``-DTARGET_PLATFORM=AN521``
269 - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519)
270 ``-DTARGET_PLATFORM=AN519``
Marton Berke8aae06f2019-11-25 16:46:12 +0100271 - Arm SSE-123 Example Subsystem for MPS2+ (AN539)
272 ``-DTARGET_PLATFORM=AN539``
Marton Berke07fc95f2020-08-18 15:24:14 +0200273 - Corstone-300 Ecosystem FVP (Cortex-M55 SSE-300 MPS2+)
Mark Horvath9a5a9b92019-11-29 15:57:55 +0100274 ``-DTARGET_PLATFORM=FVP_SSE300_MPS2``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000275 - Musca-A test chip board (Cortex-M33 SSE-200 subsystem)
276 ``-DTARGET_PLATFORM=MUSCA_A``
277 - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem)
278 ``-DTARGET_PLATFORM=MUSCA_B1``
Marton Berke8aae06f2019-11-25 16:46:12 +0100279 - Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem)
280 ``-DTARGET_PLATFORM=MUSCA_S1``
Galanakis, Minos757139a2019-11-11 15:00:11 +0000281 - Cortex-M33 SSE-200 subsystem for MPS3 (AN524)
282 ``-DTARGET_PLATFORM=AN524``
Chris Brandb42fed52019-12-02 16:10:17 -0800283 - Cypress CYS0644ABZI-S2D44 board (PSoC64 platform)
284 ``-DTARGET_PLATFORM=psoc64``
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000285 See :doc:`Cypress PSoC 64 platform specifics </platform/ext/target/cypress/psoc64/cypress_psoc64_spec>`
Marton Berkee9803662019-11-11 14:11:05 +0100286 - DesignStart FPGA on Cloud: Cortex-M33 based platform (SSE-200_AWS platform)
287 ``-DTARGET_PLATFORM=SSE-200_AWS``
Ludovic Barre8a77bdd2020-03-26 19:53:07 +0100288 - DISCO_L562QE board (Cortex-M33 STM32L562)
289 ``-DTARGET_PLATFORM=STM_DISCO_L562QE``
290 See :doc:`STM32L5xx platform specifics </platform/ext/target/stm/stm32l5xx/readme>`
291 - NUCLEO_L552ZE_Q (Cortex-M33 STM32L552)
Michel Jaouen85700322020-07-03 11:53:41 +0200292 ``-DTARGET_PLATFORM=STM_NUCLEO_L552ZE_Q``
Ludovic Barre8a77bdd2020-03-26 19:53:07 +0100293 See :doc:`STM32L5xx platform specifics </platform/ext/target/stm/stm32l5xx/readme>`
Galanakis, Minos757139a2019-11-11 15:00:11 +0000294
295 * - -DCOMPILER=<compiler name>
296 - Specifies the compiler toolchain
297 The possible values are:
298
299 - ``ARMCLANG``
300 - ``GNUARM``
301 * - -DCMAKE_BUILD_TYPE=<build type>
302 - Configures debugging support.
303 The possible values are:
304
305 - ``Debug``
306 - ``Release``
307 - ``Relwithdebinfo``
308 - ``Minsizerel``
Raef Coles1bb168e2019-10-17 09:04:55 +0100309 * - -DMBEDCRYPTO_DEBUG=<ON|OFF>
Soby Mathew07ef6e42020-07-20 21:09:23 +0100310 - Enables debug symbols for Mbed Crypto(MbedTLS) library. If a
311 cryptographic accelerator is enabled then this will also enable
312 debug symbols and logging for any accelerator libraries.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000313 * - -DBUILD_DWARF_VERSION=<dwarf version>
314 - Configures DWARF version.
315 The possible values are:
316
317 - 2
318 - 3
319 - 4
320
321.. Note::
322 Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or
323 without BL2 bootloader.
324
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000325**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800326Configurations
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000327**************
Kevin Pengd9d19202020-01-15 19:34:39 +0800328Configurations files under `configs` are TF-M provided configurations for building.
329They are used by the `-DPROJ_CONFIG` argument for the build command line.
330The following table describes the differences between the configurations:
331
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000332+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
333| Configuration | Model [1]_ | TF-M LVL [2]_ | Regression [3]_ | Core Test [4]_ | IPC Test [5]_ | PSA API Test [6]_ | Comment |
334+========================+============+===============+=================+================+===============+===================+=========================+
335| Default | Library | 1 | No | No | No | No | TF-M, no tests |
336+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
337| Regression | Library | 1 | Yes | Yes | No | No | TF-M & Regression tests |
338+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
339| CoreIPC | IPC | 1 | No | No | No | No | TF-M, no tests |
340+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
341| CoreIPCTfmLevel2 | IPC | 2 | No | No | No | No | TF-M, no tests |
342+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
343| RegressionIPC | IPC | 1 | Yes | Yes | Yes | No | TF-M & Regression tests |
344+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
345| RegressionIPCTfmLevel2 | IPC | 2 | Yes | Yes | Yes | No | TF-M & Regression tests |
346+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
347| PsaApiTest | Library | 1 | No | No | No | Yes | TF-M & PSA API tests |
348+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
349| PsaApiTestIPC | IPC | 1 | No | No | No | Yes | TF-M & PSA API tests |
350+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
351| PsaApiTestIPCTfmLevel2 | IPC | 2 | No | No | No | Yes | TF-M & PSA API tests |
352+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
David Huc51e7c52020-06-01 10:45:52 +0800353| DefaultProfileS | Library | 1 | No | No | No | No | TF-M Profile Small, |
David Hu2cbf5df2020-06-15 10:41:44 +0800354| | | | | | | | no tests [7]_ |
David Huc51e7c52020-06-01 10:45:52 +0800355+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
356| RegressionProfileS | Library | 1 | Yes | Yes | No | No | TF-M Profile Small & |
David Hu2cbf5df2020-06-15 10:41:44 +0800357| | | | | | | | Regression tests [7]_ |
David Huc51e7c52020-06-01 10:45:52 +0800358+------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+
Kevin Pengd9d19202020-01-15 19:34:39 +0800359
360.. [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.
361
362.. [2] The TF-M isolation level `TFM_LVL`. Currently Library model supports level 1. IPC model supports level 1 and 2.
363
364.. [3] Build regression tests or not: `REGRESSION`.
365
366.. [4] Build core tests or not: `CORE_TEST`.
367
368.. [5] Build IPC tests or not: `IPC_TEST`. It can be only enabled in IPC model
369
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000370.. [6] Build for PSA API compliance tests or not: `PSA_API_TEST`.
Kevin Pengd9d19202020-01-15 19:34:39 +0800371
David Hu2cbf5df2020-06-15 10:41:44 +0800372.. [7] Profile Small config doesn't cover all the platforms. Please check
373 Profile Small config files to find out the supported platforms.
374
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100375.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
376.. _Doxygen: https://www.doxygen.nl
377
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200378--------------
379
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000380*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*