blob: 9779d09006d7bb0a9046df82e6b78302cfcc7304 [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
256Example: building TF-M for AN521 platform using GCC:
257====================================================
258.. code-block:: bash
259
Leonardo Sandoval98350142021-02-03 16:32:14 -0600260 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100261 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100262 cmake --build cmake_build -- install
263
264Alternately using traditional cmake syntax
265
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200266.. code-block:: bash
267
Leonardo Sandoval98350142021-02-03 16:32:14 -0600268 cd <TF-M base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200269 mkdir cmake_build
270 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100271 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100272 make install
273
274.. Note::
275 Unix Makefiles is the default generator. Ninja is also supported by setting
276 -GNinja
277
278.. Note::
279
280 It is recommended to build each different build configuration in a separate
281 build directory.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200282
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600283As seen above, the toolchain can be set using the -DTFM_TOOLCHAIN_FILE parameter. Without
284it, the build command takes the GNU ARM toolchain as default, so there is no need
285to explicitly include it. In case other toolchain is required, i.e. ARM Clang, simply
286specify in the command line
287
288.. code-block:: bash
289 cd <TF-M base folder>
290 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_ARMCLANG.cmake -DTEST_S=ON -DTEST_NS=ON
291 cmake --build cmake_build -- install
292
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200293Regression Tests for the AN521 target platform
294==============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100295
296Regression tests can be build by using the TEST_S and TEST_NS settings. Either
297can be used in isolation or both can be used to enable both suites. All tests
298for all enabled partitions are run, along with IPC and Multicore tests if those
299features are enabled.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200300
301.. code-block:: bash
302
Leonardo Sandoval98350142021-02-03 16:32:14 -0600303 cd <TF-M base folder>
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600304 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100305 cmake --build cmake_build -- install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200306
Anton Komlevb8e3af02020-08-28 10:23:57 +0100307Alternately using traditional cmake syntax
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200308
309.. code-block:: bash
310
Leonardo Sandoval98350142021-02-03 16:32:14 -0600311 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100312 mkdir cmake_build
313 cd cmake_build
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600314 cmake .. -DTFM_PLATFORM=mps2/an521 -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100315 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200316
Jamie Fox19c91c22019-02-10 18:04:58 +0000317Build for PSA Functional API compliance tests
318=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100319The build system provides support for building and integrating the PSA API tests
320from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
321controlled using the TEST_PSA_API variable. Enabling both regression tests and
322PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200323
Anton Komlevb8e3af02020-08-28 10:23:57 +0100324The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200325
Anton Komlevb8e3af02020-08-28 10:23:57 +0100326.. code-block::
327
328 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
329 -DTEST_PSA_API=PROTECTED_STORAGE
330 -DTEST_PSA_API=STORAGE
331 -DTEST_PSA_API=CRYPTO
332 -DTEST_PSA_API=INITIAL_ATTESTATION
333
334Respectively for the corresponding service. For example, to enable the PSA API
335tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200336
337.. code-block:: bash
338
Leonardo Sandoval98350142021-02-03 16:32:14 -0600339 cd <TF-M base folder>
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600340 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100341 cmake --build cmake_build -- install
342
343Alternately using traditional cmake syntax
344
345.. code-block:: bash
346
Leonardo Sandoval98350142021-02-03 16:32:14 -0600347 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100348 mkdir cmake_build
349 cd cmake_build
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600350 cmake .. -DTFM_PLATFORM=mps2/an521 -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100351 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200352
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530353Build for PSA FF (IPC) compliance tests
354=======================================
355
Anton Komlevb8e3af02020-08-28 10:23:57 +0100356The build system provides support for building and integrating the PSA FF
357compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530358
Anton Komlevb8e3af02020-08-28 10:23:57 +0100359.. code-block::
360
361 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530362
363.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000364
Leonardo Sandoval98350142021-02-03 16:32:14 -0600365 cd <TF-M base folder>
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600366 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100367 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530368
Anton Komlevb8e3af02020-08-28 10:23:57 +0100369Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530370
371.. code-block:: bash
372
Leonardo Sandoval98350142021-02-03 16:32:14 -0600373 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100374 mkdir cmake_build
375 cd cmake_build
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600376 cmake .. -DTFM_PLATFORM=mps2/an521 -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100377 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530378
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200379Location of build artifacts
380===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200381
Anton Komlevb8e3af02020-08-28 10:23:57 +0100382All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
383**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200384
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200385
Anton Komlevb8e3af02020-08-28 10:23:57 +0100386For the purposes of maintaining compatibility with the legacy cmake build
387system, they are also provided in
388``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
389artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200390
391Building the documentation
392==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100393Please ensure the dependencies for building the documentation are installed
394as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
395requirements to build the firmware, are only required when using the CMAKE
396method
397
398There are currently two ways of building the documentation:
399- Using the CMake build system as custom targets
400- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
401
402Using the CMake build-system
403----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200404
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100405Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
406tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200407
408.. Note::
409 For building the documentation all tools needed to build the firmware must
410 be available.
411
412Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100413^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200414.. code-block:: bash
415
416 cd <TF-M base folder>
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600417 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521
Anton Komlevb8e3af02020-08-28 10:23:57 +0100418 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200419
420The documentation files will be available under the directory::
421
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100422 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200423
424Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100425^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200426.. code-block:: bash
427
428 cd <TF-M base folder>
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600429 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521
Anton Komlevb8e3af02020-08-28 10:23:57 +0100430 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200431
432The documentation files will be available under the directory::
433
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100434 cmake_doc/docs/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200435
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100436Manually using documentation generation tools
437---------------------------------------------
438
439Invoking Sphinx-build will build both user_guide and reference_manual
440targets.
441
442.. code-block:: bash
443
444 # Build the documentation from build_docs directory
Shawn Shanfdb47a02021-03-30 17:16:43 +0800445 cd <TF-M base folder>
446 mkdir build_docs
447 cp docs/conf.py build_docs/conf.py
448 cd build_docs
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100449 sphinx-build ./ user_guide
450
451 # Build the documentation from a custom location
452 # setting the build_docs as input
453
454 # Note that using this method will still generate the reference manual
455 # to the <TF-M base folder>/build_docs/reference_manual
456 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
457 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
458
Anton Komlevb8e3af02020-08-28 10:23:57 +0100459****************************
460Manual dependency management
461****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000462
Raef Coles1ecb8132020-10-02 15:11:24 +0100463The TF-M build system will by default fetch all dependencies with appropriate
464versions and store them inside the build tree. In this case, the build tree
465location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
466deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000467
Raef Coles1ecb8132020-10-02 15:11:24 +0100468If you have local copies already, and wish to avoid having the libraries
469downloaded every time the build directory is deleted, then the following
Raef Colesc630b882020-12-10 15:46:18 +0000470variables can be set to the path to the root directory of the local repo. This
471will disable the automatic downloading for that dependency.
Raef Coles1ecb8132020-10-02 15:11:24 +0100472
Raef Colesc630b882020-12-10 15:46:18 +0000473+----------------+---------------------+-----------------------------------------------------+
474| Dependency | Cmake variable | Git repo URL |
475+================+=====================+=====================================================+
476| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
477+----------------+---------------------+-----------------------------------------------------+
478| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
479+----------------+---------------------+-----------------------------------------------------+
480| MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot |
481+----------------+---------------------+-----------------------------------------------------+
482| psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests |
483+----------------+---------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000484
Anton Komlevb8e3af02020-08-28 10:23:57 +0100485For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000486
487.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100488 - Some patches are required to the mbedtls repo to allow building it as part of
489 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100490 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
491 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000492
Anton Komlevb8e3af02020-08-28 10:23:57 +0100493.. Note::
494 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
495 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800496
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100497.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
498.. _Doxygen: https://www.doxygen.nl
499
Kevin Pengcba37d32020-12-07 17:07:39 +0800500TF-M Tests
501==========
502
503Dependency auto downloading is used by default.
504The TF-M build system downloads the tf-m-tests repo with a fixed version
505specified by ``TFM_TEST_REPO_VERSION`` in ``config/config_default.cmake``.
506The version can be a release tag or a commit hash.
507
508Developers who want a different version of tf-m-tests can override
509``TFM_TEST_REPO_PATH`` to a local copy with the desired version.
510
511As the test repo is part of the TF-M project and coupled with TF-M repo a lot,
512The version should be updated when there are dependency changes between the TF-M
513repo and the test repo and when there is a complete change merged in test repo.
514
515A complete change is one or more patches that are for the same purpose, for
516example a new test suite or enhancements on the test cases.
517Patches in one change can be merge individually provided they do not break
518anything or cause any regressions.
519But the version in the TF-M gets updated only when all the patches are merged.
520
Raef Coles1ecb8132020-10-02 15:11:24 +0100521Example: building TF-M for AN521 platform with local Mbed Crypto
522================================================================
523
524Prepare Mbed Crypto repository
525------------------------------
526
527This is only required to be done once. For dependencies that do not have any
528``.patch`` files in their ``lib/ext`` directory the only required step is
529cloning the repo and checking out the correct branch.
530
531.. code-block:: bash
532
533 cd <Mbed Crypto base folder>
534 git clone https://github.com/ARMmbed/mbedtls
535 cd mbedtls
536 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
537 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
538
539.. Note::
540 - <Mbed Crypto base folder> does not need to have any fixed posisition related
541 to the TF-M repo.
542
543Build TF-M
544----------
545
546With new cmake syntax
547
548.. code-block:: bash
549
Leonardo Sandoval98350142021-02-03 16:32:14 -0600550 cd <TF-M base folder>
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600551 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
Raef Coles1ecb8132020-10-02 15:11:24 +0100552 cmake --build cmake_build -- install
553
554Alternately using traditional cmake syntax
555
556.. code-block:: bash
557
Leonardo Sandoval98350142021-02-03 16:32:14 -0600558 cd <TF-M base folder>
Raef Coles1ecb8132020-10-02 15:11:24 +0100559 mkdir cmake_build
560 cd cmake_build
Leonardo Sandoval49a558c2021-02-03 17:04:22 -0600561 cmake .. -DTFM_PLATFORM=mps2/an521 -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
Raef Coles1ecb8132020-10-02 15:11:24 +0100562 make install
563
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200564--------------
565
Summer Qinabf66982021-04-06 17:22:15 +0800566*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*