blob: bfc36ced6782de6a2ccd7df8e923f2c99919ceab [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
Minos Galanakise4094012020-06-12 14:25:34 +010030 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
165
166PSA test configuration
167----------------------
168
169PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The
170variable should be set to the name of the test suite that is desired. It is
171_not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``.
172
Jamie Fox19c91c22019-02-10 18:04:58 +0000173The Functional API tests are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100174 - ``CRYPTO``
175 - ``INITIAL_ATTESTATION``
176 - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE)
177 - ``INTERNAL_TRUSTED_STORAGE``
178 - ``PROTECTED_STORAGE``
179
Jamie Fox19c91c22019-02-10 18:04:58 +0000180The Firmware Framework test suites are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100181 - ``IPC``
182
183Note that these map directly to the ``SUITE`` cmake variable used in the
184psa-arch-tests documentation.
185
186Migration from legacy buildsystem
187---------------------------------
188
189The previous (legacy) cmake buildsystem made use of separate configuration
190files, where now build options are controlled by variables. For ease of
191transition, a table below is provided that maps the legacy files to the current
192variables, in the format of cmake command line parameters.
193
194+------------------------------------------+-----------------------------------+
195| File | Cmake command line |
196+==========================================+===================================+
197| ConfigDefault.cmake | <No options> |
198+------------------------------------------+-----------------------------------+
199| ConfigCoreIPC.cmake | -DTFM_PSA_API=ON |
200+------------------------------------------+-----------------------------------+
201| ConfigCoreIPCTfmLevel2.cmake | -DTFM_PSA_API=ON |
202| | -DTFM_ISOLATION_LEVEL=2 |
203+------------------------------------------+-----------------------------------+
204| ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small |
205+------------------------------------------+-----------------------------------+
206| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
207+------------------------------------------+-----------------------------------+
208| ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON |
209+------------------------------------------+-----------------------------------+
210| ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON |
211| | -DTFM_PSA_API=ON |
212+------------------------------------------+-----------------------------------+
213| ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON |
214| | -DTFM_PSA_API=ON |
215| | -DTFM_ISOLATION_LEVEL=2 |
216+------------------------------------------+-----------------------------------+
217| ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small |
218| | -DTEST_NS=ON -DTEST_S=ON |
219+------------------------------------------+-----------------------------------+
220| ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium |
221| | -DTEST_NS=ON -DTEST_S=ON |
222+------------------------------------------+-----------------------------------+
223| ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> |
224+------------------------------------------+-----------------------------------+
225| ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> |
226| | -DTFM_PSA_API=ON |
227+------------------------------------------+-----------------------------------+
228| ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> |
229| | -DTFM_PSA_API=ON |
230| | -DTFM_ISOLATION_LEVEL=2 |
231+------------------------------------------+-----------------------------------+
232| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
233| + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PS=OFF |
234+------------------------------------------+-----------------------------------+
235
236There has also been some changes to the PSA manifest file generation. The files
237are now generated into a seperate tree in the ``<tfm build dir>/generated``
238directory. Therefore they have been removed from the source tree. Any changes
239should be made only to the template files.
240
241The api for the ``tools/tfm_parse_manifest_list.py`` script has also changed
242slightly. It is no longer required to be run manually as it is run as part of
243cmake.
244
245*******************
246TF-M build examples
247*******************
248
249Example: building TF-M for AN521 platform using GCC:
250====================================================
251.. code-block:: bash
252
253 cd <base folder>
254 cd trusted-firmware-m
255 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
256 cmake --build cmake_build -- install
257
258Alternately using traditional cmake syntax
259
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200260.. code-block:: bash
261
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500262 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200263 cd trusted-firmware-m
264 mkdir cmake_build
265 cd cmake_build
Anton Komlevb8e3af02020-08-28 10:23:57 +0100266 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
267 make install
268
269.. Note::
270 Unix Makefiles is the default generator. Ninja is also supported by setting
271 -GNinja
272
273.. Note::
274
275 It is recommended to build each different build configuration in a separate
276 build directory.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200277
278Regression Tests for the AN521 target platform
279==============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100280
281Regression tests can be build by using the TEST_S and TEST_NS settings. Either
282can be used in isolation or both can be used to enable both suites. All tests
283for all enabled partitions are run, along with IPC and Multicore tests if those
284features are enabled.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200285
286.. code-block:: bash
287
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500288 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200289 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100290 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
291 cmake --build cmake_build -- install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200292
Anton Komlevb8e3af02020-08-28 10:23:57 +0100293Alternately using traditional cmake syntax
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200294
295.. code-block:: bash
296
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500297 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200298 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100299 mkdir cmake_build
300 cd cmake_build
301 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
302 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200303
Jamie Fox19c91c22019-02-10 18:04:58 +0000304Build for PSA Functional API compliance tests
305=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100306The build system provides support for building and integrating the PSA API tests
307from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
308controlled using the TEST_PSA_API variable. Enabling both regression tests and
309PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200310
Anton Komlevb8e3af02020-08-28 10:23:57 +0100311The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200312
Anton Komlevb8e3af02020-08-28 10:23:57 +0100313.. code-block::
314
315 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
316 -DTEST_PSA_API=PROTECTED_STORAGE
317 -DTEST_PSA_API=STORAGE
318 -DTEST_PSA_API=CRYPTO
319 -DTEST_PSA_API=INITIAL_ATTESTATION
320
321Respectively for the corresponding service. For example, to enable the PSA API
322tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200323
324.. code-block:: bash
325
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500326 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200327 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100328 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
329 cmake --build cmake_build -- install
330
331Alternately using traditional cmake syntax
332
333.. code-block:: bash
334
335 cd <base folder>
336 cd trusted-firmware-m
337 mkdir cmake_build
338 cd cmake_build
339 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
340 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200341
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530342Build for PSA FF (IPC) compliance tests
343=======================================
344
Anton Komlevb8e3af02020-08-28 10:23:57 +0100345The build system provides support for building and integrating the PSA FF
346compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530347
Anton Komlevb8e3af02020-08-28 10:23:57 +0100348.. code-block::
349
350 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530351
352.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000353
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500354 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530355 cd trusted-firmware-m
David Hu75bf7962020-10-20 16:44:28 +0800356 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 +0100357 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530358
Anton Komlevb8e3af02020-08-28 10:23:57 +0100359Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530360
361.. code-block:: bash
362
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500363 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530364 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100365 mkdir cmake_build
366 cd cmake_build
David Hu75bf7962020-10-20 16:44:28 +0800367 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 +0100368 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530369
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200370Location of build artifacts
371===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200372
Anton Komlevb8e3af02020-08-28 10:23:57 +0100373All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
374**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200375
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200376
Anton Komlevb8e3af02020-08-28 10:23:57 +0100377For the purposes of maintaining compatibility with the legacy cmake build
378system, they are also provided in
379``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
380artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200381
382Building the documentation
383==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100384Please ensure the dependencies for building the documentation are installed
385as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
386requirements to build the firmware, are only required when using the CMAKE
387method
388
389There are currently two ways of building the documentation:
390- Using the CMake build system as custom targets
391- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
392
393Using the CMake build-system
394----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200395
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100396Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
397tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200398
399.. Note::
400 For building the documentation all tools needed to build the firmware must
401 be available.
402
403Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100404^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200405.. code-block:: bash
406
407 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100408 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
409 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200410
411The documentation files will be available under the directory::
412
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100413 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200414
415Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100416^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200417.. code-block:: bash
418
419 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100420 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
421 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200422
423The documentation files will be available under the directory::
424
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100425 cmake_doc/docs/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200426
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100427Manually using documentation generation tools
428---------------------------------------------
429
430Invoking Sphinx-build will build both user_guide and reference_manual
431targets.
432
433.. code-block:: bash
434
435 # Build the documentation from build_docs directory
436 cd <TF-M base folder>/ build_docs/
437 sphinx-build ./ user_guide
438
439 # Build the documentation from a custom location
440 # setting the build_docs as input
441
442 # Note that using this method will still generate the reference manual
443 # to the <TF-M base folder>/build_docs/reference_manual
444 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
445 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
446
Anton Komlevb8e3af02020-08-28 10:23:57 +0100447****************************
448Manual dependency management
449****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000450
Raef Coles1ecb8132020-10-02 15:11:24 +0100451The TF-M build system will by default fetch all dependencies with appropriate
452versions and store them inside the build tree. In this case, the build tree
453location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
454deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000455
Raef Coles1ecb8132020-10-02 15:11:24 +0100456If you have local copies already, and wish to avoid having the libraries
457downloaded every time the build directory is deleted, then the following
458variables can be set to the paths to those local copies. This will disable the
459automatic downloading for that dependency.
460
461+----------------+--------------------+-----------------------------------------------------+
462| Dependency | Cmake variable | Git repo URL |
463+================+====================+=====================================================+
464| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
465+----------------+--------------------+-----------------------------------------------------+
466| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
467+----------------+--------------------+-----------------------------------------------------+
468| MCUboot | MCUBOOT_PATH | https://github.com/JuulLabs-OSS/mcuboot |
469+----------------+--------------------+-----------------------------------------------------+
470| psa-arch-tests | PSA_ARCH_TEST_PATH | https://github.com/ARM-software/psa-arch-tests |
471+----------------+--------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000472
Anton Komlevb8e3af02020-08-28 10:23:57 +0100473For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000474
475.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100476 - Some patches are required to the mbedtls repo to allow building it as part of
477 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100478 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
479 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000480
Anton Komlevb8e3af02020-08-28 10:23:57 +0100481.. Note::
482 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
483 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800484
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100485.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
486.. _Doxygen: https://www.doxygen.nl
487
Raef Coles1ecb8132020-10-02 15:11:24 +0100488Example: building TF-M for AN521 platform with local Mbed Crypto
489================================================================
490
491Prepare Mbed Crypto repository
492------------------------------
493
494This is only required to be done once. For dependencies that do not have any
495``.patch`` files in their ``lib/ext`` directory the only required step is
496cloning the repo and checking out the correct branch.
497
498.. code-block:: bash
499
500 cd <Mbed Crypto base folder>
501 git clone https://github.com/ARMmbed/mbedtls
502 cd mbedtls
503 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
504 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
505
506.. Note::
507 - <Mbed Crypto base folder> does not need to have any fixed posisition related
508 to the TF-M repo.
509
510Build TF-M
511----------
512
513With new cmake syntax
514
515.. code-block:: bash
516
517 cd <base folder>
518 cd trusted-firmware-m
519 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
520 cmake --build cmake_build -- install
521
522Alternately using traditional cmake syntax
523
524.. code-block:: bash
525
526 cd <base folder>
527 cd trusted-firmware-m
528 mkdir cmake_build
529 cd cmake_build
530 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
531 make install
532
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200533--------------
534
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000535*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*