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 | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 46 | .. _tfm_cmake_configuration: |
| 47 | |
| 48 | Cmake configuration |
| 49 | =================== |
| 50 | |
| 51 | All configuration options are provided by cmake variables, and their default |
| 52 | values, with docstrings, can be found in ``config/config_default.cmake``. |
| 53 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 54 | Configuration is provided in multiple stages. Each stage will not override any |
| 55 | config that has already been set at any of the prior stages. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 56 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 57 | 1. Command-line variable settings are applied. |
| 58 | 2. If the ``TFM_EXTRA_CONFIG_PATH`` variable has been set, that file is |
Soby Mathew | 7b7e124 | 2020-10-07 13:31:56 +0100 | [diff] [blame] | 59 | loaded. |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 60 | 3. If TEST_PSA_TEST is set, then PSA API test related config is applied from |
| 61 | ``config/tests/config_test_psa_api.cmake``. |
| 62 | 4. If it exists, CMAKE_BUILD_TYPE specific config is applied from |
| 63 | ``config/build_type/<build_type>.cmake``. |
| 64 | 5. Target specific config from ``platform/ext/target/<target_platform>/config.cmake`` |
| 65 | is applied. |
| 66 | 6. If CRYPTO_HW_ACCELERATOR is set, then a config specific to the |
| 67 | accelerator type is applied if it exists. |
| 68 | 7. If it exists, TFM Profile specific config is applied from |
| 69 | ``config/profile/<tfm_profile>.cmake``. |
| 70 | 8. ``config/config_default.cmake`` is loaded. |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 71 | 9. If ``TEST_S`` or ``TEST_NS`` or other single test suite config like |
| 72 | ``TEST_NS_ATTESTATION`` (see `Regression test configuration`_)is set, then |
| 73 | config from ``${TFM_TEST_REPO_PATH}/test/config/set_config.cmake`` and |
| 74 | ``${TFM_TEST_REPO_PATH}/test/config/default_ns_test_config.cmake`` or |
| 75 | ``${TFM_TEST_REPO_PATH}/test/config/default_s_test_config.cmake`` or |
| 76 | ``${TFM_TEST_REPO_PATH}/test/config/default_test_config.cmake`` is |
| 77 | applied. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 78 | |
| 79 | .. Warning:: |
| 80 | This means that command-line settings are not applied when they conflict |
| 81 | with required platform settings. If it is required to override platform |
| 82 | settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be |
| 83 | used. |
| 84 | |
| 85 | Required cmake parameters for building TF-M |
| 86 | ------------------------------------------- |
| 87 | |
Jianliang Shen | 2628db7 | 2022-03-17 10:13:06 +0800 | [diff] [blame] | 88 | ``TFM_PLATFORM`` is required to select the target platform, it can be: |
| 89 | - A relative path under ``<TF-M_root>/platform/ext/target``, |
| 90 | for example ``arm/mps2/an521``. |
| 91 | - An absolute path of target platform, mainly used for out-of-tree platform |
| 92 | build. |
| 93 | - A target platform name that is supported under |
| 94 | <TF-M_root>/platform/ext/target, for example ``an521``. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 95 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 96 | Build type |
| 97 | ---------- |
| 98 | |
Dávid Házi | e50f0a9 | 2022-07-06 14:46:01 +0200 | [diff] [blame] | 99 | By default, a MinSizeRel configuration is built. Alternate build types can be |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 100 | specified with the ``CMAKE_BUILD_TYPE`` variable. The possible |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 101 | types are: |
| 102 | |
| 103 | - ``Debug`` |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 104 | - ``RelWithDebInfo`` |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 105 | - ``Release`` |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 106 | - ``MinSizeRel`` |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 107 | |
Dávid Házi | e50f0a9 | 2022-07-06 14:46:01 +0200 | [diff] [blame] | 108 | ``MinSizeRel`` is default. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 109 | |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 110 | Debug symbols are added by default to all builds, but can be removed |
| 111 | from ``Release`` and ``MinSizeRel`` builds by setting |
| 112 | ``TFM_DEBUG_SYMBOLS`` to ``OFF``. |
| 113 | |
| 114 | ``RelWithDebInfo``, ``Release`` and ``MinSizeRel`` all have different |
| 115 | optimizations turned on and hence will produce smaller, faster code |
| 116 | than ``Debug``. ``MinSizeRel`` will produce the smallest code, and |
| 117 | hence is often a good idea on RAM or flash constrained systems. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 118 | |
| 119 | Other cmake parameters |
| 120 | ---------------------- |
| 121 | |
| 122 | The full list of default options is in ``config/config_default.cmake``. Several |
| 123 | important options are listed below. |
| 124 | |
| 125 | |
| 126 | +---------------------+----------------------------------------+---------------+ |
| 127 | | Parameter | Description | Default value | |
| 128 | +=====================+========================================+===============+ |
| 129 | | BL2 | Build level 2 secure bootloader. | ON | |
| 130 | +---------------------+----------------------------------------+---------------+ |
| 131 | | NS | Build NS app. Required for test code. | ON | |
| 132 | +---------------------+----------------------------------------+---------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 133 | | TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 | |
| 134 | +---------------------+----------------------------------------+---------------+ |
| 135 | | TFM_PROFILE | Set TFM profile. | | |
| 136 | +---------------------+----------------------------------------+---------------+ |
| 137 | | TEST_S | Build secure regression tests. | OFF | |
| 138 | +---------------------+----------------------------------------+---------------+ |
| 139 | | TEST_NS | Build non-secure regression tests. | OFF | |
| 140 | +---------------------+----------------------------------------+---------------+ |
| 141 | | TEST_PSA_API | Build PSA API TESTS for the given | | |
| 142 | | | suite. Takes a PSA api ``SUITE`` as an | | |
| 143 | | | argument (``CRYPTO`` etc). | | |
| 144 | +---------------------+----------------------------------------+---------------+ |
| 145 | |
| 146 | Regression test configuration |
| 147 | ----------------------------- |
| 148 | |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 149 | Regression test configuration is controlled entirely by ``TEST_NS`` or |
| 150 | ``TEST_S`` or single test suite configuration. The group test |
| 151 | configurations and single test suite configurations are listed below, all of |
| 152 | them are disabled by default. |
| 153 | |
| 154 | +---------------------+--------------------------------------------------------------------+ |
| 155 | | Parameter | Description | |
| 156 | +=====================+====================================================================+ |
| 157 | | TEST_NS_ATTESTATION | Build non-secure regression Attestation tests. | |
| 158 | +---------------------+--------------------------------------------------------------------+ |
| 159 | | TEST_NS_T_COSE | Build non-secure regression t_cose tests. | |
| 160 | +---------------------+--------------------------------------------------------------------+ |
| 161 | | TEST_NS_QCBOR | Build non-secure regression QCBOR tests. | |
| 162 | +---------------------+--------------------------------------------------------------------+ |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 163 | | TEST_NS_CRYPTO | Build non-secure regression Crypto tests. | |
| 164 | +---------------------+--------------------------------------------------------------------+ |
| 165 | | TEST_NS_ITS | Build non-secure regression ITS tests. | |
| 166 | +---------------------+--------------------------------------------------------------------+ |
| 167 | | TEST_NS_PS | Build non-secure regression PS tests. | |
| 168 | +---------------------+--------------------------------------------------------------------+ |
| 169 | | TEST_NS_PLATFORM | Build non-secure regression Platform tests. | |
| 170 | +---------------------+--------------------------------------------------------------------+ |
| 171 | | TEST_NS_FWU | Build non-secure regression FWU tests. | |
| 172 | +---------------------+--------------------------------------------------------------------+ |
| 173 | | TEST_NS_IPC | Build non-secure regression IPC tests. | |
| 174 | +---------------------+--------------------------------------------------------------------+ |
| 175 | | TEST_NS_SLIH_IRQ | Build non-secure regression Second-Level Interrupt Handling tests. | |
| 176 | +---------------------+--------------------------------------------------------------------+ |
| 177 | | TEST_NS_FLIH_IRQ | Build non-secure regression First-Level Interrupt Handling tests. | |
| 178 | +---------------------+--------------------------------------------------------------------+ |
| 179 | | TEST_NS_MULTI_CORE | Build non-secure regression multi-core tests. | |
| 180 | +---------------------+--------------------------------------------------------------------+ |
| 181 | | TEST_S_ATTESTATION | Build secure regression Attestation tests. | |
| 182 | +---------------------+--------------------------------------------------------------------+ |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 183 | | TEST_S_CRYPTO | Build secure regression Crypto tests. | |
| 184 | +---------------------+--------------------------------------------------------------------+ |
| 185 | | TEST_S_ITS | Build secure regression ITS tests. | |
| 186 | +---------------------+--------------------------------------------------------------------+ |
| 187 | | TEST_S_PS | Build secure regression PS tests. | |
| 188 | +---------------------+--------------------------------------------------------------------+ |
| 189 | | TEST_S_PLATFORM | Build secure regression Platform tests. | |
| 190 | +---------------------+--------------------------------------------------------------------+ |
| 191 | | TEST_S_FWU | Build secure regression FWU tests. | |
| 192 | +---------------------+--------------------------------------------------------------------+ |
| 193 | | TEST_S_IPC | Build secure regression IPC tests. | |
| 194 | +---------------------+--------------------------------------------------------------------+ |
| 195 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 196 | Individual test suites can be enabled when their dependencies like partitions or |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 197 | other specific configurations are set. On the one hand, some test suites depend |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 198 | on other test suites. On the other hand, some test suites conflict with |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 199 | other test suites. Test configurations and dependencies will be |
| 200 | checked in ``${TFM_TEST_REPO_PATH}/test/config/check_config.cmake``. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 201 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 202 | If regression testing is enabled by ``TEST_NS`` or ``TEST_S``, individual |
| 203 | test suites will be enabled or disabled as appropriate for the TF-M |
| 204 | configuration (i.e. all enabled secure partitions will be tested). |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 205 | |
| 206 | Some cryptographic tests can be enabled and disabled. This is done to prevent |
| 207 | false failures from being reported when a smaller Mbed Crypto config is being |
| 208 | used which does not support all features. |
| 209 | |
Summer Qin | 32e41f5 | 2022-06-08 15:37:13 +0800 | [diff] [blame] | 210 | +---------------------------------------+---------------------------------------+---------------+ |
| 211 | | Parameter | Description | Default value | |
| 212 | +=======================================+=======================================+===============+ |
| 213 | | TFM_CRYPTO_TEST_ALG_CBC | Test CBC cryptography mode | ON | |
| 214 | +---------------------------------------+---------------------------------------+---------------+ |
| 215 | | TFM_CRYPTO_TEST_ALG_CCM | Test CCM cryptography mode | ON | |
| 216 | +---------------------------------------+---------------------------------------+---------------+ |
| 217 | | TFM_CRYPTO_TEST_ALG_CFB | Test CFB cryptography mode | ON | |
| 218 | +---------------------------------------+---------------------------------------+---------------+ |
| 219 | | TFM_CRYPTO_TEST_ALG_ECB | Test ECB cryptography mode | ON | |
| 220 | +---------------------------------------+---------------------------------------+---------------+ |
| 221 | | TFM_CRYPTO_TEST_ALG_CTR | Test CTR cryptography mode | ON | |
| 222 | +---------------------------------------+---------------------------------------+---------------+ |
| 223 | | TFM_CRYPTO_TEST_ALG_OFB | Test OFB cryptography mode | ON | |
| 224 | +---------------------------------------+---------------------------------------+---------------+ |
| 225 | | TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON | |
| 226 | +---------------------------------------+---------------------------------------+---------------+ |
| 227 | | TFM_CRYPTO_TEST_ALG_SHA_384 | Test SHA-384 cryptography algorithm | ON | |
| 228 | +---------------------------------------+---------------------------------------+---------------+ |
| 229 | | TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON | |
| 230 | +---------------------------------------+---------------------------------------+---------------+ |
| 231 | | TFM_CRYPTO_TEST_HKDF | Test HKDF key derivation algorithm | ON | |
| 232 | +---------------------------------------+---------------------------------------+---------------+ |
| 233 | | TFM_CRYPTO_TEST_ECDH | Test ECDH key agreement algorithm | ON | |
| 234 | +---------------------------------------+---------------------------------------+---------------+ |
| 235 | | TFM_CRYPTO_TEST_CHACHA20 | Test ChaCha20 stream cipher | ON | |
| 236 | +---------------------------------------+---------------------------------------+---------------+ |
| 237 | | TFM_CRYPTO_TEST_ALG_CHACHA20_POLY1305 | Test ChaCha20-Poly1305 AEAD algorithm | ON | |
| 238 | +---------------------------------------+---------------------------------------+---------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 239 | |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 240 | TF-M Profiles |
| 241 | ------------- |
| 242 | |
| 243 | TF-M Profiles are implemented as a single cmake configuration file, under the |
| 244 | ``config/profile`` directory. A good understanding can be gained quickly by |
| 245 | looking at the Profile configuration files, but the ultimate reference for |
Summer Qin | abf6698 | 2021-04-06 17:22:15 +0800 | [diff] [blame] | 246 | Profiles are the design documents in the ``docs/technical_references/profiles/`` |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 247 | directory. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 248 | |
| 249 | PSA test configuration |
| 250 | ---------------------- |
| 251 | |
| 252 | PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The |
| 253 | variable should be set to the name of the test suite that is desired. It is |
| 254 | _not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``. |
| 255 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 256 | The Functional API tests are: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 257 | - ``CRYPTO`` |
| 258 | - ``INITIAL_ATTESTATION`` |
| 259 | - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE) |
| 260 | - ``INTERNAL_TRUSTED_STORAGE`` |
| 261 | - ``PROTECTED_STORAGE`` |
| 262 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 263 | The Firmware Framework test suites are: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 264 | - ``IPC`` |
| 265 | |
| 266 | Note that these map directly to the ``SUITE`` cmake variable used in the |
| 267 | psa-arch-tests documentation. |
| 268 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 269 | ******************* |
| 270 | TF-M build examples |
| 271 | ******************* |
| 272 | |
| 273 | Example: building TF-M for AN521 platform using GCC: |
| 274 | ==================================================== |
| 275 | .. code-block:: bash |
| 276 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 277 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 278 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 279 | cmake --build cmake_build -- install |
| 280 | |
| 281 | Alternately using traditional cmake syntax |
| 282 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 283 | .. code-block:: bash |
| 284 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 285 | cd <TF-M base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 286 | mkdir cmake_build |
| 287 | cd cmake_build |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 288 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 289 | make install |
| 290 | |
| 291 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 292 | |
| 293 | It is recommended to build each different build configuration in a separate |
| 294 | build directory. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 295 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 296 | The default build uses Unix Makefiles. The ``-G`` option can be used to change |
| 297 | this. The default build uses the GNU ARM toolchain and creates a Release build. |
| 298 | These options can be overridden using the ``TFM_TOOLCHAIN_FILE`` and |
| 299 | ``CMAKE_BUILD_TYPE`` parameters, as shown below |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 300 | |
| 301 | .. code-block:: bash |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 302 | |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 303 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 304 | 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] | 305 | cmake --build cmake_build -- install |
| 306 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 307 | Regression Tests for the AN521 target platform |
| 308 | ============================================== |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 309 | |
| 310 | Regression tests can be build by using the TEST_S and TEST_NS settings. Either |
| 311 | can be used in isolation or both can be used to enable both suites. All tests |
| 312 | for all enabled partitions are run, along with IPC and Multicore tests if those |
| 313 | features are enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 314 | |
| 315 | .. code-block:: bash |
| 316 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 317 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 318 | 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] | 319 | cmake --build cmake_build -- install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 320 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 321 | Alternately using traditional cmake syntax |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 322 | |
| 323 | .. code-block:: bash |
| 324 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 325 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 326 | mkdir cmake_build |
| 327 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 328 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 329 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 330 | |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 331 | Build for PSA API tests |
| 332 | ======================= |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 333 | The build system provides support for building and integrating the PSA API tests |
| 334 | from https://github.com/ARM-software/psa-arch-tests. PSA API tests are |
| 335 | controlled using the TEST_PSA_API variable. Enabling both regression tests and |
| 336 | PSA API tests simultaneously is **not** supported. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 337 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 338 | 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] | 339 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 340 | .. code-block:: bash |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 341 | |
| 342 | -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE |
| 343 | -DTEST_PSA_API=PROTECTED_STORAGE |
| 344 | -DTEST_PSA_API=STORAGE |
| 345 | -DTEST_PSA_API=CRYPTO |
| 346 | -DTEST_PSA_API=INITIAL_ATTESTATION |
| 347 | |
| 348 | Respectively for the corresponding service. For example, to enable the PSA API |
| 349 | tests for the Crypto service: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 350 | |
| 351 | .. code-block:: bash |
| 352 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 353 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 354 | 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] | 355 | cmake --build cmake_build -- install |
| 356 | |
| 357 | Alternately using traditional cmake syntax |
| 358 | |
| 359 | .. code-block:: bash |
| 360 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 361 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 362 | mkdir cmake_build |
| 363 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 364 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 365 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 366 | |
| 367 | Location of build artifacts |
| 368 | =========================== |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 369 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 370 | All build artifacts are provided in the ``<build_dir>/bin`` directory. It is |
| 371 | **not** required to run ``make install`` to generate artifacts in this location. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 372 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 373 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 374 | For the purposes of maintaining compatibility with the legacy cmake build |
| 375 | system, they are also provided in |
| 376 | ``<build_dir>/install/outputs/<target_platform>/``. In order to generate the |
| 377 | artifacts in this location ``make install`` must be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 378 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 379 | **************************** |
| 380 | Manual dependency management |
| 381 | **************************** |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 382 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 383 | The TF-M build system will by default fetch all dependencies with appropriate |
| 384 | versions and store them inside the build tree. In this case, the build tree |
| 385 | location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by |
| 386 | deleting that directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 387 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 388 | If you have local copies already, and wish to avoid having the libraries |
| 389 | downloaded every time the build directory is deleted, then the following |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 390 | variables can be set to the path to the root directory of the local repo. This |
| 391 | will disable the automatic downloading for that dependency. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 392 | |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 393 | +----------------+---------------------+-----------------------------------------------------+ |
| 394 | | Dependency | Cmake variable | Git repo URL | |
| 395 | +================+=====================+=====================================================+ |
| 396 | | Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls | |
| 397 | +----------------+---------------------+-----------------------------------------------------+ |
| 398 | | tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git | |
| 399 | +----------------+---------------------+-----------------------------------------------------+ |
| 400 | | MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot | |
| 401 | +----------------+---------------------+-----------------------------------------------------+ |
| 402 | | psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests | |
| 403 | +----------------+---------------------+-----------------------------------------------------+ |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 404 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 405 | For required versions of the dependencies, refer to ``config/config_default.cmake``. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 406 | |
| 407 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 408 | - Some patches are required to the mbedtls repo to allow building it as part of |
| 409 | TF-M. While these patches are being upstreamed they are stored in |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 410 | ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is |
| 411 | required to apply all patch files in this directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 412 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 413 | .. Note:: |
| 414 | - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different |
| 415 | source for CMSIS 5, it can be configured using CMSIS_5_PATH. |
David Hu | 2cbf5df | 2020-06-15 10:41:44 +0800 | [diff] [blame] | 416 | |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 417 | TF-M Tests |
| 418 | ========== |
| 419 | |
| 420 | Dependency auto downloading is used by default. |
| 421 | 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] | 422 | specified by ``TFM_TEST_REPO_VERSION`` in |
| 423 | :file:`lib/ext/tf-m-tests/repo_config_default.cmake`. |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 424 | The version can be a release tag or a commit hash. |
| 425 | |
| 426 | Developers who want a different version of tf-m-tests can override |
| 427 | ``TFM_TEST_REPO_PATH`` to a local copy with the desired version. |
| 428 | |
David Hu | f89bcb6 | 2021-09-06 15:02:34 +0800 | [diff] [blame] | 429 | As the test repo is part of the TF-M project and coupled with TF-M repo, |
| 430 | 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] | 431 | repo and the test repo and when there is a complete change merged in test repo. |
| 432 | |
| 433 | A complete change is one or more patches that are for the same purpose, for |
| 434 | example a new test suite or enhancements on the test cases. |
| 435 | Patches in one change can be merge individually provided they do not break |
| 436 | anything or cause any regressions. |
| 437 | But the version in the TF-M gets updated only when all the patches are merged. |
| 438 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 439 | Example: building TF-M for AN521 platform with local Mbed Crypto |
| 440 | ================================================================ |
| 441 | |
| 442 | Prepare Mbed Crypto repository |
| 443 | ------------------------------ |
| 444 | |
| 445 | This is only required to be done once. For dependencies that do not have any |
| 446 | ``.patch`` files in their ``lib/ext`` directory the only required step is |
| 447 | cloning the repo and checking out the correct branch. |
| 448 | |
| 449 | .. code-block:: bash |
| 450 | |
| 451 | cd <Mbed Crypto base folder> |
| 452 | git clone https://github.com/ARMmbed/mbedtls |
| 453 | cd mbedtls |
| 454 | git checkout <MBEDCRYPTO_VERSION from config_default.cmake> |
| 455 | git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch |
| 456 | |
| 457 | .. Note:: |
| 458 | - <Mbed Crypto base folder> does not need to have any fixed posisition related |
| 459 | to the TF-M repo. |
| 460 | |
| 461 | Build TF-M |
| 462 | ---------- |
| 463 | |
| 464 | With new cmake syntax |
| 465 | |
| 466 | .. code-block:: bash |
| 467 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 468 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 469 | 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] | 470 | cmake --build cmake_build -- install |
| 471 | |
| 472 | Alternately using traditional cmake syntax |
| 473 | |
| 474 | .. code-block:: bash |
| 475 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 476 | cd <TF-M base folder> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 477 | mkdir cmake_build |
| 478 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 479 | 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] | 480 | make install |
| 481 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 482 | -------------- |
| 483 | |
Jianliang Shen | 2628db7 | 2022-03-17 10:13:06 +0800 | [diff] [blame] | 484 | *Copyright (c) 2017-2022, Arm Limited. All rights reserved.* |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 485 | *Copyright (c) 2022, Cypress Semiconductor Corporation. All rights reserved.* |