blob: a2d4ad4004f77263447435273a6154a16efa20ea [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 Coles1ecb8132020-10-02 15:11:24 +010013Cmake version ``3.13.0`` or higher is supported, but version ``3.15.0`` or
14higher is required for ARMclang support.
15
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020016Getting the source-code
17=======================
18.. code-block:: bash
19
Leonardo Sandovald7f72d52020-07-28 18:02:34 -050020 cd <base folder>
Minos Galanakis0f39fa52020-06-08 16:53:53 +010021 git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
Anton Komlevb8e3af02020-08-28 10:23:57 +010022
23Dependency management is now handled by cmake. If you wish to alter this
24behaviour, see :ref:`docs/getting_started/tfm_build_instruction:Manual
25dependency management`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +020026
Minos Galanakisac6b06c2020-03-19 12:57:02 +000027.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +010028
29 - For building with Armclang compiler version 6.10.0, please follow the note
Anton Komlev211aacf2020-11-02 12:48:11 +000030 in :ref:`docs/getting_started/tfm_sw_requirement:External dependencies` section.
Anton Komlevb8e3af02020-08-28 10:23:57 +010031 - For building with the IAR toolchain, please see the notes in
TTornblomb9e5ed02020-02-13 16:53:15 +010032 :doc:`software requirements <tfm_build_instruction_iar>`
33
Anton Komlevb8e3af02020-08-28 10:23:57 +010034.. _tfm_cmake_configuration:
35
36Cmake configuration
37===================
38
39All configuration options are provided by cmake variables, and their default
40values, with docstrings, can be found in ``config/config_default.cmake``.
41
Soby Mathew7b7e1242020-10-07 13:31:56 +010042Configuration is provided in multiple stages, and each subsequent stage
43can override settings of the previous stage.
Anton Komlevb8e3af02020-08-28 10:23:57 +010044
45 1. ``config/config_default.cmake`` is loaded.
Soby Mathew7b7e1242020-10-07 13:31:56 +010046 2. Command-line variable settings are applied.
47 3. If it exists, CMAKE_BUILD_TYPE specific config is applied from
48 ``config/build_type/<build_type>.cmake``.
49 4. If TEST_PSA_TEST is set, then PSA API test related config is applied from
50 ``config/tests/config_test_psa_api.cmake``.
51 5. If it exists, TFM Profile specific config is applied from
52 ``config/profile/<tfm_profile>.cmake``.
53 6. Target specific config from ``platform/ext/target/<target_platform>/config.cmake``
54 is applied.
55 7. If CRYPTO_HW_ACCELERATOR is set, then a config specific to the
56 accelerator type is applied if it exists.
57 8. If the ``TFM_EXTRA_CONFIG_PATH`` variable has been set, that file is
58 loaded.
Anton Komlevb8e3af02020-08-28 10:23:57 +010059
60.. Warning::
61 This means that command-line settings are not applied when they conflict
62 with required platform settings. If it is required to override platform
63 settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be
64 used.
65
66Required cmake parameters for building TF-M
67-------------------------------------------
68
69+----------------------+-------------------------------------------------------+
70| Parameter | Description |
71+======================+=======================================================+
72| TFM_PLATFORM | The target platform as a path from the base directory |
73| | ``/platform/ext/target`` |
74+----------------------+-------------------------------------------------------+
75| CMAKE_TOOLCHAIN_FILE | The path to the toolchain file that corresponds to |
76| | the desired compiler. |
77+----------------------+-------------------------------------------------------+
78
79By default release configuration builds. Alternate build types can be controlled
80by the CMAKE_BUILD_TYPE variable.
81
82Build type
83----------
84
85Build type is controlled by the ``CMAKE_BUILD_TYPE`` variable. The possible
86types are:
87
88 - ``Debug``
89 - ``Relwithdebinfo``
90 - ``Release``
91 - ``Minsizerel``
92
93``Release`` is default.
94
95Both ``Debug`` and ``Relwithdebinfo`` will include debug symbols in the output
96files. ``Relwithdebinfo``, ``Release`` and ``Minsizerel`` have optimization
Raef Coles1ecb8132020-10-02 15:11:24 +010097turned on and hence will produce smaller, faster code. ``Minsizerel`` will
Anton Komlevb8e3af02020-08-28 10:23:57 +010098produce the smallest code, and hence is often a good idea on RAM or flash
99constrained systems.
100
101Other cmake parameters
102----------------------
103
104The full list of default options is in ``config/config_default.cmake``. Several
105important options are listed below.
106
107
108+---------------------+----------------------------------------+---------------+
109| Parameter | Description | Default value |
110+=====================+========================================+===============+
111| BL2 | Build level 2 secure bootloader. | ON |
112+---------------------+----------------------------------------+---------------+
113| NS | Build NS app. Required for test code. | ON |
114+---------------------+----------------------------------------+---------------+
115| TFM_PSA_API | Use PSA api (IPC mode) instead of | OFF |
116| | secure library mode. | |
117+---------------------+----------------------------------------+---------------+
118| TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 |
119+---------------------+----------------------------------------+---------------+
120| TFM_PROFILE | Set TFM profile. | |
121+---------------------+----------------------------------------+---------------+
122| TEST_S | Build secure regression tests. | OFF |
123+---------------------+----------------------------------------+---------------+
124| TEST_NS | Build non-secure regression tests. | OFF |
125+---------------------+----------------------------------------+---------------+
126| TEST_PSA_API | Build PSA API TESTS for the given | |
127| | suite. Takes a PSA api ``SUITE`` as an | |
128| | argument (``CRYPTO`` etc). | |
129+---------------------+----------------------------------------+---------------+
130
131Regression test configuration
132-----------------------------
133
134Regression test configuration is controlled entirely by the ``TEST_S`` and
135``TEST_NS`` cmake variables.
136
137If regression testing is enabled, it will then enable all tests for the enabled
138secure partitions. If IPC mode is enabled via ``TFM_PSA_API`` the IPC tests will
139be enabled. QCBOR and T_COSE tests are linked to the Initial Attestation
140partition, as they are only used there. Multicore tests will be enabled if
141``TFM_MULTI_CORE_TOPOLOGY`` is enabled.
142
143Some cryptographic tests can be enabled and disabled. This is done to prevent
144false failures from being reported when a smaller Mbed Crypto config is being
145used which does not support all features.
146
147+-----------------------------+-------------------------------------+---------------+
148| Parameter | Description | Default value |
149+=============================+=====================================+===============+
150| TFM_CRYPTO_TEST_ALG_CBC | Test CBC cryptography mode | ON |
151+-----------------------------+-------------------------------------+---------------+
152| TFM_CRYPTO_TEST_ALG_CCM | Test CCM cryptography mode | ON |
153+-----------------------------+-------------------------------------+---------------+
154| TFM_CRYPTO_TEST_ALG_CFB | Test CFB cryptography mode | ON |
155+-----------------------------+-------------------------------------+---------------+
156| TFM_CRYPTO_TEST_ALG_CTR | Test CTR cryptography mode | ON |
157+-----------------------------+-------------------------------------+---------------+
158| TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON |
159+-----------------------------+-------------------------------------+---------------+
160| TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON |
161+-----------------------------+-------------------------------------+---------------+
162| TFM_CRYPTO_TEST_HKDF | Test SHA-512 cryptography algorithm | ON |
163+-----------------------------+-------------------------------------+---------------+
164
Anton Komlev211aacf2020-11-02 12:48:11 +0000165TF-M Profiles
166-------------
167
168TF-M Profiles are implemented as a single cmake configuration file, under the
169``config/profile`` directory. A good understanding can be gained quickly by
170looking at the Profile configuration files, but the ultimate reference for
171Profiles are the design documents in the ``docs/design_documents/profiles/``
172directory.
Anton Komlevb8e3af02020-08-28 10:23:57 +0100173
174PSA test configuration
175----------------------
176
177PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The
178variable should be set to the name of the test suite that is desired. It is
179_not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``.
180
Jamie Fox19c91c22019-02-10 18:04:58 +0000181The Functional API tests are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100182 - ``CRYPTO``
183 - ``INITIAL_ATTESTATION``
184 - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE)
185 - ``INTERNAL_TRUSTED_STORAGE``
186 - ``PROTECTED_STORAGE``
187
Jamie Fox19c91c22019-02-10 18:04:58 +0000188The Firmware Framework test suites are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100189 - ``IPC``
190
191Note that these map directly to the ``SUITE`` cmake variable used in the
192psa-arch-tests documentation.
193
194Migration from legacy buildsystem
195---------------------------------
196
197The previous (legacy) cmake buildsystem made use of separate configuration
198files, where now build options are controlled by variables. For ease of
199transition, a table below is provided that maps the legacy files to the current
200variables, in the format of cmake command line parameters.
201
202+------------------------------------------+-----------------------------------+
203| File | Cmake command line |
204+==========================================+===================================+
205| ConfigDefault.cmake | <No options> |
206+------------------------------------------+-----------------------------------+
207| ConfigCoreIPC.cmake | -DTFM_PSA_API=ON |
208+------------------------------------------+-----------------------------------+
209| ConfigCoreIPCTfmLevel2.cmake | -DTFM_PSA_API=ON |
210| | -DTFM_ISOLATION_LEVEL=2 |
211+------------------------------------------+-----------------------------------+
212| ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small |
213+------------------------------------------+-----------------------------------+
214| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
215+------------------------------------------+-----------------------------------+
216| ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON |
217+------------------------------------------+-----------------------------------+
218| ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON |
219| | -DTFM_PSA_API=ON |
220+------------------------------------------+-----------------------------------+
221| ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON |
222| | -DTFM_PSA_API=ON |
223| | -DTFM_ISOLATION_LEVEL=2 |
224+------------------------------------------+-----------------------------------+
225| ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small |
226| | -DTEST_NS=ON -DTEST_S=ON |
227+------------------------------------------+-----------------------------------+
228| ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium |
229| | -DTEST_NS=ON -DTEST_S=ON |
230+------------------------------------------+-----------------------------------+
231| ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> |
232+------------------------------------------+-----------------------------------+
233| ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> |
234| | -DTFM_PSA_API=ON |
235+------------------------------------------+-----------------------------------+
236| ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> |
237| | -DTFM_PSA_API=ON |
238| | -DTFM_ISOLATION_LEVEL=2 |
239+------------------------------------------+-----------------------------------+
240| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
241| + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PS=OFF |
242+------------------------------------------+-----------------------------------+
243
244There has also been some changes to the PSA manifest file generation. The files
245are now generated into a seperate tree in the ``<tfm build dir>/generated``
246directory. Therefore they have been removed from the source tree. Any changes
247should be made only to the template files.
248
249The api for the ``tools/tfm_parse_manifest_list.py`` script has also changed
250slightly. It is no longer required to be run manually as it is run as part of
251cmake.
252
253*******************
254TF-M build examples
255*******************
256
257Example: building TF-M for AN521 platform using GCC:
258====================================================
259.. code-block:: bash
260
261 cd <base folder>
262 cd trusted-firmware-m
263 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
264 cmake --build cmake_build -- install
265
266Alternately using traditional cmake syntax
267
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200268.. code-block:: bash
269
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500270 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200271 cd trusted-firmware-m
272 mkdir cmake_build
273 cd cmake_build
Anton Komlevb8e3af02020-08-28 10:23:57 +0100274 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
275 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 Sandovald7f72d52020-07-28 18:02:34 -0500296 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200297 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100298 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
299 cmake --build cmake_build -- install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200300
Anton Komlevb8e3af02020-08-28 10:23:57 +0100301Alternately using traditional cmake syntax
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200302
303.. code-block:: bash
304
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500305 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200306 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100307 mkdir cmake_build
308 cd cmake_build
309 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
310 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200311
Jamie Fox19c91c22019-02-10 18:04:58 +0000312Build for PSA Functional API compliance tests
313=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100314The build system provides support for building and integrating the PSA API tests
315from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
316controlled using the TEST_PSA_API variable. Enabling both regression tests and
317PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200318
Anton Komlevb8e3af02020-08-28 10:23:57 +0100319The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200320
Anton Komlevb8e3af02020-08-28 10:23:57 +0100321.. code-block::
322
323 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
324 -DTEST_PSA_API=PROTECTED_STORAGE
325 -DTEST_PSA_API=STORAGE
326 -DTEST_PSA_API=CRYPTO
327 -DTEST_PSA_API=INITIAL_ATTESTATION
328
329Respectively for the corresponding service. For example, to enable the PSA API
330tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200331
332.. code-block:: bash
333
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500334 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200335 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100336 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
337 cmake --build cmake_build -- install
338
339Alternately using traditional cmake syntax
340
341.. code-block:: bash
342
343 cd <base folder>
344 cd trusted-firmware-m
345 mkdir cmake_build
346 cd cmake_build
347 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
348 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200349
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530350Build for PSA FF (IPC) compliance tests
351=======================================
352
Anton Komlevb8e3af02020-08-28 10:23:57 +0100353The build system provides support for building and integrating the PSA FF
354compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530355
Anton Komlevb8e3af02020-08-28 10:23:57 +0100356.. code-block::
357
358 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530359
360.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000361
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500362 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530363 cd trusted-firmware-m
Anton Komlev211aacf2020-11-02 12:48:11 +0000364 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100365 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530366
Anton Komlevb8e3af02020-08-28 10:23:57 +0100367Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530368
369.. code-block:: bash
370
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500371 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530372 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100373 mkdir cmake_build
374 cd cmake_build
Anton Komlev211aacf2020-11-02 12:48:11 +0000375 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=IPC -DTFM_PSA_API=ON
Anton Komlevb8e3af02020-08-28 10:23:57 +0100376 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530377
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200378Location of build artifacts
379===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200380
Anton Komlevb8e3af02020-08-28 10:23:57 +0100381All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
382**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200383
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200384
Anton Komlevb8e3af02020-08-28 10:23:57 +0100385For the purposes of maintaining compatibility with the legacy cmake build
386system, they are also provided in
387``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
388artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200389
390Building the documentation
391==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100392Please ensure the dependencies for building the documentation are installed
393as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
394requirements to build the firmware, are only required when using the CMAKE
395method
396
397There are currently two ways of building the documentation:
398- Using the CMake build system as custom targets
399- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
400
401Using the CMake build-system
402----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200403
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100404Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
405tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200406
407.. Note::
408 For building the documentation all tools needed to build the firmware must
409 be available.
410
411Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100412^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200413.. code-block:: bash
414
415 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100416 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
417 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200418
419The documentation files will be available under the directory::
420
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100421 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200422
423Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100424^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200425.. code-block:: bash
426
427 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100428 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
429 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200430
431The documentation files will be available under the directory::
432
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100433 cmake_doc/docs/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200434
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100435Manually using documentation generation tools
436---------------------------------------------
437
438Invoking Sphinx-build will build both user_guide and reference_manual
439targets.
440
441.. code-block:: bash
442
443 # Build the documentation from build_docs directory
444 cd <TF-M base folder>/ build_docs/
445 sphinx-build ./ user_guide
446
447 # Build the documentation from a custom location
448 # setting the build_docs as input
449
450 # Note that using this method will still generate the reference manual
451 # to the <TF-M base folder>/build_docs/reference_manual
452 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
453 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
454
Anton Komlevb8e3af02020-08-28 10:23:57 +0100455****************************
456Manual dependency management
457****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000458
Raef Coles1ecb8132020-10-02 15:11:24 +0100459The TF-M build system will by default fetch all dependencies with appropriate
460versions and store them inside the build tree. In this case, the build tree
461location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
462deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000463
Raef Coles1ecb8132020-10-02 15:11:24 +0100464If you have local copies already, and wish to avoid having the libraries
465downloaded every time the build directory is deleted, then the following
466variables can be set to the paths to those local copies. This will disable the
467automatic downloading for that dependency.
468
469+----------------+--------------------+-----------------------------------------------------+
470| Dependency | Cmake variable | Git repo URL |
471+================+====================+=====================================================+
472| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
473+----------------+--------------------+-----------------------------------------------------+
474| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
475+----------------+--------------------+-----------------------------------------------------+
476| MCUboot | MCUBOOT_PATH | https://github.com/JuulLabs-OSS/mcuboot |
477+----------------+--------------------+-----------------------------------------------------+
478| psa-arch-tests | PSA_ARCH_TEST_PATH | https://github.com/ARM-software/psa-arch-tests |
479+----------------+--------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000480
Anton Komlevb8e3af02020-08-28 10:23:57 +0100481For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000482
483.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100484 - Some patches are required to the mbedtls repo to allow building it as part of
485 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100486 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
487 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000488
Anton Komlevb8e3af02020-08-28 10:23:57 +0100489.. Note::
490 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
491 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800492
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100493.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
494.. _Doxygen: https://www.doxygen.nl
495
Raef Coles1ecb8132020-10-02 15:11:24 +0100496Example: building TF-M for AN521 platform with local Mbed Crypto
497================================================================
498
499Prepare Mbed Crypto repository
500------------------------------
501
502This is only required to be done once. For dependencies that do not have any
503``.patch`` files in their ``lib/ext`` directory the only required step is
504cloning the repo and checking out the correct branch.
505
506.. code-block:: bash
507
508 cd <Mbed Crypto base folder>
509 git clone https://github.com/ARMmbed/mbedtls
510 cd mbedtls
511 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
512 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
513
514.. Note::
515 - <Mbed Crypto base folder> does not need to have any fixed posisition related
516 to the TF-M repo.
517
518Build TF-M
519----------
520
521With new cmake syntax
522
523.. code-block:: bash
524
525 cd <base folder>
526 cd trusted-firmware-m
527 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
528 cmake --build cmake_build -- install
529
530Alternately using traditional cmake syntax
531
532.. code-block:: bash
533
534 cd <base folder>
535 cd trusted-firmware-m
536 mkdir cmake_build
537 cd cmake_build
538 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
539 make install
540
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200541--------------
542
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000543*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*