blob: f64528a89927050d25684a9f3b109066584e2841 [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
Gyorgy Szingdb9783c2019-04-17 21:08:48 +02007****************
8TF-M build steps
9****************
10TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source
11build environment. The instructions are below.
12
Raef Coles69817322020-10-19 14:14:14 +010013Cmake version ``3.15.0`` or higher is required.
Raef Coles1ecb8132020-10-02 15:11:24 +010014
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020015Getting the source-code
16=======================
17.. code-block:: bash
18
Leonardo Sandovald7f72d52020-07-28 18:02:34 -050019 cd <base folder>
Minos Galanakis0f39fa52020-06-08 16:53:53 +010020 git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
Anton Komlevb8e3af02020-08-28 10:23:57 +010021
Leonardo Sandoval98350142021-02-03 16:32:14 -060022To simplify documentation commands, the new created repository under
23``trusted-firmware-m`` would be referenced as ``<TF-M base folder>`` and
24its parent, the ``<base folder>``. Dependency management is now handled by
25cmake. If you wish to alter this behaviour, see
26:ref:`docs/getting_started/tfm_build_instruction:Manual
Anton Komlevb8e3af02020-08-28 10:23:57 +010027dependency management`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020028
Minos Galanakisac6b06c2020-03-19 12:57:02 +000029.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +010030
Minos Galanakis3b740a12020-10-15 11:10:26 +010031 - For building with Armclang compiler version 6.10.0+, please follow the note
32 in :doc:`software requirements <tfm_sw_requirement>`.
Anton Komlevb8e3af02020-08-28 10:23:57 +010033 - For building with the IAR toolchain, please see the notes in
Minos Galanakis3b740a12020-10-15 11:10:26 +010034 :doc:`IAR software requirements <tfm_build_instruction_iar>`
TTornblomb9e5ed02020-02-13 16:53:15 +010035
Anton Komlevb8e3af02020-08-28 10:23:57 +010036.. _tfm_cmake_configuration:
37
38Cmake configuration
39===================
40
41All configuration options are provided by cmake variables, and their default
42values, with docstrings, can be found in ``config/config_default.cmake``.
43
Tamas Ban69219202020-10-27 08:13:18 +000044Configuration is provided in multiple stages. Each stage will not override any
45config that has already been set at any of the prior stages.
Anton Komlevb8e3af02020-08-28 10:23:57 +010046
Tamas Ban69219202020-10-27 08:13:18 +000047 1. Command-line variable settings are applied.
48 2. If the ``TFM_EXTRA_CONFIG_PATH`` variable has been set, that file is
Soby Mathew7b7e1242020-10-07 13:31:56 +010049 loaded.
Tamas Ban69219202020-10-27 08:13:18 +000050 3. If TEST_PSA_TEST is set, then PSA API test related config is applied from
51 ``config/tests/config_test_psa_api.cmake``.
52 4. If it exists, CMAKE_BUILD_TYPE specific config is applied from
53 ``config/build_type/<build_type>.cmake``.
54 5. Target specific config from ``platform/ext/target/<target_platform>/config.cmake``
55 is applied.
56 6. If CRYPTO_HW_ACCELERATOR is set, then a config specific to the
57 accelerator type is applied if it exists.
58 7. If it exists, TFM Profile specific config is applied from
59 ``config/profile/<tfm_profile>.cmake``.
60 8. ``config/config_default.cmake`` is loaded.
Anton Komlevb8e3af02020-08-28 10:23:57 +010061
62.. Warning::
63 This means that command-line settings are not applied when they conflict
64 with required platform settings. If it is required to override platform
65 settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be
66 used.
67
68Required cmake parameters for building TF-M
69-------------------------------------------
70
71+----------------------+-------------------------------------------------------+
72| Parameter | Description |
73+======================+=======================================================+
74| TFM_PLATFORM | The target platform as a path from the base directory |
Øyvind Rønningstada9d5eac2021-01-22 14:21:25 +010075| | ``/platform/ext/target``, or as an absolute path. |
Anton Komlevb8e3af02020-08-28 10:23:57 +010076+----------------------+-------------------------------------------------------+
Anton Komlevb8e3af02020-08-28 10:23:57 +010077
78By default release configuration builds. Alternate build types can be controlled
79by the CMAKE_BUILD_TYPE variable.
80
81Build type
82----------
83
84Build type is controlled by the ``CMAKE_BUILD_TYPE`` variable. The possible
85types are:
86
87 - ``Debug``
88 - ``Relwithdebinfo``
89 - ``Release``
90 - ``Minsizerel``
91
92``Release`` is default.
93
94Both ``Debug`` and ``Relwithdebinfo`` will include debug symbols in the output
95files. ``Relwithdebinfo``, ``Release`` and ``Minsizerel`` have optimization
Raef Coles1ecb8132020-10-02 15:11:24 +010096turned on and hence will produce smaller, faster code. ``Minsizerel`` will
Anton Komlevb8e3af02020-08-28 10:23:57 +010097produce the smallest code, and hence is often a good idea on RAM or flash
98constrained systems.
99
100Other cmake parameters
101----------------------
102
103The full list of default options is in ``config/config_default.cmake``. Several
104important options are listed below.
105
106
107+---------------------+----------------------------------------+---------------+
108| Parameter | Description | Default value |
109+=====================+========================================+===============+
110| BL2 | Build level 2 secure bootloader. | ON |
111+---------------------+----------------------------------------+---------------+
112| NS | Build NS app. Required for test code. | ON |
113+---------------------+----------------------------------------+---------------+
114| TFM_PSA_API | Use PSA api (IPC mode) instead of | OFF |
115| | secure library mode. | |
116+---------------------+----------------------------------------+---------------+
117| TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 |
118+---------------------+----------------------------------------+---------------+
119| TFM_PROFILE | Set TFM profile. | |
120+---------------------+----------------------------------------+---------------+
121| TEST_S | Build secure regression tests. | OFF |
122+---------------------+----------------------------------------+---------------+
123| TEST_NS | Build non-secure regression tests. | OFF |
124+---------------------+----------------------------------------+---------------+
125| TEST_PSA_API | Build PSA API TESTS for the given | |
126| | suite. Takes a PSA api ``SUITE`` as an | |
127| | argument (``CRYPTO`` etc). | |
128+---------------------+----------------------------------------+---------------+
129
130Regression test configuration
131-----------------------------
132
133Regression test configuration is controlled entirely by the ``TEST_S`` and
134``TEST_NS`` cmake variables.
135
136If regression testing is enabled, it will then enable all tests for the enabled
137secure partitions. If IPC mode is enabled via ``TFM_PSA_API`` the IPC tests will
138be enabled. QCBOR and T_COSE tests are linked to the Initial Attestation
139partition, as they are only used there. Multicore tests will be enabled if
140``TFM_MULTI_CORE_TOPOLOGY`` is enabled.
141
142Some cryptographic tests can be enabled and disabled. This is done to prevent
143false failures from being reported when a smaller Mbed Crypto config is being
144used which does not support all features.
145
146+-----------------------------+-------------------------------------+---------------+
147| Parameter | Description | Default value |
148+=============================+=====================================+===============+
149| TFM_CRYPTO_TEST_ALG_CBC | Test CBC cryptography mode | ON |
150+-----------------------------+-------------------------------------+---------------+
151| TFM_CRYPTO_TEST_ALG_CCM | Test CCM cryptography mode | ON |
152+-----------------------------+-------------------------------------+---------------+
153| TFM_CRYPTO_TEST_ALG_CFB | Test CFB cryptography mode | ON |
154+-----------------------------+-------------------------------------+---------------+
155| TFM_CRYPTO_TEST_ALG_CTR | Test CTR cryptography mode | ON |
156+-----------------------------+-------------------------------------+---------------+
157| TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON |
158+-----------------------------+-------------------------------------+---------------+
159| TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON |
160+-----------------------------+-------------------------------------+---------------+
161| TFM_CRYPTO_TEST_HKDF | Test SHA-512 cryptography algorithm | ON |
162+-----------------------------+-------------------------------------+---------------+
163
Anton Komlev211aacf2020-11-02 12:48:11 +0000164TF-M Profiles
165-------------
166
167TF-M Profiles are implemented as a single cmake configuration file, under the
168``config/profile`` directory. A good understanding can be gained quickly by
169looking at the Profile configuration files, but the ultimate reference for
Summer Qinabf66982021-04-06 17:22:15 +0800170Profiles are the design documents in the ``docs/technical_references/profiles/``
Anton Komlev211aacf2020-11-02 12:48:11 +0000171directory.
Anton Komlevb8e3af02020-08-28 10:23:57 +0100172
173PSA test configuration
174----------------------
175
176PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The
177variable should be set to the name of the test suite that is desired. It is
178_not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``.
179
Jamie Fox19c91c22019-02-10 18:04:58 +0000180The Functional API tests are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100181 - ``CRYPTO``
182 - ``INITIAL_ATTESTATION``
183 - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE)
184 - ``INTERNAL_TRUSTED_STORAGE``
185 - ``PROTECTED_STORAGE``
186
Jamie Fox19c91c22019-02-10 18:04:58 +0000187The Firmware Framework test suites are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100188 - ``IPC``
189
190Note that these map directly to the ``SUITE`` cmake variable used in the
191psa-arch-tests documentation.
192
193Migration from legacy buildsystem
194---------------------------------
195
196The previous (legacy) cmake buildsystem made use of separate configuration
197files, where now build options are controlled by variables. For ease of
198transition, a table below is provided that maps the legacy files to the current
199variables, in the format of cmake command line parameters.
200
Summer Qin001ce9d2020-11-04 14:41:54 +0800201+------------------------------------------+---------------------------------------+
202| File | Cmake command line |
203+==========================================+=======================================+
204| ConfigDefault.cmake | <No options> |
205+------------------------------------------+---------------------------------------+
206| ConfigCoreIPC.cmake | -DTFM_PSA_API=ON |
207+------------------------------------------+---------------------------------------+
208| ConfigCoreIPCTfmLevel2.cmake | -DTFM_PSA_API=ON |
209| | -DTFM_ISOLATION_LEVEL=2 |
210+------------------------------------------+---------------------------------------+
211| ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small |
212+------------------------------------------+---------------------------------------+
213| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
214+------------------------------------------+---------------------------------------+
215| ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON |
216+------------------------------------------+---------------------------------------+
217| ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON |
218| | -DTFM_PSA_API=ON |
219+------------------------------------------+---------------------------------------+
220| ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON |
221| | -DTFM_PSA_API=ON |
222| | -DTFM_ISOLATION_LEVEL=2 |
223+------------------------------------------+---------------------------------------+
224| ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small |
225| | -DTEST_NS=ON -DTEST_S=ON |
226+------------------------------------------+---------------------------------------+
227| ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium |
228| | -DTEST_NS=ON -DTEST_S=ON |
229+------------------------------------------+---------------------------------------+
230| ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> |
231+------------------------------------------+---------------------------------------+
232| ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> |
233| | -DTFM_PSA_API=ON |
234+------------------------------------------+---------------------------------------+
235| ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> |
236| | -DTFM_PSA_API=ON |
237| | -DTFM_ISOLATION_LEVEL=2 |
238+------------------------------------------+---------------------------------------+
239| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
240| + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PROTECTED_STORAGE=OFF |
241+------------------------------------------+---------------------------------------+
Anton Komlevb8e3af02020-08-28 10:23:57 +0100242
243There has also been some changes to the PSA manifest file generation. The files
244are now generated into a seperate tree in the ``<tfm build dir>/generated``
245directory. Therefore they have been removed from the source tree. Any changes
246should be made only to the template files.
247
248The api for the ``tools/tfm_parse_manifest_list.py`` script has also changed
249slightly. It is no longer required to be run manually as it is run as part of
250cmake.
251
252*******************
253TF-M build examples
254*******************
255
Subhasish Ghoshbc849302021-04-08 20:21:20 +0100256.. Note::
257 By default, CMAKE_BUILD_TYPE is set to Release, for debug support change
258 this to Debug. See below for an example.
259
Anton Komlevb8e3af02020-08-28 10:23:57 +0100260Example: building TF-M for AN521 platform using GCC:
261====================================================
262.. code-block:: bash
263
Leonardo Sandoval98350142021-02-03 16:32:14 -0600264 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800265 cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug
Anton Komlevb8e3af02020-08-28 10:23:57 +0100266 cmake --build cmake_build -- install
267
268Alternately using traditional cmake syntax
269
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200270.. code-block:: bash
271
Leonardo Sandoval98350142021-02-03 16:32:14 -0600272 cd <TF-M base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200273 mkdir cmake_build
274 cd cmake_build
Summer Qin2de23d02021-05-14 13:44:14 +0800275 cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100276 make install
277
278.. Note::
279 Unix Makefiles is the default generator. Ninja is also supported by setting
280 -GNinja
281
282.. Note::
283
284 It is recommended to build each different build configuration in a separate
285 build directory.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200286
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600287As seen above, the toolchain can be set using the -DTFM_TOOLCHAIN_FILE parameter. Without
288it, the build command takes the GNU ARM toolchain as default, so there is no need
289to explicitly include it. In case other toolchain is required, i.e. ARM Clang, simply
290specify in the command line
291
292.. code-block:: bash
Subhasish Ghoshbc849302021-04-08 20:21:20 +0100293
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600294 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800295 cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_ARMCLANG.cmake -DTEST_S=ON -DTEST_NS=ON
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600296 cmake --build cmake_build -- install
297
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200298Regression Tests for the AN521 target platform
299==============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100300
301Regression tests can be build by using the TEST_S and TEST_NS settings. Either
302can be used in isolation or both can be used to enable both suites. All tests
303for all enabled partitions are run, along with IPC and Multicore tests if those
304features are enabled.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200305
306.. code-block:: bash
307
Leonardo Sandoval98350142021-02-03 16:32:14 -0600308 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800309 cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100310 cmake --build cmake_build -- install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200311
Anton Komlevb8e3af02020-08-28 10:23:57 +0100312Alternately using traditional cmake syntax
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200313
314.. code-block:: bash
315
Leonardo Sandoval98350142021-02-03 16:32:14 -0600316 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100317 mkdir cmake_build
318 cd cmake_build
Summer Qin2de23d02021-05-14 13:44:14 +0800319 cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100320 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200321
Jamie Fox19c91c22019-02-10 18:04:58 +0000322Build for PSA Functional API compliance tests
323=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100324The build system provides support for building and integrating the PSA API tests
325from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
326controlled using the TEST_PSA_API variable. Enabling both regression tests and
327PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200328
Anton Komlevb8e3af02020-08-28 10:23:57 +0100329The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200330
Subhasish Ghoshbc849302021-04-08 20:21:20 +0100331.. code-block:: bash
Anton Komlevb8e3af02020-08-28 10:23:57 +0100332
333 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
334 -DTEST_PSA_API=PROTECTED_STORAGE
335 -DTEST_PSA_API=STORAGE
336 -DTEST_PSA_API=CRYPTO
337 -DTEST_PSA_API=INITIAL_ATTESTATION
338
339Respectively for the corresponding service. For example, to enable the PSA API
340tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200341
342.. code-block:: bash
343
Leonardo Sandoval98350142021-02-03 16:32:14 -0600344 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800345 cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100346 cmake --build cmake_build -- install
347
348Alternately using traditional cmake syntax
349
350.. code-block:: bash
351
Leonardo Sandoval98350142021-02-03 16:32:14 -0600352 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100353 mkdir cmake_build
354 cd cmake_build
Summer Qin2de23d02021-05-14 13:44:14 +0800355 cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100356 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200357
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530358Build for PSA FF (IPC) compliance tests
359=======================================
360
Anton Komlevb8e3af02020-08-28 10:23:57 +0100361The build system provides support for building and integrating the PSA FF
362compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530363
Subhasish Ghoshbc849302021-04-08 20:21:20 +0100364.. code-block:: bash
Anton Komlevb8e3af02020-08-28 10:23:57 +0100365
366 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530367
368.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000369
Leonardo Sandoval98350142021-02-03 16:32:14 -0600370 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800371 cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100372 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530373
Anton Komlevb8e3af02020-08-28 10:23:57 +0100374Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530375
376.. code-block:: bash
377
Leonardo Sandoval98350142021-02-03 16:32:14 -0600378 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100379 mkdir cmake_build
380 cd cmake_build
Summer Qin2de23d02021-05-14 13:44:14 +0800381 cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100382 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530383
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200384Location of build artifacts
385===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200386
Anton Komlevb8e3af02020-08-28 10:23:57 +0100387All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
388**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200389
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200390
Anton Komlevb8e3af02020-08-28 10:23:57 +0100391For the purposes of maintaining compatibility with the legacy cmake build
392system, they are also provided in
393``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
394artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200395
396Building the documentation
397==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100398Please ensure the dependencies for building the documentation are installed
399as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
400requirements to build the firmware, are only required when using the CMAKE
401method
402
403There are currently two ways of building the documentation:
404- Using the CMake build system as custom targets
405- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
406
407Using the CMake build-system
408----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200409
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100410Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
411tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200412
413.. Note::
414 For building the documentation all tools needed to build the firmware must
415 be available.
416
417Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100418^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200419.. code-block:: bash
420
421 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800422 cmake -S . -B cmake_doc -DTFM_PLATFORM=arm/mps2/an521
Anton Komlevb8e3af02020-08-28 10:23:57 +0100423 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200424
425The documentation files will be available under the directory::
426
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100427 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200428
429Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100430^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200431.. code-block:: bash
432
433 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800434 cmake -S . -B cmake_doc -DTFM_PLATFORM=arm/mps2/an521
Anton Komlevb8e3af02020-08-28 10:23:57 +0100435 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200436
437The documentation files will be available under the directory::
438
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100439 cmake_doc/docs/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200440
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100441Manually using documentation generation tools
442---------------------------------------------
443
444Invoking Sphinx-build will build both user_guide and reference_manual
445targets.
446
447.. code-block:: bash
448
449 # Build the documentation from build_docs directory
Shawn Shanfdb47a02021-03-30 17:16:43 +0800450 cd <TF-M base folder>
451 mkdir build_docs
452 cp docs/conf.py build_docs/conf.py
453 cd build_docs
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100454 sphinx-build ./ user_guide
455
456 # Build the documentation from a custom location
457 # setting the build_docs as input
458
459 # Note that using this method will still generate the reference manual
460 # to the <TF-M base folder>/build_docs/reference_manual
461 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
462 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
463
Anton Komlevb8e3af02020-08-28 10:23:57 +0100464****************************
465Manual dependency management
466****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000467
Raef Coles1ecb8132020-10-02 15:11:24 +0100468The TF-M build system will by default fetch all dependencies with appropriate
469versions and store them inside the build tree. In this case, the build tree
470location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
471deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000472
Raef Coles1ecb8132020-10-02 15:11:24 +0100473If you have local copies already, and wish to avoid having the libraries
474downloaded every time the build directory is deleted, then the following
Raef Colesc630b882020-12-10 15:46:18 +0000475variables can be set to the path to the root directory of the local repo. This
476will disable the automatic downloading for that dependency.
Raef Coles1ecb8132020-10-02 15:11:24 +0100477
Raef Colesc630b882020-12-10 15:46:18 +0000478+----------------+---------------------+-----------------------------------------------------+
479| Dependency | Cmake variable | Git repo URL |
480+================+=====================+=====================================================+
481| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
482+----------------+---------------------+-----------------------------------------------------+
483| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
484+----------------+---------------------+-----------------------------------------------------+
485| MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot |
486+----------------+---------------------+-----------------------------------------------------+
487| psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests |
488+----------------+---------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000489
Anton Komlevb8e3af02020-08-28 10:23:57 +0100490For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000491
492.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100493 - Some patches are required to the mbedtls repo to allow building it as part of
494 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100495 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
496 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000497
Anton Komlevb8e3af02020-08-28 10:23:57 +0100498.. Note::
499 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
500 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800501
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100502.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
503.. _Doxygen: https://www.doxygen.nl
504
Kevin Pengcba37d32020-12-07 17:07:39 +0800505TF-M Tests
506==========
507
508Dependency auto downloading is used by default.
509The TF-M build system downloads the tf-m-tests repo with a fixed version
510specified by ``TFM_TEST_REPO_VERSION`` in ``config/config_default.cmake``.
511The version can be a release tag or a commit hash.
512
513Developers who want a different version of tf-m-tests can override
514``TFM_TEST_REPO_PATH`` to a local copy with the desired version.
515
516As the test repo is part of the TF-M project and coupled with TF-M repo a lot,
517The version should be updated when there are dependency changes between the TF-M
518repo and the test repo and when there is a complete change merged in test repo.
519
520A complete change is one or more patches that are for the same purpose, for
521example a new test suite or enhancements on the test cases.
522Patches in one change can be merge individually provided they do not break
523anything or cause any regressions.
524But the version in the TF-M gets updated only when all the patches are merged.
525
Raef Coles1ecb8132020-10-02 15:11:24 +0100526Example: building TF-M for AN521 platform with local Mbed Crypto
527================================================================
528
529Prepare Mbed Crypto repository
530------------------------------
531
532This is only required to be done once. For dependencies that do not have any
533``.patch`` files in their ``lib/ext`` directory the only required step is
534cloning the repo and checking out the correct branch.
535
536.. code-block:: bash
537
538 cd <Mbed Crypto base folder>
539 git clone https://github.com/ARMmbed/mbedtls
540 cd mbedtls
541 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
542 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
543
544.. Note::
545 - <Mbed Crypto base folder> does not need to have any fixed posisition related
546 to the TF-M repo.
547
548Build TF-M
549----------
550
551With new cmake syntax
552
553.. code-block:: bash
554
Leonardo Sandoval98350142021-02-03 16:32:14 -0600555 cd <TF-M base folder>
Summer Qin2de23d02021-05-14 13:44:14 +0800556 cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
Raef Coles1ecb8132020-10-02 15:11:24 +0100557 cmake --build cmake_build -- install
558
559Alternately using traditional cmake syntax
560
561.. code-block:: bash
562
Leonardo Sandoval98350142021-02-03 16:32:14 -0600563 cd <TF-M base folder>
Raef Coles1ecb8132020-10-02 15:11:24 +0100564 mkdir cmake_build
565 cd cmake_build
Summer Qin2de23d02021-05-14 13:44:14 +0800566 cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
Raef Coles1ecb8132020-10-02 15:11:24 +0100567 make install
568
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200569--------------
570
Summer Qinabf66982021-04-06 17:22:15 +0800571*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*