blob: 23220a611f13cb6f0efbdb35762f394e8edb5d02 [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+----------------------+-------------------------------------------------------+
Raef Coles69817322020-10-19 14:14:14 +010077| TFM_TOOLCHAIN_FILE | The path to the toolchain file that corresponds to |
Anton Komlevb8e3af02020-08-28 10:23:57 +010078| | the desired compiler. |
79+----------------------+-------------------------------------------------------+
80
81By default release configuration builds. Alternate build types can be controlled
82by the CMAKE_BUILD_TYPE variable.
83
84Build type
85----------
86
87Build type is controlled by the ``CMAKE_BUILD_TYPE`` variable. The possible
88types are:
89
90 - ``Debug``
91 - ``Relwithdebinfo``
92 - ``Release``
93 - ``Minsizerel``
94
95``Release`` is default.
96
97Both ``Debug`` and ``Relwithdebinfo`` will include debug symbols in the output
98files. ``Relwithdebinfo``, ``Release`` and ``Minsizerel`` have optimization
Raef Coles1ecb8132020-10-02 15:11:24 +010099turned on and hence will produce smaller, faster code. ``Minsizerel`` will
Anton Komlevb8e3af02020-08-28 10:23:57 +0100100produce the smallest code, and hence is often a good idea on RAM or flash
101constrained systems.
102
103Other cmake parameters
104----------------------
105
106The full list of default options is in ``config/config_default.cmake``. Several
107important options are listed below.
108
109
110+---------------------+----------------------------------------+---------------+
111| Parameter | Description | Default value |
112+=====================+========================================+===============+
113| BL2 | Build level 2 secure bootloader. | ON |
114+---------------------+----------------------------------------+---------------+
115| NS | Build NS app. Required for test code. | ON |
116+---------------------+----------------------------------------+---------------+
117| TFM_PSA_API | Use PSA api (IPC mode) instead of | OFF |
118| | secure library mode. | |
119+---------------------+----------------------------------------+---------------+
120| TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 |
121+---------------------+----------------------------------------+---------------+
122| TFM_PROFILE | Set TFM profile. | |
123+---------------------+----------------------------------------+---------------+
124| TEST_S | Build secure regression tests. | OFF |
125+---------------------+----------------------------------------+---------------+
126| TEST_NS | Build non-secure regression tests. | OFF |
127+---------------------+----------------------------------------+---------------+
128| TEST_PSA_API | Build PSA API TESTS for the given | |
129| | suite. Takes a PSA api ``SUITE`` as an | |
130| | argument (``CRYPTO`` etc). | |
131+---------------------+----------------------------------------+---------------+
132
133Regression test configuration
134-----------------------------
135
136Regression test configuration is controlled entirely by the ``TEST_S`` and
137``TEST_NS`` cmake variables.
138
139If regression testing is enabled, it will then enable all tests for the enabled
140secure partitions. If IPC mode is enabled via ``TFM_PSA_API`` the IPC tests will
141be enabled. QCBOR and T_COSE tests are linked to the Initial Attestation
142partition, as they are only used there. Multicore tests will be enabled if
143``TFM_MULTI_CORE_TOPOLOGY`` is enabled.
144
145Some cryptographic tests can be enabled and disabled. This is done to prevent
146false failures from being reported when a smaller Mbed Crypto config is being
147used which does not support all features.
148
149+-----------------------------+-------------------------------------+---------------+
150| Parameter | Description | Default value |
151+=============================+=====================================+===============+
152| TFM_CRYPTO_TEST_ALG_CBC | Test CBC cryptography mode | ON |
153+-----------------------------+-------------------------------------+---------------+
154| TFM_CRYPTO_TEST_ALG_CCM | Test CCM cryptography mode | ON |
155+-----------------------------+-------------------------------------+---------------+
156| TFM_CRYPTO_TEST_ALG_CFB | Test CFB cryptography mode | ON |
157+-----------------------------+-------------------------------------+---------------+
158| TFM_CRYPTO_TEST_ALG_CTR | Test CTR cryptography mode | ON |
159+-----------------------------+-------------------------------------+---------------+
160| TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON |
161+-----------------------------+-------------------------------------+---------------+
162| TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON |
163+-----------------------------+-------------------------------------+---------------+
164| TFM_CRYPTO_TEST_HKDF | Test SHA-512 cryptography algorithm | ON |
165+-----------------------------+-------------------------------------+---------------+
166
Anton Komlev211aacf2020-11-02 12:48:11 +0000167TF-M Profiles
168-------------
169
170TF-M Profiles are implemented as a single cmake configuration file, under the
171``config/profile`` directory. A good understanding can be gained quickly by
172looking at the Profile configuration files, but the ultimate reference for
Summer Qinabf66982021-04-06 17:22:15 +0800173Profiles are the design documents in the ``docs/technical_references/profiles/``
Anton Komlev211aacf2020-11-02 12:48:11 +0000174directory.
Anton Komlevb8e3af02020-08-28 10:23:57 +0100175
176PSA test configuration
177----------------------
178
179PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The
180variable should be set to the name of the test suite that is desired. It is
181_not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``.
182
Jamie Fox19c91c22019-02-10 18:04:58 +0000183The Functional API tests are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100184 - ``CRYPTO``
185 - ``INITIAL_ATTESTATION``
186 - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE)
187 - ``INTERNAL_TRUSTED_STORAGE``
188 - ``PROTECTED_STORAGE``
189
Jamie Fox19c91c22019-02-10 18:04:58 +0000190The Firmware Framework test suites are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100191 - ``IPC``
192
193Note that these map directly to the ``SUITE`` cmake variable used in the
194psa-arch-tests documentation.
195
196Migration from legacy buildsystem
197---------------------------------
198
199The previous (legacy) cmake buildsystem made use of separate configuration
200files, where now build options are controlled by variables. For ease of
201transition, a table below is provided that maps the legacy files to the current
202variables, in the format of cmake command line parameters.
203
Summer Qin001ce9d2020-11-04 14:41:54 +0800204+------------------------------------------+---------------------------------------+
205| File | Cmake command line |
206+==========================================+=======================================+
207| ConfigDefault.cmake | <No options> |
208+------------------------------------------+---------------------------------------+
209| ConfigCoreIPC.cmake | -DTFM_PSA_API=ON |
210+------------------------------------------+---------------------------------------+
211| ConfigCoreIPCTfmLevel2.cmake | -DTFM_PSA_API=ON |
212| | -DTFM_ISOLATION_LEVEL=2 |
213+------------------------------------------+---------------------------------------+
214| ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small |
215+------------------------------------------+---------------------------------------+
216| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
217+------------------------------------------+---------------------------------------+
218| ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON |
219+------------------------------------------+---------------------------------------+
220| ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON |
221| | -DTFM_PSA_API=ON |
222+------------------------------------------+---------------------------------------+
223| ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON |
224| | -DTFM_PSA_API=ON |
225| | -DTFM_ISOLATION_LEVEL=2 |
226+------------------------------------------+---------------------------------------+
227| ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small |
228| | -DTEST_NS=ON -DTEST_S=ON |
229+------------------------------------------+---------------------------------------+
230| ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium |
231| | -DTEST_NS=ON -DTEST_S=ON |
232+------------------------------------------+---------------------------------------+
233| ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> |
234+------------------------------------------+---------------------------------------+
235| ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> |
236| | -DTFM_PSA_API=ON |
237+------------------------------------------+---------------------------------------+
238| ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> |
239| | -DTFM_PSA_API=ON |
240| | -DTFM_ISOLATION_LEVEL=2 |
241+------------------------------------------+---------------------------------------+
242| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
243| + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PROTECTED_STORAGE=OFF |
244+------------------------------------------+---------------------------------------+
Anton Komlevb8e3af02020-08-28 10:23:57 +0100245
246There has also been some changes to the PSA manifest file generation. The files
247are now generated into a seperate tree in the ``<tfm build dir>/generated``
248directory. Therefore they have been removed from the source tree. Any changes
249should be made only to the template files.
250
251The api for the ``tools/tfm_parse_manifest_list.py`` script has also changed
252slightly. It is no longer required to be run manually as it is run as part of
253cmake.
254
255*******************
256TF-M build examples
257*******************
258
259Example: building TF-M for AN521 platform using GCC:
260====================================================
261.. code-block:: bash
262
Leonardo Sandoval98350142021-02-03 16:32:14 -0600263 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100264 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100265 cmake --build cmake_build -- install
266
267Alternately using traditional cmake syntax
268
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200269.. code-block:: bash
270
Leonardo Sandoval98350142021-02-03 16:32:14 -0600271 cd <TF-M base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200272 mkdir cmake_build
273 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100274 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100275 make install
276
277.. Note::
278 Unix Makefiles is the default generator. Ninja is also supported by setting
279 -GNinja
280
281.. Note::
282
283 It is recommended to build each different build configuration in a separate
284 build directory.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200285
286Regression Tests for the AN521 target platform
287==============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100288
289Regression tests can be build by using the TEST_S and TEST_NS settings. Either
290can be used in isolation or both can be used to enable both suites. All tests
291for all enabled partitions are run, along with IPC and Multicore tests if those
292features are enabled.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200293
294.. code-block:: bash
295
Leonardo Sandoval98350142021-02-03 16:32:14 -0600296 cd <TF-M base folder>
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 Sandoval98350142021-02-03 16:32:14 -0600304 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100305 mkdir cmake_build
306 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100307 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100308 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200309
Jamie Fox19c91c22019-02-10 18:04:58 +0000310Build for PSA Functional API compliance tests
311=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100312The build system provides support for building and integrating the PSA API tests
313from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
314controlled using the TEST_PSA_API variable. Enabling both regression tests and
315PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200316
Anton Komlevb8e3af02020-08-28 10:23:57 +0100317The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200318
Anton Komlevb8e3af02020-08-28 10:23:57 +0100319.. code-block::
320
321 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
322 -DTEST_PSA_API=PROTECTED_STORAGE
323 -DTEST_PSA_API=STORAGE
324 -DTEST_PSA_API=CRYPTO
325 -DTEST_PSA_API=INITIAL_ATTESTATION
326
327Respectively for the corresponding service. For example, to enable the PSA API
328tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200329
330.. code-block:: bash
331
Leonardo Sandoval98350142021-02-03 16:32:14 -0600332 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100333 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 +0100334 cmake --build cmake_build -- install
335
336Alternately using traditional cmake syntax
337
338.. code-block:: bash
339
Leonardo Sandoval98350142021-02-03 16:32:14 -0600340 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100341 mkdir cmake_build
342 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100343 cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
Anton Komlevb8e3af02020-08-28 10:23:57 +0100344 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200345
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530346Build for PSA FF (IPC) compliance tests
347=======================================
348
Anton Komlevb8e3af02020-08-28 10:23:57 +0100349The build system provides support for building and integrating the PSA FF
350compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530351
Anton Komlevb8e3af02020-08-28 10:23:57 +0100352.. code-block::
353
354 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530355
356.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000357
Leonardo Sandoval98350142021-02-03 16:32:14 -0600358 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100359 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 +0100360 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530361
Anton Komlevb8e3af02020-08-28 10:23:57 +0100362Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530363
364.. code-block:: bash
365
Leonardo Sandoval98350142021-02-03 16:32:14 -0600366 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100367 mkdir cmake_build
368 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100369 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 +0100370 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530371
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200372Location of build artifacts
373===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200374
Anton Komlevb8e3af02020-08-28 10:23:57 +0100375All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
376**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200377
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200378
Anton Komlevb8e3af02020-08-28 10:23:57 +0100379For the purposes of maintaining compatibility with the legacy cmake build
380system, they are also provided in
381``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
382artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200383
384Building the documentation
385==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100386Please ensure the dependencies for building the documentation are installed
387as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
388requirements to build the firmware, are only required when using the CMAKE
389method
390
391There are currently two ways of building the documentation:
392- Using the CMake build system as custom targets
393- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
394
395Using the CMake build-system
396----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200397
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100398Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
399tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200400
401.. Note::
402 For building the documentation all tools needed to build the firmware must
403 be available.
404
405Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100406^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200407.. code-block:: bash
408
409 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100410 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100411 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200412
413The documentation files will be available under the directory::
414
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100415 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200416
417Building the User Guide
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>
Raef Coles69817322020-10-19 14:14:14 +0100422 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
Anton Komlevb8e3af02020-08-28 10:23:57 +0100423 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_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/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200428
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100429Manually using documentation generation tools
430---------------------------------------------
431
432Invoking Sphinx-build will build both user_guide and reference_manual
433targets.
434
435.. code-block:: bash
436
437 # Build the documentation from build_docs directory
Shawn Shanfdb47a02021-03-30 17:16:43 +0800438 cd <TF-M base folder>
439 mkdir build_docs
440 cp docs/conf.py build_docs/conf.py
441 cd build_docs
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100442 sphinx-build ./ user_guide
443
444 # Build the documentation from a custom location
445 # setting the build_docs as input
446
447 # Note that using this method will still generate the reference manual
448 # to the <TF-M base folder>/build_docs/reference_manual
449 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
450 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
451
Anton Komlevb8e3af02020-08-28 10:23:57 +0100452****************************
453Manual dependency management
454****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000455
Raef Coles1ecb8132020-10-02 15:11:24 +0100456The TF-M build system will by default fetch all dependencies with appropriate
457versions and store them inside the build tree. In this case, the build tree
458location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
459deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000460
Raef Coles1ecb8132020-10-02 15:11:24 +0100461If you have local copies already, and wish to avoid having the libraries
462downloaded every time the build directory is deleted, then the following
Raef Colesc630b882020-12-10 15:46:18 +0000463variables can be set to the path to the root directory of the local repo. This
464will disable the automatic downloading for that dependency.
Raef Coles1ecb8132020-10-02 15:11:24 +0100465
Raef Colesc630b882020-12-10 15:46:18 +0000466+----------------+---------------------+-----------------------------------------------------+
467| Dependency | Cmake variable | Git repo URL |
468+================+=====================+=====================================================+
469| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
470+----------------+---------------------+-----------------------------------------------------+
471| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
472+----------------+---------------------+-----------------------------------------------------+
473| MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot |
474+----------------+---------------------+-----------------------------------------------------+
475| psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests |
476+----------------+---------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000477
Anton Komlevb8e3af02020-08-28 10:23:57 +0100478For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000479
480.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100481 - Some patches are required to the mbedtls repo to allow building it as part of
482 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100483 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
484 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000485
Anton Komlevb8e3af02020-08-28 10:23:57 +0100486.. Note::
487 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
488 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800489
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100490.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
491.. _Doxygen: https://www.doxygen.nl
492
Kevin Pengcba37d32020-12-07 17:07:39 +0800493TF-M Tests
494==========
495
496Dependency auto downloading is used by default.
497The TF-M build system downloads the tf-m-tests repo with a fixed version
498specified by ``TFM_TEST_REPO_VERSION`` in ``config/config_default.cmake``.
499The version can be a release tag or a commit hash.
500
501Developers who want a different version of tf-m-tests can override
502``TFM_TEST_REPO_PATH`` to a local copy with the desired version.
503
504As the test repo is part of the TF-M project and coupled with TF-M repo a lot,
505The version should be updated when there are dependency changes between the TF-M
506repo and the test repo and when there is a complete change merged in test repo.
507
508A complete change is one or more patches that are for the same purpose, for
509example a new test suite or enhancements on the test cases.
510Patches in one change can be merge individually provided they do not break
511anything or cause any regressions.
512But the version in the TF-M gets updated only when all the patches are merged.
513
Raef Coles1ecb8132020-10-02 15:11:24 +0100514Example: building TF-M for AN521 platform with local Mbed Crypto
515================================================================
516
517Prepare Mbed Crypto repository
518------------------------------
519
520This is only required to be done once. For dependencies that do not have any
521``.patch`` files in their ``lib/ext`` directory the only required step is
522cloning the repo and checking out the correct branch.
523
524.. code-block:: bash
525
526 cd <Mbed Crypto base folder>
527 git clone https://github.com/ARMmbed/mbedtls
528 cd mbedtls
529 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
530 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
531
532.. Note::
533 - <Mbed Crypto base folder> does not need to have any fixed posisition related
534 to the TF-M repo.
535
536Build TF-M
537----------
538
539With new cmake syntax
540
541.. code-block:: bash
542
Leonardo Sandoval98350142021-02-03 16:32:14 -0600543 cd <TF-M base folder>
Raef Coles69817322020-10-19 14:14:14 +0100544 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 +0100545 cmake --build cmake_build -- install
546
547Alternately using traditional cmake syntax
548
549.. code-block:: bash
550
Leonardo Sandoval98350142021-02-03 16:32:14 -0600551 cd <TF-M base folder>
Raef Coles1ecb8132020-10-02 15:11:24 +0100552 mkdir cmake_build
553 cd cmake_build
Raef Coles69817322020-10-19 14:14:14 +0100554 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 +0100555 make install
556
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200557--------------
558
Summer Qinabf66982021-04-06 17:22:15 +0800559*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*