blob: 7e92be19d721f391e45043f92e328fbc9134221c [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
22Dependency management is now handled by cmake. If you wish to alter this
23behaviour, see :ref:`docs/getting_started/tfm_build_instruction:Manual
24dependency management`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020025
Minos Galanakisac6b06c2020-03-19 12:57:02 +000026.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +010027
28 - For building with Armclang compiler version 6.10.0, please follow the note
Anton Komlev211aacf2020-11-02 12:48:11 +000029 in :ref:`docs/getting_started/tfm_sw_requirement:External dependencies` section.
Anton Komlevb8e3af02020-08-28 10:23:57 +010030 - For building with the IAR toolchain, please see the notes in
TTornblomb9e5ed02020-02-13 16:53:15 +010031 :doc:`software requirements <tfm_build_instruction_iar>`
32
Anton Komlevb8e3af02020-08-28 10:23:57 +010033.. _tfm_cmake_configuration:
34
35Cmake configuration
36===================
37
38All configuration options are provided by cmake variables, and their default
39values, with docstrings, can be found in ``config/config_default.cmake``.
40
Soby Mathew7b7e1242020-10-07 13:31:56 +010041Configuration is provided in multiple stages, and each subsequent stage
42can override settings of the previous stage.
Anton Komlevb8e3af02020-08-28 10:23:57 +010043
44 1. ``config/config_default.cmake`` is loaded.
Soby Mathew7b7e1242020-10-07 13:31:56 +010045 2. Command-line variable settings are applied.
46 3. If it exists, CMAKE_BUILD_TYPE specific config is applied from
47 ``config/build_type/<build_type>.cmake``.
48 4. If TEST_PSA_TEST is set, then PSA API test related config is applied from
49 ``config/tests/config_test_psa_api.cmake``.
50 5. If it exists, TFM Profile specific config is applied from
51 ``config/profile/<tfm_profile>.cmake``.
52 6. Target specific config from ``platform/ext/target/<target_platform>/config.cmake``
53 is applied.
54 7. If CRYPTO_HW_ACCELERATOR is set, then a config specific to the
55 accelerator type is applied if it exists.
56 8. If the ``TFM_EXTRA_CONFIG_PATH`` variable has been set, that file is
57 loaded.
Anton Komlevb8e3af02020-08-28 10:23:57 +010058
59.. Warning::
60 This means that command-line settings are not applied when they conflict
61 with required platform settings. If it is required to override platform
62 settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be
63 used.
64
65Required cmake parameters for building TF-M
66-------------------------------------------
67
68+----------------------+-------------------------------------------------------+
69| Parameter | Description |
70+======================+=======================================================+
71| TFM_PLATFORM | The target platform as a path from the base directory |
72| | ``/platform/ext/target`` |
73+----------------------+-------------------------------------------------------+
Raef Coles69817322020-10-19 14:14:14 +010074| TFM_TOOLCHAIN_FILE | The path to the toolchain file that corresponds to |
Anton Komlevb8e3af02020-08-28 10:23:57 +010075| | the desired compiler. |
76+----------------------+-------------------------------------------------------+
77
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
170Profiles are the design documents in the ``docs/design_documents/profiles/``
171directory.
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
201+------------------------------------------+-----------------------------------+
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_PS=OFF |
241+------------------------------------------+-----------------------------------+
242
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
260 cd <base folder>
261 cd trusted-firmware-m
Raef Coles69817322020-10-19 14:14:14 +0100262 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100263 cmake --build cmake_build -- install
264
265Alternately using traditional cmake syntax
266
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200267.. code-block:: bash
268
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500269 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200270 cd trusted-firmware-m
271 mkdir cmake_build
272 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100273 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100274 make install
275
276.. Note::
277 Unix Makefiles is the default generator. Ninja is also supported by setting
278 -GNinja
279
280.. Note::
281
282 It is recommended to build each different build configuration in a separate
283 build directory.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200284
285Regression Tests for the AN521 target platform
286==============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100287
288Regression tests can be build by using the TEST_S and TEST_NS settings. Either
289can be used in isolation or both can be used to enable both suites. All tests
290for all enabled partitions are run, along with IPC and Multicore tests if those
291features are enabled.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200292
293.. code-block:: bash
294
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500295 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200296 cd trusted-firmware-m
Raef Coles69817322020-10-19 14:14:14 +0100297 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100298 cmake --build cmake_build -- install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200299
Anton Komlevb8e3af02020-08-28 10:23:57 +0100300Alternately using traditional cmake syntax
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200301
302.. code-block:: bash
303
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500304 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200305 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100306 mkdir cmake_build
307 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100308 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100309 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200310
Jamie Fox19c91c22019-02-10 18:04:58 +0000311Build for PSA Functional API compliance tests
312=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100313The build system provides support for building and integrating the PSA API tests
314from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
315controlled using the TEST_PSA_API variable. Enabling both regression tests and
316PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200317
Anton Komlevb8e3af02020-08-28 10:23:57 +0100318The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200319
Anton Komlevb8e3af02020-08-28 10:23:57 +0100320.. code-block::
321
322 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
323 -DTEST_PSA_API=PROTECTED_STORAGE
324 -DTEST_PSA_API=STORAGE
325 -DTEST_PSA_API=CRYPTO
326 -DTEST_PSA_API=INITIAL_ATTESTATION
327
328Respectively for the corresponding service. For example, to enable the PSA API
329tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200330
331.. code-block:: bash
332
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500333 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200334 cd trusted-firmware-m
Raef Coles69817322020-10-19 14:14:14 +0100335 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100336 cmake --build cmake_build -- install
337
338Alternately using traditional cmake syntax
339
340.. code-block:: bash
341
342 cd <base folder>
343 cd trusted-firmware-m
344 mkdir cmake_build
345 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100346 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100347 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200348
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530349Build for PSA FF (IPC) compliance tests
350=======================================
351
Anton Komlevb8e3af02020-08-28 10:23:57 +0100352The build system provides support for building and integrating the PSA FF
353compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530354
Anton Komlevb8e3af02020-08-28 10:23:57 +0100355.. code-block::
356
357 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530358
359.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000360
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500361 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530362 cd trusted-firmware-m
Raef Coles69817322020-10-19 14:14:14 +0100363 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100364 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530365
Anton Komlevb8e3af02020-08-28 10:23:57 +0100366Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530367
368.. code-block:: bash
369
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500370 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530371 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100372 mkdir cmake_build
373 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100374 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100375 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530376
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200377Location of build artifacts
378===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200379
Anton Komlevb8e3af02020-08-28 10:23:57 +0100380All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
381**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200382
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200383
Anton Komlevb8e3af02020-08-28 10:23:57 +0100384For the purposes of maintaining compatibility with the legacy cmake build
385system, they are also provided in
386``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
387artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200388
389Building the documentation
390==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100391Please ensure the dependencies for building the documentation are installed
392as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
393requirements to build the firmware, are only required when using the CMAKE
394method
395
396There are currently two ways of building the documentation:
397- Using the CMake build system as custom targets
398- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
399
400Using the CMake build-system
401----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200402
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100403Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
404tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200405
406.. Note::
407 For building the documentation all tools needed to build the firmware must
408 be available.
409
410Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100411^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200412.. code-block:: bash
413
414 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100415 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100416 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200417
418The documentation files will be available under the directory::
419
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100420 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200421
422Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100423^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200424.. code-block:: bash
425
426 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100427 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100428 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200429
430The documentation files will be available under the directory::
431
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100432 cmake_doc/docs/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200433
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100434Manually using documentation generation tools
435---------------------------------------------
436
437Invoking Sphinx-build will build both user_guide and reference_manual
438targets.
439
440.. code-block:: bash
441
442 # Build the documentation from build_docs directory
443 cd <TF-M base folder>/ build_docs/
444 sphinx-build ./ user_guide
445
446 # Build the documentation from a custom location
447 # setting the build_docs as input
448
449 # Note that using this method will still generate the reference manual
450 # to the <TF-M base folder>/build_docs/reference_manual
451 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
452 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
453
Anton Komlevb8e3af02020-08-28 10:23:57 +0100454****************************
455Manual dependency management
456****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000457
Raef Coles1ecb8132020-10-02 15:11:24 +0100458The TF-M build system will by default fetch all dependencies with appropriate
459versions and store them inside the build tree. In this case, the build tree
460location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
461deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000462
Raef Coles1ecb8132020-10-02 15:11:24 +0100463If you have local copies already, and wish to avoid having the libraries
464downloaded every time the build directory is deleted, then the following
465variables can be set to the paths to those local copies. This will disable the
466automatic downloading for that dependency.
467
468+----------------+--------------------+-----------------------------------------------------+
469| Dependency | Cmake variable | Git repo URL |
470+================+====================+=====================================================+
471| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
472+----------------+--------------------+-----------------------------------------------------+
473| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
474+----------------+--------------------+-----------------------------------------------------+
475| MCUboot | MCUBOOT_PATH | https://github.com/JuulLabs-OSS/mcuboot |
476+----------------+--------------------+-----------------------------------------------------+
477| psa-arch-tests | PSA_ARCH_TEST_PATH | https://github.com/ARM-software/psa-arch-tests |
478+----------------+--------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000479
Anton Komlevb8e3af02020-08-28 10:23:57 +0100480For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000481
482.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100483 - Some patches are required to the mbedtls repo to allow building it as part of
484 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100485 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
486 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000487
Anton Komlevb8e3af02020-08-28 10:23:57 +0100488.. Note::
489 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
490 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800491
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100492.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
493.. _Doxygen: https://www.doxygen.nl
494
Raef Coles1ecb8132020-10-02 15:11:24 +0100495Example: building TF-M for AN521 platform with local Mbed Crypto
496================================================================
497
498Prepare Mbed Crypto repository
499------------------------------
500
501This is only required to be done once. For dependencies that do not have any
502``.patch`` files in their ``lib/ext`` directory the only required step is
503cloning the repo and checking out the correct branch.
504
505.. code-block:: bash
506
507 cd <Mbed Crypto base folder>
508 git clone https://github.com/ARMmbed/mbedtls
509 cd mbedtls
510 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
511 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
512
513.. Note::
514 - <Mbed Crypto base folder> does not need to have any fixed posisition related
515 to the TF-M repo.
516
517Build TF-M
518----------
519
520With new cmake syntax
521
522.. code-block:: bash
523
524 cd <base folder>
525 cd trusted-firmware-m
Raef Coles69817322020-10-19 14:14:14 +0100526 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
Raef Coles1ecb8132020-10-02 15:11:24 +0100527 cmake --build cmake_build -- install
528
529Alternately using traditional cmake syntax
530
531.. code-block:: bash
532
533 cd <base folder>
534 cd trusted-firmware-m
535 mkdir cmake_build
536 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100537 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
Raef Coles1ecb8132020-10-02 15:11:24 +0100538 make install
539
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200540--------------
541
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000542*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*