Galanakis, Minos | 41f8597 | 2019-09-30 15:56:40 +0100 | [diff] [blame] | 1 | ################## |
| 2 | Build instructions |
| 3 | ################## |
Anton Komlev | 0dbe8f1 | 2022-06-17 16:48:12 +0100 | [diff] [blame] | 4 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 5 | Please make sure you have all required software installed as explained in the |
Anton Komlev | 3356ba3 | 2022-03-31 22:02:11 +0100 | [diff] [blame] | 6 | :doc:`TF-M getting started </getting_started/tfm_getting_started>`. |
Anton Komlev | 91281f0 | 2022-04-22 09:24:20 +0100 | [diff] [blame] | 7 | The additional building materials you can find in the following links: |
| 8 | |
| 9 | .. toctree:: |
| 10 | :maxdepth: 1 |
| 11 | |
Anton Komlev | 91281f0 | 2022-04-22 09:24:20 +0100 | [diff] [blame] | 12 | Run TF-M examples <run_tfm_examples_on_arm_platforms> |
Anton Komlev | 0dbe8f1 | 2022-06-17 16:48:12 +0100 | [diff] [blame] | 13 | Building the documentation <documentation_generation> |
| 14 | IAR toolchain <tfm_build_instruction_iar> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 15 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 16 | **************** |
| 17 | TF-M build steps |
| 18 | **************** |
| 19 | TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source |
| 20 | build environment. The instructions are below. |
| 21 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 22 | Cmake version ``3.15.0`` or higher is required. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 23 | |
David Wang | d6fd6af | 2021-06-21 17:17:26 +0800 | [diff] [blame] | 24 | .. _Getting the source-code: |
| 25 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 26 | Getting the source-code |
| 27 | ======================= |
| 28 | .. code-block:: bash |
| 29 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 30 | cd <base folder> |
Minos Galanakis | 0f39fa5 | 2020-06-08 16:53:53 +0100 | [diff] [blame] | 31 | git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 32 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 33 | To simplify documentation commands, the new created repository under |
| 34 | ``trusted-firmware-m`` would be referenced as ``<TF-M base folder>`` and |
| 35 | its parent, the ``<base folder>``. Dependency management is now handled by |
| 36 | cmake. If you wish to alter this behaviour, see |
Anton Komlev | 0dbe8f1 | 2022-06-17 16:48:12 +0100 | [diff] [blame] | 37 | :ref:`building/tfm_build_instruction:Manual dependency management` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 38 | |
Minos Galanakis | ac6b06c | 2020-03-19 12:57:02 +0000 | [diff] [blame] | 39 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 40 | |
Minos Galanakis | 3b740a1 | 2020-10-15 11:10:26 +0100 | [diff] [blame] | 41 | - For building with Armclang compiler version 6.10.0+, please follow the note |
Anton Komlev | 3356ba3 | 2022-03-31 22:02:11 +0100 | [diff] [blame] | 42 | in :doc:`TF-M getting started </getting_started/tfm_getting_started>`. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 43 | - For building with the IAR toolchain, please see the notes in |
Minos Galanakis | 3b740a1 | 2020-10-15 11:10:26 +0100 | [diff] [blame] | 44 | :doc:`IAR software requirements <tfm_build_instruction_iar>` |
TTornblom | b9e5ed0 | 2020-02-13 16:53:15 +0100 | [diff] [blame] | 45 | |
Anton Komlev | 2cd9153 | 2022-11-17 13:36:55 +0000 | [diff] [blame] | 46 | Basic configuration |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 47 | =================== |
| 48 | |
Anton Komlev | 2cd9153 | 2022-11-17 13:36:55 +0000 | [diff] [blame] | 49 | TF-M has many options for configuration and fine-tuning. Please check the |
| 50 | :ref:`tf-m_configuration` section for details. The **base** configuration |
| 51 | will be build by default with only essential modules SPM and platform hence |
| 52 | a platform must be selected via ``TFM_PLATFORM`` options, it can be: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 53 | |
Jianliang Shen | 2628db7 | 2022-03-17 10:13:06 +0800 | [diff] [blame] | 54 | - A relative path under ``<TF-M_root>/platform/ext/target``, |
| 55 | for example ``arm/mps2/an521``. |
| 56 | - An absolute path of target platform, mainly used for out-of-tree platform |
| 57 | build. |
| 58 | - A target platform name that is supported under |
| 59 | <TF-M_root>/platform/ext/target, for example ``an521``. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 60 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 61 | Build type |
| 62 | ---------- |
| 63 | |
Dávid Házi | e50f0a9 | 2022-07-06 14:46:01 +0200 | [diff] [blame] | 64 | By default, a MinSizeRel configuration is built. Alternate build types can be |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 65 | specified with the ``CMAKE_BUILD_TYPE`` variable. The possible |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 66 | types are: |
| 67 | |
| 68 | - ``Debug`` |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 69 | - ``RelWithDebInfo`` |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 70 | - ``Release`` |
Anton Komlev | 2cd9153 | 2022-11-17 13:36:55 +0000 | [diff] [blame] | 71 | - ``MinSizeRel`` - default |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 72 | |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 73 | Debug symbols are added by default to all builds, but can be removed |
| 74 | from ``Release`` and ``MinSizeRel`` builds by setting |
| 75 | ``TFM_DEBUG_SYMBOLS`` to ``OFF``. |
| 76 | |
| 77 | ``RelWithDebInfo``, ``Release`` and ``MinSizeRel`` all have different |
| 78 | optimizations turned on and hence will produce smaller, faster code |
| 79 | than ``Debug``. ``MinSizeRel`` will produce the smallest code, and |
| 80 | hence is often a good idea on RAM or flash constrained systems. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 81 | |
| 82 | Other cmake parameters |
| 83 | ---------------------- |
| 84 | |
Anton Komlev | 2cd9153 | 2022-11-17 13:36:55 +0000 | [diff] [blame] | 85 | The full list of default options is in ``config/config_base.cmake`` and |
| 86 | explained in :ref:`tfm_cmake_configuration`. Several important options |
| 87 | are listed below. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 88 | |
Xinyu Zhang | 5f9ffeb | 2023-03-31 11:09:45 +0800 | [diff] [blame] | 89 | +----------------------------+------------------------------------------+---------------+ |
| 90 | | Parameter | Description | Default value | |
| 91 | +============================+==========================================+===============+ |
| 92 | | BL2 | Build level 2 secure bootloader. | ON | |
| 93 | +----------------------------+------------------------------------------+---------------+ |
| 94 | | NS | Build NS app. Required for test code. | ON | |
| 95 | +----------------------------+------------------------------------------+---------------+ |
| 96 | | PROJECT_CONFIG_HEADER_FILE | User defined header file for TF-M config | | |
| 97 | +----------------------------+------------------------------------------+---------------+ |
| 98 | | TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 | |
| 99 | +----------------------------+------------------------------------------+---------------+ |
| 100 | | TFM_PROFILE | Set TFM profile. | | |
| 101 | +----------------------------+------------------------------------------+---------------+ |
| 102 | | TEST_S | Build secure regression tests. | OFF | |
| 103 | +----------------------------+------------------------------------------+---------------+ |
| 104 | | TEST_NS | Build non-secure regression tests. | OFF | |
| 105 | +----------------------------+------------------------------------------+---------------+ |
| 106 | | TEST_PSA_API | Build PSA API TESTS for the given | | |
| 107 | | | suite. Takes a PSA api ``SUITE`` as an | | |
| 108 | | | argument (``CRYPTO`` etc). | | |
| 109 | +----------------------------+------------------------------------------+---------------+ |
| 110 | |
| 111 | Project Config Header File |
| 112 | -------------------------- |
| 113 | |
| 114 | CMake variable ``PROJECT_CONFIG_HEADER_FILE`` is set by users with the full path of the |
| 115 | configuration header file, which is used to fine-tune component options. The detailed reference |
| 116 | for project config header file is in :ref:`Header_configuration`. |
| 117 | |
| 118 | .. Note:: |
| 119 | |
| 120 | It is recommended to clean up build folder before re-build if config header file is updated. |
| 121 | CMake is unable to automatically recognize the dependency when the header file is defined as a macro. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 122 | |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 123 | TF-M Profiles |
| 124 | ------------- |
| 125 | |
| 126 | TF-M Profiles are implemented as a single cmake configuration file, under the |
| 127 | ``config/profile`` directory. A good understanding can be gained quickly by |
| 128 | looking at the Profile configuration files, but the ultimate reference for |
Anton Komlev | 2cd9153 | 2022-11-17 13:36:55 +0000 | [diff] [blame] | 129 | Profiles is in :ref:`tf-m_profiles`. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 130 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 131 | ******************* |
| 132 | TF-M build examples |
| 133 | ******************* |
| 134 | |
| 135 | Example: building TF-M for AN521 platform using GCC: |
| 136 | ==================================================== |
| 137 | .. code-block:: bash |
| 138 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 139 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 140 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 141 | cmake --build cmake_build -- install |
| 142 | |
| 143 | Alternately using traditional cmake syntax |
| 144 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 145 | .. code-block:: bash |
| 146 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 147 | cd <TF-M base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 148 | mkdir cmake_build |
| 149 | cd cmake_build |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 150 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 151 | make install |
| 152 | |
| 153 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 154 | |
| 155 | It is recommended to build each different build configuration in a separate |
| 156 | build directory. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 157 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 158 | The default build uses Unix Makefiles. The ``-G`` option can be used to change |
| 159 | this. The default build uses the GNU ARM toolchain and creates a Release build. |
| 160 | These options can be overridden using the ``TFM_TOOLCHAIN_FILE`` and |
| 161 | ``CMAKE_BUILD_TYPE`` parameters, as shown below |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 162 | |
| 163 | .. code-block:: bash |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 164 | |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 165 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 166 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -GNinja -DTFM_TOOLCHAIN_FILE=toolchain_ARMCLANG.cmake -DCMAKE_BUILD_TYPE=Debug |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 167 | cmake --build cmake_build -- install |
| 168 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 169 | Regression Tests for the AN521 target platform |
| 170 | ============================================== |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 171 | |
| 172 | Regression tests can be build by using the TEST_S and TEST_NS settings. Either |
| 173 | can be used in isolation or both can be used to enable both suites. All tests |
| 174 | for all enabled partitions are run, along with IPC and Multicore tests if those |
| 175 | features are enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 176 | |
| 177 | .. code-block:: bash |
| 178 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 179 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 180 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 181 | cmake --build cmake_build -- install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 182 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 183 | Alternately using traditional cmake syntax |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 184 | |
| 185 | .. code-block:: bash |
| 186 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 187 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 188 | mkdir cmake_build |
| 189 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 190 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 191 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 192 | |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 193 | Build for PSA API tests |
| 194 | ======================= |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 195 | The build system provides support for building and integrating the PSA API tests |
| 196 | from https://github.com/ARM-software/psa-arch-tests. PSA API tests are |
| 197 | controlled using the TEST_PSA_API variable. Enabling both regression tests and |
| 198 | PSA API tests simultaneously is **not** supported. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 199 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 200 | The value of the TEST_PSA_API variable is the suite to be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 201 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 202 | .. code-block:: bash |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 203 | |
| 204 | -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE |
| 205 | -DTEST_PSA_API=PROTECTED_STORAGE |
| 206 | -DTEST_PSA_API=STORAGE |
| 207 | -DTEST_PSA_API=CRYPTO |
| 208 | -DTEST_PSA_API=INITIAL_ATTESTATION |
| 209 | |
| 210 | Respectively for the corresponding service. For example, to enable the PSA API |
| 211 | tests for the Crypto service: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 212 | |
| 213 | .. code-block:: bash |
| 214 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 215 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 216 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 217 | cmake --build cmake_build -- install |
| 218 | |
| 219 | Alternately using traditional cmake syntax |
| 220 | |
| 221 | .. code-block:: bash |
| 222 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 223 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 224 | mkdir cmake_build |
| 225 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 226 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 227 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 228 | |
| 229 | Location of build artifacts |
| 230 | =========================== |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 231 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 232 | All build artifacts are provided in the ``<build_dir>/bin`` directory. It is |
| 233 | **not** required to run ``make install`` to generate artifacts in this location. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 234 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 235 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 236 | For the purposes of maintaining compatibility with the legacy cmake build |
| 237 | system, they are also provided in |
| 238 | ``<build_dir>/install/outputs/<target_platform>/``. In order to generate the |
| 239 | artifacts in this location ``make install`` must be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 240 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 241 | **************************** |
| 242 | Manual dependency management |
| 243 | **************************** |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 244 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 245 | The TF-M build system will by default fetch all dependencies with appropriate |
| 246 | versions and store them inside the build tree. In this case, the build tree |
| 247 | location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by |
| 248 | deleting that directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 249 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 250 | If you have local copies already, and wish to avoid having the libraries |
| 251 | downloaded every time the build directory is deleted, then the following |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 252 | variables can be set to the path to the root directory of the local repo. This |
| 253 | will disable the automatic downloading for that dependency. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 254 | |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 255 | +----------------+---------------------+-----------------------------------------------------+ |
| 256 | | Dependency | Cmake variable | Git repo URL | |
| 257 | +================+=====================+=====================================================+ |
| 258 | | Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls | |
| 259 | +----------------+---------------------+-----------------------------------------------------+ |
| 260 | | tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git | |
| 261 | +----------------+---------------------+-----------------------------------------------------+ |
| 262 | | MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot | |
| 263 | +----------------+---------------------+-----------------------------------------------------+ |
| 264 | | psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests | |
| 265 | +----------------+---------------------+-----------------------------------------------------+ |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 266 | |
Anton Komlev | 1dfd209 | 2022-10-25 17:50:09 +0100 | [diff] [blame] | 267 | For required versions of the dependencies, refer to ``config/config_base.cmake``. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 268 | |
| 269 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 270 | - Some patches are required to the mbedtls repo to allow building it as part of |
| 271 | TF-M. While these patches are being upstreamed they are stored in |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 272 | ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is |
| 273 | required to apply all patch files in this directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 274 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 275 | .. Note:: |
| 276 | - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different |
| 277 | source for CMSIS 5, it can be configured using CMSIS_5_PATH. |
David Hu | 2cbf5df | 2020-06-15 10:41:44 +0800 | [diff] [blame] | 278 | |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 279 | TF-M Tests |
| 280 | ========== |
| 281 | |
| 282 | Dependency auto downloading is used by default. |
| 283 | The TF-M build system downloads the tf-m-tests repo with a fixed version |
David Hu | f89bcb6 | 2021-09-06 15:02:34 +0800 | [diff] [blame] | 284 | specified by ``TFM_TEST_REPO_VERSION`` in |
Anton Komlev | 1dfd209 | 2022-10-25 17:50:09 +0100 | [diff] [blame] | 285 | :file:`lib/ext/tf-m-tests/repo_config_base.cmake`. |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 286 | The version can be a release tag or a commit hash. |
| 287 | |
| 288 | Developers who want a different version of tf-m-tests can override |
| 289 | ``TFM_TEST_REPO_PATH`` to a local copy with the desired version. |
| 290 | |
David Hu | f89bcb6 | 2021-09-06 15:02:34 +0800 | [diff] [blame] | 291 | As the test repo is part of the TF-M project and coupled with TF-M repo, |
| 292 | the version should be updated when there are dependency changes between the TF-M |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 293 | repo and the test repo and when there is a complete change merged in test repo. |
| 294 | |
| 295 | A complete change is one or more patches that are for the same purpose, for |
| 296 | example a new test suite or enhancements on the test cases. |
| 297 | Patches in one change can be merge individually provided they do not break |
| 298 | anything or cause any regressions. |
| 299 | But the version in the TF-M gets updated only when all the patches are merged. |
| 300 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 301 | Example: building TF-M for AN521 platform with local Mbed Crypto |
| 302 | ================================================================ |
| 303 | |
| 304 | Prepare Mbed Crypto repository |
| 305 | ------------------------------ |
| 306 | |
| 307 | This is only required to be done once. For dependencies that do not have any |
| 308 | ``.patch`` files in their ``lib/ext`` directory the only required step is |
| 309 | cloning the repo and checking out the correct branch. |
| 310 | |
| 311 | .. code-block:: bash |
| 312 | |
| 313 | cd <Mbed Crypto base folder> |
| 314 | git clone https://github.com/ARMmbed/mbedtls |
| 315 | cd mbedtls |
Anton Komlev | 1dfd209 | 2022-10-25 17:50:09 +0100 | [diff] [blame] | 316 | git checkout <MBEDCRYPTO_VERSION from config_base.cmake> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 317 | git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch |
| 318 | |
| 319 | .. Note:: |
| 320 | - <Mbed Crypto base folder> does not need to have any fixed posisition related |
| 321 | to the TF-M repo. |
| 322 | |
| 323 | Build TF-M |
| 324 | ---------- |
| 325 | |
| 326 | With new cmake syntax |
| 327 | |
| 328 | .. code-block:: bash |
| 329 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 330 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 331 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 332 | cmake --build cmake_build -- install |
| 333 | |
| 334 | Alternately using traditional cmake syntax |
| 335 | |
| 336 | .. code-block:: bash |
| 337 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 338 | cd <TF-M base folder> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 339 | mkdir cmake_build |
| 340 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 341 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DMBEDCRYPTO_PATH=<Mbed Crypto base folder>/mbedtls |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 342 | make install |
| 343 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 344 | -------------- |
| 345 | |
Xinyu Zhang | 5f9ffeb | 2023-03-31 11:09:45 +0800 | [diff] [blame] | 346 | *Copyright (c) 2017-2023, Arm Limited. All rights reserved.* |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 347 | *Copyright (c) 2022, Cypress Semiconductor Corporation. All rights reserved.* |