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 | |
| 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 | +---------------------+----------------------------------------+---------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 96 | | TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 | |
| 97 | +---------------------+----------------------------------------+---------------+ |
| 98 | | TFM_PROFILE | Set TFM profile. | | |
| 99 | +---------------------+----------------------------------------+---------------+ |
| 100 | | TEST_S | Build secure regression tests. | OFF | |
| 101 | +---------------------+----------------------------------------+---------------+ |
| 102 | | TEST_NS | Build non-secure regression tests. | OFF | |
| 103 | +---------------------+----------------------------------------+---------------+ |
| 104 | | TEST_PSA_API | Build PSA API TESTS for the given | | |
| 105 | | | suite. Takes a PSA api ``SUITE`` as an | | |
| 106 | | | argument (``CRYPTO`` etc). | | |
| 107 | +---------------------+----------------------------------------+---------------+ |
| 108 | |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 109 | TF-M Profiles |
| 110 | ------------- |
| 111 | |
| 112 | TF-M Profiles are implemented as a single cmake configuration file, under the |
| 113 | ``config/profile`` directory. A good understanding can be gained quickly by |
| 114 | looking at the Profile configuration files, but the ultimate reference for |
Anton Komlev | 2cd9153 | 2022-11-17 13:36:55 +0000 | [diff] [blame] | 115 | Profiles is in :ref:`tf-m_profiles`. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 116 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 117 | ******************* |
| 118 | TF-M build examples |
| 119 | ******************* |
| 120 | |
| 121 | Example: building TF-M for AN521 platform using GCC: |
| 122 | ==================================================== |
| 123 | .. code-block:: bash |
| 124 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 125 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 126 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 127 | cmake --build cmake_build -- install |
| 128 | |
| 129 | Alternately using traditional cmake syntax |
| 130 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 131 | .. code-block:: bash |
| 132 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 133 | cd <TF-M base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 134 | mkdir cmake_build |
| 135 | cd cmake_build |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 136 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 137 | make install |
| 138 | |
| 139 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 140 | |
| 141 | It is recommended to build each different build configuration in a separate |
| 142 | build directory. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 143 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 144 | The default build uses Unix Makefiles. The ``-G`` option can be used to change |
| 145 | this. The default build uses the GNU ARM toolchain and creates a Release build. |
| 146 | These options can be overridden using the ``TFM_TOOLCHAIN_FILE`` and |
| 147 | ``CMAKE_BUILD_TYPE`` parameters, as shown below |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 148 | |
| 149 | .. code-block:: bash |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 150 | |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 151 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 152 | 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] | 153 | cmake --build cmake_build -- install |
| 154 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 155 | Regression Tests for the AN521 target platform |
| 156 | ============================================== |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 157 | |
| 158 | Regression tests can be build by using the TEST_S and TEST_NS settings. Either |
| 159 | can be used in isolation or both can be used to enable both suites. All tests |
| 160 | for all enabled partitions are run, along with IPC and Multicore tests if those |
| 161 | features are enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 162 | |
| 163 | .. code-block:: bash |
| 164 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 165 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 166 | 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] | 167 | cmake --build cmake_build -- install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 168 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 169 | Alternately using traditional cmake syntax |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 170 | |
| 171 | .. code-block:: bash |
| 172 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 173 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 174 | mkdir cmake_build |
| 175 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 176 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 177 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 178 | |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 179 | Build for PSA API tests |
| 180 | ======================= |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 181 | The build system provides support for building and integrating the PSA API tests |
| 182 | from https://github.com/ARM-software/psa-arch-tests. PSA API tests are |
| 183 | controlled using the TEST_PSA_API variable. Enabling both regression tests and |
| 184 | PSA API tests simultaneously is **not** supported. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 185 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 186 | 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] | 187 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 188 | .. code-block:: bash |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 189 | |
| 190 | -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE |
| 191 | -DTEST_PSA_API=PROTECTED_STORAGE |
| 192 | -DTEST_PSA_API=STORAGE |
| 193 | -DTEST_PSA_API=CRYPTO |
| 194 | -DTEST_PSA_API=INITIAL_ATTESTATION |
| 195 | |
| 196 | Respectively for the corresponding service. For example, to enable the PSA API |
| 197 | tests for the Crypto service: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 198 | |
| 199 | .. code-block:: bash |
| 200 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 201 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 202 | 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] | 203 | cmake --build cmake_build -- install |
| 204 | |
| 205 | Alternately using traditional cmake syntax |
| 206 | |
| 207 | .. code-block:: bash |
| 208 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 209 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 210 | mkdir cmake_build |
| 211 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 212 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 213 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 214 | |
| 215 | Location of build artifacts |
| 216 | =========================== |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 217 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 218 | All build artifacts are provided in the ``<build_dir>/bin`` directory. It is |
| 219 | **not** required to run ``make install`` to generate artifacts in this location. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 220 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 221 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 222 | For the purposes of maintaining compatibility with the legacy cmake build |
| 223 | system, they are also provided in |
| 224 | ``<build_dir>/install/outputs/<target_platform>/``. In order to generate the |
| 225 | artifacts in this location ``make install`` must be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 226 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 227 | **************************** |
| 228 | Manual dependency management |
| 229 | **************************** |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 230 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 231 | The TF-M build system will by default fetch all dependencies with appropriate |
| 232 | versions and store them inside the build tree. In this case, the build tree |
| 233 | location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by |
| 234 | deleting that directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 235 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 236 | If you have local copies already, and wish to avoid having the libraries |
| 237 | downloaded every time the build directory is deleted, then the following |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 238 | variables can be set to the path to the root directory of the local repo. This |
| 239 | will disable the automatic downloading for that dependency. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 240 | |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 241 | +----------------+---------------------+-----------------------------------------------------+ |
| 242 | | Dependency | Cmake variable | Git repo URL | |
| 243 | +================+=====================+=====================================================+ |
| 244 | | Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls | |
| 245 | +----------------+---------------------+-----------------------------------------------------+ |
| 246 | | tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git | |
| 247 | +----------------+---------------------+-----------------------------------------------------+ |
| 248 | | MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot | |
| 249 | +----------------+---------------------+-----------------------------------------------------+ |
| 250 | | psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests | |
| 251 | +----------------+---------------------+-----------------------------------------------------+ |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 252 | |
Anton Komlev | 1dfd209 | 2022-10-25 17:50:09 +0100 | [diff] [blame] | 253 | For required versions of the dependencies, refer to ``config/config_base.cmake``. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 254 | |
| 255 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 256 | - Some patches are required to the mbedtls repo to allow building it as part of |
| 257 | TF-M. While these patches are being upstreamed they are stored in |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 258 | ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is |
| 259 | required to apply all patch files in this directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 260 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 261 | .. Note:: |
| 262 | - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different |
| 263 | source for CMSIS 5, it can be configured using CMSIS_5_PATH. |
David Hu | 2cbf5df | 2020-06-15 10:41:44 +0800 | [diff] [blame] | 264 | |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 265 | TF-M Tests |
| 266 | ========== |
| 267 | |
| 268 | Dependency auto downloading is used by default. |
| 269 | 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] | 270 | specified by ``TFM_TEST_REPO_VERSION`` in |
Anton Komlev | 1dfd209 | 2022-10-25 17:50:09 +0100 | [diff] [blame] | 271 | :file:`lib/ext/tf-m-tests/repo_config_base.cmake`. |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 272 | The version can be a release tag or a commit hash. |
| 273 | |
| 274 | Developers who want a different version of tf-m-tests can override |
| 275 | ``TFM_TEST_REPO_PATH`` to a local copy with the desired version. |
| 276 | |
David Hu | f89bcb6 | 2021-09-06 15:02:34 +0800 | [diff] [blame] | 277 | As the test repo is part of the TF-M project and coupled with TF-M repo, |
| 278 | 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] | 279 | repo and the test repo and when there is a complete change merged in test repo. |
| 280 | |
| 281 | A complete change is one or more patches that are for the same purpose, for |
| 282 | example a new test suite or enhancements on the test cases. |
| 283 | Patches in one change can be merge individually provided they do not break |
| 284 | anything or cause any regressions. |
| 285 | But the version in the TF-M gets updated only when all the patches are merged. |
| 286 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 287 | Example: building TF-M for AN521 platform with local Mbed Crypto |
| 288 | ================================================================ |
| 289 | |
| 290 | Prepare Mbed Crypto repository |
| 291 | ------------------------------ |
| 292 | |
| 293 | This is only required to be done once. For dependencies that do not have any |
| 294 | ``.patch`` files in their ``lib/ext`` directory the only required step is |
| 295 | cloning the repo and checking out the correct branch. |
| 296 | |
| 297 | .. code-block:: bash |
| 298 | |
| 299 | cd <Mbed Crypto base folder> |
| 300 | git clone https://github.com/ARMmbed/mbedtls |
| 301 | cd mbedtls |
Anton Komlev | 1dfd209 | 2022-10-25 17:50:09 +0100 | [diff] [blame] | 302 | git checkout <MBEDCRYPTO_VERSION from config_base.cmake> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 303 | git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch |
| 304 | |
| 305 | .. Note:: |
| 306 | - <Mbed Crypto base folder> does not need to have any fixed posisition related |
| 307 | to the TF-M repo. |
| 308 | |
| 309 | Build TF-M |
| 310 | ---------- |
| 311 | |
| 312 | With new cmake syntax |
| 313 | |
| 314 | .. code-block:: bash |
| 315 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 316 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 317 | 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] | 318 | cmake --build cmake_build -- install |
| 319 | |
| 320 | Alternately using traditional cmake syntax |
| 321 | |
| 322 | .. code-block:: bash |
| 323 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 324 | cd <TF-M base folder> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 325 | mkdir cmake_build |
| 326 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 327 | 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] | 328 | make install |
| 329 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 330 | -------------- |
| 331 | |
Jianliang Shen | 2628db7 | 2022-03-17 10:13:06 +0800 | [diff] [blame] | 332 | *Copyright (c) 2017-2022, Arm Limited. All rights reserved.* |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 333 | *Copyright (c) 2022, Cypress Semiconductor Corporation. All rights reserved.* |