blob: 5410fad20131e788c876eb85495db57e7b8e38c6 [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
42Configuration is provided in multiple stages, with multiple priorities.
43
44 1. ``config/config_default.cmake`` is loaded.
45 2. Command-line variable settings are applied, overriding all previous settings.
46 3. If it exists, CMAKE_BUILD_TYPE specific config is applied from ``config/build_type/<build_type>.cmake``, overriding all previous settings.
47 4. If it exists, TFM Profile specific config is applied from ``config/profile/<tfm_profile>.cmake``, overriding all previous settings.
48 5. Target specific config from ``platform/ext/target/<target_platform>/config.cmake`` is applied, overriding all previous settings.
49 6. If the ``TFM_EXTRA_CONFIG_PATH`` variable has been set, that file is loaded and overrides all previous settings.
50
51.. Warning::
52 This means that command-line settings are not applied when they conflict
53 with required platform settings. If it is required to override platform
54 settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be
55 used.
56
57Required cmake parameters for building TF-M
58-------------------------------------------
59
60+----------------------+-------------------------------------------------------+
61| Parameter | Description |
62+======================+=======================================================+
63| TFM_PLATFORM | The target platform as a path from the base directory |
64| | ``/platform/ext/target`` |
65+----------------------+-------------------------------------------------------+
66| CMAKE_TOOLCHAIN_FILE | The path to the toolchain file that corresponds to |
67| | the desired compiler. |
68+----------------------+-------------------------------------------------------+
69
70By default release configuration builds. Alternate build types can be controlled
71by the CMAKE_BUILD_TYPE variable.
72
73Build type
74----------
75
76Build type is controlled by the ``CMAKE_BUILD_TYPE`` variable. The possible
77types are:
78
79 - ``Debug``
80 - ``Relwithdebinfo``
81 - ``Release``
82 - ``Minsizerel``
83
84``Release`` is default.
85
86Both ``Debug`` and ``Relwithdebinfo`` will include debug symbols in the output
87files. ``Relwithdebinfo``, ``Release`` and ``Minsizerel`` have optimization
Raef Coles1ecb8132020-10-02 15:11:24 +010088turned on and hence will produce smaller, faster code. ``Minsizerel`` will
Anton Komlevb8e3af02020-08-28 10:23:57 +010089produce the smallest code, and hence is often a good idea on RAM or flash
90constrained systems.
91
92Other cmake parameters
93----------------------
94
95The full list of default options is in ``config/config_default.cmake``. Several
96important options are listed below.
97
98
99+---------------------+----------------------------------------+---------------+
100| Parameter | Description | Default value |
101+=====================+========================================+===============+
102| BL2 | Build level 2 secure bootloader. | ON |
103+---------------------+----------------------------------------+---------------+
104| NS | Build NS app. Required for test code. | ON |
105+---------------------+----------------------------------------+---------------+
106| TFM_PSA_API | Use PSA api (IPC mode) instead of | OFF |
107| | secure library mode. | |
108+---------------------+----------------------------------------+---------------+
109| TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 |
110+---------------------+----------------------------------------+---------------+
111| TFM_PROFILE | Set TFM profile. | |
112+---------------------+----------------------------------------+---------------+
113| TEST_S | Build secure regression tests. | OFF |
114+---------------------+----------------------------------------+---------------+
115| TEST_NS | Build non-secure regression tests. | OFF |
116+---------------------+----------------------------------------+---------------+
117| TEST_PSA_API | Build PSA API TESTS for the given | |
118| | suite. Takes a PSA api ``SUITE`` as an | |
119| | argument (``CRYPTO`` etc). | |
120+---------------------+----------------------------------------+---------------+
121
122Regression test configuration
123-----------------------------
124
125Regression test configuration is controlled entirely by the ``TEST_S`` and
126``TEST_NS`` cmake variables.
127
128If regression testing is enabled, it will then enable all tests for the enabled
129secure partitions. If IPC mode is enabled via ``TFM_PSA_API`` the IPC tests will
130be enabled. QCBOR and T_COSE tests are linked to the Initial Attestation
131partition, as they are only used there. Multicore tests will be enabled if
132``TFM_MULTI_CORE_TOPOLOGY`` is enabled.
133
134Some cryptographic tests can be enabled and disabled. This is done to prevent
135false failures from being reported when a smaller Mbed Crypto config is being
136used which does not support all features.
137
138+-----------------------------+-------------------------------------+---------------+
139| Parameter | Description | Default value |
140+=============================+=====================================+===============+
141| TFM_CRYPTO_TEST_ALG_CBC | Test CBC cryptography mode | ON |
142+-----------------------------+-------------------------------------+---------------+
143| TFM_CRYPTO_TEST_ALG_CCM | Test CCM cryptography mode | ON |
144+-----------------------------+-------------------------------------+---------------+
145| TFM_CRYPTO_TEST_ALG_CFB | Test CFB cryptography mode | ON |
146+-----------------------------+-------------------------------------+---------------+
147| TFM_CRYPTO_TEST_ALG_CTR | Test CTR cryptography mode | ON |
148+-----------------------------+-------------------------------------+---------------+
149| TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON |
150+-----------------------------+-------------------------------------+---------------+
151| TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON |
152+-----------------------------+-------------------------------------+---------------+
153| TFM_CRYPTO_TEST_HKDF | Test SHA-512 cryptography algorithm | ON |
154+-----------------------------+-------------------------------------+---------------+
155
156
157PSA test configuration
158----------------------
159
160PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The
161variable should be set to the name of the test suite that is desired. It is
162_not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``.
163
Jamie Fox19c91c22019-02-10 18:04:58 +0000164The Functional API tests are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100165 - ``CRYPTO``
166 - ``INITIAL_ATTESTATION``
167 - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE)
168 - ``INTERNAL_TRUSTED_STORAGE``
169 - ``PROTECTED_STORAGE``
170
Jamie Fox19c91c22019-02-10 18:04:58 +0000171The Firmware Framework test suites are:
Anton Komlevb8e3af02020-08-28 10:23:57 +0100172 - ``IPC``
173
174Note that these map directly to the ``SUITE`` cmake variable used in the
175psa-arch-tests documentation.
176
177Migration from legacy buildsystem
178---------------------------------
179
180The previous (legacy) cmake buildsystem made use of separate configuration
181files, where now build options are controlled by variables. For ease of
182transition, a table below is provided that maps the legacy files to the current
183variables, in the format of cmake command line parameters.
184
185+------------------------------------------+-----------------------------------+
186| File | Cmake command line |
187+==========================================+===================================+
188| ConfigDefault.cmake | <No options> |
189+------------------------------------------+-----------------------------------+
190| ConfigCoreIPC.cmake | -DTFM_PSA_API=ON |
191+------------------------------------------+-----------------------------------+
192| ConfigCoreIPCTfmLevel2.cmake | -DTFM_PSA_API=ON |
193| | -DTFM_ISOLATION_LEVEL=2 |
194+------------------------------------------+-----------------------------------+
195| ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small |
196+------------------------------------------+-----------------------------------+
197| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
198+------------------------------------------+-----------------------------------+
199| ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON |
200+------------------------------------------+-----------------------------------+
201| ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON |
202| | -DTFM_PSA_API=ON |
203+------------------------------------------+-----------------------------------+
204| ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON |
205| | -DTFM_PSA_API=ON |
206| | -DTFM_ISOLATION_LEVEL=2 |
207+------------------------------------------+-----------------------------------+
208| ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small |
209| | -DTEST_NS=ON -DTEST_S=ON |
210+------------------------------------------+-----------------------------------+
211| ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium |
212| | -DTEST_NS=ON -DTEST_S=ON |
213+------------------------------------------+-----------------------------------+
214| ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> |
215+------------------------------------------+-----------------------------------+
216| ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> |
217| | -DTFM_PSA_API=ON |
218+------------------------------------------+-----------------------------------+
219| ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> |
220| | -DTFM_PSA_API=ON |
221| | -DTFM_ISOLATION_LEVEL=2 |
222+------------------------------------------+-----------------------------------+
223| ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium |
224| + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PS=OFF |
225+------------------------------------------+-----------------------------------+
226
227There has also been some changes to the PSA manifest file generation. The files
228are now generated into a seperate tree in the ``<tfm build dir>/generated``
229directory. Therefore they have been removed from the source tree. Any changes
230should be made only to the template files.
231
232The api for the ``tools/tfm_parse_manifest_list.py`` script has also changed
233slightly. It is no longer required to be run manually as it is run as part of
234cmake.
235
236*******************
237TF-M build examples
238*******************
239
240Example: building TF-M for AN521 platform using GCC:
241====================================================
242.. code-block:: bash
243
244 cd <base folder>
245 cd trusted-firmware-m
246 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
247 cmake --build cmake_build -- install
248
249Alternately using traditional cmake syntax
250
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200251.. code-block:: bash
252
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500253 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200254 cd trusted-firmware-m
255 mkdir cmake_build
256 cd cmake_build
Anton Komlevb8e3af02020-08-28 10:23:57 +0100257 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake
258 make install
259
260.. Note::
261 Unix Makefiles is the default generator. Ninja is also supported by setting
262 -GNinja
263
264.. Note::
265
266 It is recommended to build each different build configuration in a separate
267 build directory.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200268
269Regression Tests for the AN521 target platform
270==============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100271
272Regression tests can be build by using the TEST_S and TEST_NS settings. Either
273can be used in isolation or both can be used to enable both suites. All tests
274for all enabled partitions are run, along with IPC and Multicore tests if those
275features are enabled.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200276
277.. code-block:: bash
278
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500279 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200280 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100281 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
282 cmake --build cmake_build -- install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200283
Anton Komlevb8e3af02020-08-28 10:23:57 +0100284Alternately using traditional cmake syntax
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 mkdir cmake_build
291 cd cmake_build
292 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
293 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200294
Jamie Fox19c91c22019-02-10 18:04:58 +0000295Build for PSA Functional API compliance tests
296=============================================
Anton Komlevb8e3af02020-08-28 10:23:57 +0100297The build system provides support for building and integrating the PSA API tests
298from https://github.com/ARM-software/psa-arch-tests. PSA API tests are
299controlled using the TEST_PSA_API variable. Enabling both regression tests and
300PSA API tests simultaneously is **not** supported.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200301
Anton Komlevb8e3af02020-08-28 10:23:57 +0100302The value of the TEST_PSA_API variable is the suite to be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200303
Anton Komlevb8e3af02020-08-28 10:23:57 +0100304.. code-block::
305
306 -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE
307 -DTEST_PSA_API=PROTECTED_STORAGE
308 -DTEST_PSA_API=STORAGE
309 -DTEST_PSA_API=CRYPTO
310 -DTEST_PSA_API=INITIAL_ATTESTATION
311
312Respectively for the corresponding service. For example, to enable the PSA API
313tests for the Crypto service:
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200314
315.. code-block:: bash
316
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500317 cd <base folder>
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200318 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100319 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
320 cmake --build cmake_build -- install
321
322Alternately using traditional cmake syntax
323
324.. code-block:: bash
325
326 cd <base folder>
327 cd trusted-firmware-m
328 mkdir cmake_build
329 cd cmake_build
330 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=CRYPTO
331 make install
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200332
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530333Build for PSA FF (IPC) compliance tests
334=======================================
335
Anton Komlevb8e3af02020-08-28 10:23:57 +0100336The build system provides support for building and integrating the PSA FF
337compliance test. This support is controlled by the TEST_PSA_API variable:
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530338
Anton Komlevb8e3af02020-08-28 10:23:57 +0100339.. code-block::
340
341 -DTEST_PSA_API=IPC
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530342
343.. code-block:: bash
Minos Galanakisfc6804e2020-03-10 11:03:34 +0000344
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500345 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530346 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100347 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DTEST_PSA_API=IPC
348 cmake --build cmake_build -- install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530349
Anton Komlevb8e3af02020-08-28 10:23:57 +0100350Alternately using traditional cmake syntax
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530351
352.. code-block:: bash
353
Leonardo Sandovald7f72d52020-07-28 18:02:34 -0500354 cd <base folder>
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530355 cd trusted-firmware-m
Anton Komlevb8e3af02020-08-28 10:23:57 +0100356 mkdir cmake_build
357 cd cmake_build
358 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_PSA_API=IPC
359 make install
Jaykumar Pitambarbhai Patel6891b8b2020-01-23 14:32:20 +0530360
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200361Location of build artifacts
362===========================
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200363
Anton Komlevb8e3af02020-08-28 10:23:57 +0100364All build artifacts are provided in the ``<build_dir>/bin`` directory. It is
365**not** required to run ``make install`` to generate artifacts in this location.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200366
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200367
Anton Komlevb8e3af02020-08-28 10:23:57 +0100368For the purposes of maintaining compatibility with the legacy cmake build
369system, they are also provided in
370``<build_dir>/install/outputs/<target_platform>/``. In order to generate the
371artifacts in this location ``make install`` must be run.
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200372
373Building the documentation
374==========================
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100375Please ensure the dependencies for building the documentation are installed
376as explained in the :doc:`software requirements <tfm_sw_requirement>`. The
377requirements to build the firmware, are only required when using the CMAKE
378method
379
380There are currently two ways of building the documentation:
381- Using the CMake build system as custom targets
382- Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_)
383
384Using the CMake build-system
385----------------------------
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200386
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100387Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/
388tfm_docs_userguide_pdf`
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200389
390.. Note::
391 For building the documentation all tools needed to build the firmware must
392 be available.
393
394Building the Reference Manual
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100395^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200396.. code-block:: bash
397
398 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100399 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
400 cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200401
402The documentation files will be available under the directory::
403
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100404 cmake_doc/docs/reference_manual
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200405
406Building the User Guide
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100407^^^^^^^^^^^^^^^^^^^^^^^
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200408.. code-block:: bash
409
410 cd <TF-M base folder>
Anton Komlevb8e3af02020-08-28 10:23:57 +0100411 cmake -S . -B cmake_doc -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake
412 cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200413
414The documentation files will be available under the directory::
415
Minos Galanakisdff2eae2020-07-21 15:13:52 +0100416 cmake_doc/docs/user_guide
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200417
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100418Manually using documentation generation tools
419---------------------------------------------
420
421Invoking Sphinx-build will build both user_guide and reference_manual
422targets.
423
424.. code-block:: bash
425
426 # Build the documentation from build_docs directory
427 cd <TF-M base folder>/ build_docs/
428 sphinx-build ./ user_guide
429
430 # Build the documentation from a custom location
431 # setting the build_docs as input
432
433 # Note that using this method will still generate the reference manual
434 # to the <TF-M base folder>/build_docs/reference_manual
435 cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2
436 sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR
437
Anton Komlevb8e3af02020-08-28 10:23:57 +0100438****************************
439Manual dependency management
440****************************
Galanakis, Minos757139a2019-11-11 15:00:11 +0000441
Raef Coles1ecb8132020-10-02 15:11:24 +0100442The TF-M build system will by default fetch all dependencies with appropriate
443versions and store them inside the build tree. In this case, the build tree
444location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by
445deleting that directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000446
Raef Coles1ecb8132020-10-02 15:11:24 +0100447If you have local copies already, and wish to avoid having the libraries
448downloaded every time the build directory is deleted, then the following
449variables can be set to the paths to those local copies. This will disable the
450automatic downloading for that dependency.
451
452+----------------+--------------------+-----------------------------------------------------+
453| Dependency | Cmake variable | Git repo URL |
454+================+====================+=====================================================+
455| Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls |
456+----------------+--------------------+-----------------------------------------------------+
457| tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git |
458+----------------+--------------------+-----------------------------------------------------+
459| MCUboot | MCUBOOT_PATH | https://github.com/JuulLabs-OSS/mcuboot |
460+----------------+--------------------+-----------------------------------------------------+
461| psa-arch-tests | PSA_ARCH_TEST_PATH | https://github.com/ARM-software/psa-arch-tests |
462+----------------+--------------------+-----------------------------------------------------+
Galanakis, Minos757139a2019-11-11 15:00:11 +0000463
Anton Komlevb8e3af02020-08-28 10:23:57 +0100464For required versions of the dependencies, refer to ``config/config_default.cmake``.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000465
466.. Note::
Anton Komlevb8e3af02020-08-28 10:23:57 +0100467 - Some patches are required to the mbedtls repo to allow building it as part of
468 TF-M. While these patches are being upstreamed they are stored in
Raef Coles1ecb8132020-10-02 15:11:24 +0100469 ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is
470 required to apply all patch files in this directory.
Galanakis, Minos757139a2019-11-11 15:00:11 +0000471
Anton Komlevb8e3af02020-08-28 10:23:57 +0100472.. Note::
473 - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different
474 source for CMSIS 5, it can be configured using CMSIS_5_PATH.
David Hu2cbf5df2020-06-15 10:41:44 +0800475
Minos Galanakisd19a19f2020-06-03 15:38:03 +0100476.. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html
477.. _Doxygen: https://www.doxygen.nl
478
Raef Coles1ecb8132020-10-02 15:11:24 +0100479Example: building TF-M for AN521 platform with local Mbed Crypto
480================================================================
481
482Prepare Mbed Crypto repository
483------------------------------
484
485This is only required to be done once. For dependencies that do not have any
486``.patch`` files in their ``lib/ext`` directory the only required step is
487cloning the repo and checking out the correct branch.
488
489.. code-block:: bash
490
491 cd <Mbed Crypto base folder>
492 git clone https://github.com/ARMmbed/mbedtls
493 cd mbedtls
494 git checkout <MBEDCRYPTO_VERSION from config_default.cmake>
495 git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch
496
497.. Note::
498 - <Mbed Crypto base folder> does not need to have any fixed posisition related
499 to the TF-M repo.
500
501Build TF-M
502----------
503
504With new cmake syntax
505
506.. code-block:: bash
507
508 cd <base folder>
509 cd trusted-firmware-m
510 cmake -S . -B cmake_build -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
511 cmake --build cmake_build -- install
512
513Alternately using traditional cmake syntax
514
515.. code-block:: bash
516
517 cd <base folder>
518 cd trusted-firmware-m
519 mkdir cmake_build
520 cd cmake_build
521 cmake .. -DTFM_PLATFORM=mps2/an521 -DCMAKE_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls
522 make install
523
Gyorgy Szingdb9783c2019-04-17 21:08:48 +0200524--------------
525
Galanakis, Minosdc6694b2020-01-06 13:54:56 +0000526*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*