Galanakis, Minos | 41f8597 | 2019-09-30 15:56:40 +0100 | [diff] [blame] | 1 | ################## |
| 2 | Build instructions |
| 3 | ################## |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 4 | Please make sure you have all required software installed as explained in the |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 5 | :doc:`TF-M getting started </docs/getting_started/tfm_getting_started>`. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 6 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 7 | **************** |
| 8 | TF-M build steps |
| 9 | **************** |
| 10 | TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source |
| 11 | build environment. The instructions are below. |
| 12 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 13 | Cmake version ``3.15.0`` or higher is required. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 14 | |
David Wang | d6fd6af | 2021-06-21 17:17:26 +0800 | [diff] [blame] | 15 | .. _Getting the source-code: |
| 16 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 17 | Getting the source-code |
| 18 | ======================= |
| 19 | .. code-block:: bash |
| 20 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 21 | cd <base folder> |
Minos Galanakis | 0f39fa5 | 2020-06-08 16:53:53 +0100 | [diff] [blame] | 22 | git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 23 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 24 | To simplify documentation commands, the new created repository under |
| 25 | ``trusted-firmware-m`` would be referenced as ``<TF-M base folder>`` and |
| 26 | its parent, the ``<base folder>``. Dependency management is now handled by |
| 27 | cmake. If you wish to alter this behaviour, see |
Summer Qin | ab1dd99 | 2021-05-25 13:58:55 +0800 | [diff] [blame] | 28 | :ref:`docs/technical_references/instructions/tfm_build_instruction:Manual |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 29 | dependency management` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 30 | |
Minos Galanakis | ac6b06c | 2020-03-19 12:57:02 +0000 | [diff] [blame] | 31 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 32 | |
Minos Galanakis | 3b740a1 | 2020-10-15 11:10:26 +0100 | [diff] [blame] | 33 | - For building with Armclang compiler version 6.10.0+, please follow the note |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 34 | in :doc:`TF-M getting started </docs/getting_started/tfm_getting_started>`. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 35 | - For building with the IAR toolchain, please see the notes in |
Minos Galanakis | 3b740a1 | 2020-10-15 11:10:26 +0100 | [diff] [blame] | 36 | :doc:`IAR software requirements <tfm_build_instruction_iar>` |
TTornblom | b9e5ed0 | 2020-02-13 16:53:15 +0100 | [diff] [blame] | 37 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 38 | .. _tfm_cmake_configuration: |
| 39 | |
| 40 | Cmake configuration |
| 41 | =================== |
| 42 | |
| 43 | All configuration options are provided by cmake variables, and their default |
| 44 | values, with docstrings, can be found in ``config/config_default.cmake``. |
| 45 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 46 | Configuration is provided in multiple stages. Each stage will not override any |
| 47 | config that has already been set at any of the prior stages. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 48 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 49 | 1. Command-line variable settings are applied. |
| 50 | 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] | 51 | loaded. |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 52 | 3. If TEST_PSA_TEST is set, then PSA API test related config is applied from |
| 53 | ``config/tests/config_test_psa_api.cmake``. |
| 54 | 4. If it exists, CMAKE_BUILD_TYPE specific config is applied from |
| 55 | ``config/build_type/<build_type>.cmake``. |
| 56 | 5. Target specific config from ``platform/ext/target/<target_platform>/config.cmake`` |
| 57 | is applied. |
| 58 | 6. If CRYPTO_HW_ACCELERATOR is set, then a config specific to the |
| 59 | accelerator type is applied if it exists. |
| 60 | 7. If it exists, TFM Profile specific config is applied from |
| 61 | ``config/profile/<tfm_profile>.cmake``. |
| 62 | 8. ``config/config_default.cmake`` is loaded. |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 63 | 9. If ``TEST_S`` or ``TEST_NS`` or other single test suite config like |
| 64 | ``TEST_NS_ATTESTATION`` (see `Regression test configuration`_)is set, then |
| 65 | config from ``${TFM_TEST_REPO_PATH}/test/config/set_config.cmake`` and |
| 66 | ``${TFM_TEST_REPO_PATH}/test/config/default_ns_test_config.cmake`` or |
| 67 | ``${TFM_TEST_REPO_PATH}/test/config/default_s_test_config.cmake`` or |
| 68 | ``${TFM_TEST_REPO_PATH}/test/config/default_test_config.cmake`` is |
| 69 | applied. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 70 | |
| 71 | .. Warning:: |
| 72 | This means that command-line settings are not applied when they conflict |
| 73 | with required platform settings. If it is required to override platform |
| 74 | settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be |
| 75 | used. |
| 76 | |
| 77 | Required cmake parameters for building TF-M |
| 78 | ------------------------------------------- |
| 79 | |
| 80 | +----------------------+-------------------------------------------------------+ |
| 81 | | Parameter | Description | |
| 82 | +======================+=======================================================+ |
| 83 | | TFM_PLATFORM | The target platform as a path from the base directory | |
Øyvind Rønningstad | a9d5eac | 2021-01-22 14:21:25 +0100 | [diff] [blame] | 84 | | | ``/platform/ext/target``, or as an absolute path. | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 85 | +----------------------+-------------------------------------------------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 86 | |
| 87 | By default release configuration builds. Alternate build types can be controlled |
| 88 | by the CMAKE_BUILD_TYPE variable. |
| 89 | |
| 90 | Build type |
| 91 | ---------- |
| 92 | |
| 93 | Build type is controlled by the ``CMAKE_BUILD_TYPE`` variable. The possible |
| 94 | types are: |
| 95 | |
| 96 | - ``Debug`` |
| 97 | - ``Relwithdebinfo`` |
| 98 | - ``Release`` |
| 99 | - ``Minsizerel`` |
| 100 | |
| 101 | ``Release`` is default. |
| 102 | |
| 103 | Both ``Debug`` and ``Relwithdebinfo`` will include debug symbols in the output |
| 104 | files. ``Relwithdebinfo``, ``Release`` and ``Minsizerel`` have optimization |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 105 | turned on and hence will produce smaller, faster code. ``Minsizerel`` will |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 106 | produce the smallest code, and hence is often a good idea on RAM or flash |
| 107 | constrained systems. |
| 108 | |
| 109 | Other cmake parameters |
| 110 | ---------------------- |
| 111 | |
| 112 | The full list of default options is in ``config/config_default.cmake``. Several |
| 113 | important options are listed below. |
| 114 | |
| 115 | |
| 116 | +---------------------+----------------------------------------+---------------+ |
| 117 | | Parameter | Description | Default value | |
| 118 | +=====================+========================================+===============+ |
| 119 | | BL2 | Build level 2 secure bootloader. | ON | |
| 120 | +---------------------+----------------------------------------+---------------+ |
| 121 | | NS | Build NS app. Required for test code. | ON | |
| 122 | +---------------------+----------------------------------------+---------------+ |
| 123 | | TFM_PSA_API | Use PSA api (IPC mode) instead of | OFF | |
| 124 | | | secure library mode. | | |
| 125 | +---------------------+----------------------------------------+---------------+ |
| 126 | | TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 | |
| 127 | +---------------------+----------------------------------------+---------------+ |
| 128 | | TFM_PROFILE | Set TFM profile. | | |
| 129 | +---------------------+----------------------------------------+---------------+ |
| 130 | | TEST_S | Build secure regression tests. | OFF | |
| 131 | +---------------------+----------------------------------------+---------------+ |
| 132 | | TEST_NS | Build non-secure regression tests. | OFF | |
| 133 | +---------------------+----------------------------------------+---------------+ |
| 134 | | TEST_PSA_API | Build PSA API TESTS for the given | | |
| 135 | | | suite. Takes a PSA api ``SUITE`` as an | | |
| 136 | | | argument (``CRYPTO`` etc). | | |
| 137 | +---------------------+----------------------------------------+---------------+ |
| 138 | |
| 139 | Regression test configuration |
| 140 | ----------------------------- |
| 141 | |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 142 | Regression test configuration is controlled entirely by ``TEST_NS`` or |
| 143 | ``TEST_S`` or single test suite configuration. The group test |
| 144 | configurations and single test suite configurations are listed below, all of |
| 145 | them are disabled by default. |
| 146 | |
| 147 | +---------------------+--------------------------------------------------------------------+ |
| 148 | | Parameter | Description | |
| 149 | +=====================+====================================================================+ |
| 150 | | TEST_NS_ATTESTATION | Build non-secure regression Attestation tests. | |
| 151 | +---------------------+--------------------------------------------------------------------+ |
| 152 | | TEST_NS_T_COSE | Build non-secure regression t_cose tests. | |
| 153 | +---------------------+--------------------------------------------------------------------+ |
| 154 | | TEST_NS_QCBOR | Build non-secure regression QCBOR tests. | |
| 155 | +---------------------+--------------------------------------------------------------------+ |
| 156 | | TEST_NS_AUDIT | Build non-secure regression Audit log tests. | |
| 157 | +---------------------+--------------------------------------------------------------------+ |
| 158 | | TEST_NS_CORE | Build non-secure regression Core tests. | |
| 159 | +---------------------+--------------------------------------------------------------------+ |
| 160 | | TEST_NS_CRYPTO | Build non-secure regression Crypto tests. | |
| 161 | +---------------------+--------------------------------------------------------------------+ |
| 162 | | TEST_NS_ITS | Build non-secure regression ITS tests. | |
| 163 | +---------------------+--------------------------------------------------------------------+ |
| 164 | | TEST_NS_PS | Build non-secure regression PS tests. | |
| 165 | +---------------------+--------------------------------------------------------------------+ |
| 166 | | TEST_NS_PLATFORM | Build non-secure regression Platform tests. | |
| 167 | +---------------------+--------------------------------------------------------------------+ |
| 168 | | TEST_NS_FWU | Build non-secure regression FWU tests. | |
| 169 | +---------------------+--------------------------------------------------------------------+ |
| 170 | | TEST_NS_IPC | Build non-secure regression IPC tests. | |
| 171 | +---------------------+--------------------------------------------------------------------+ |
| 172 | | TEST_NS_SLIH_IRQ | Build non-secure regression Second-Level Interrupt Handling tests. | |
| 173 | +---------------------+--------------------------------------------------------------------+ |
| 174 | | TEST_NS_FLIH_IRQ | Build non-secure regression First-Level Interrupt Handling tests. | |
| 175 | +---------------------+--------------------------------------------------------------------+ |
| 176 | | TEST_NS_MULTI_CORE | Build non-secure regression multi-core tests. | |
| 177 | +---------------------+--------------------------------------------------------------------+ |
| 178 | | TEST_S_ATTESTATION | Build secure regression Attestation tests. | |
| 179 | +---------------------+--------------------------------------------------------------------+ |
| 180 | | TEST_S_AUDIT | Build secure regression Audit log tests. | |
| 181 | +---------------------+--------------------------------------------------------------------+ |
| 182 | | TEST_S_CRYPTO | Build secure regression Crypto tests. | |
| 183 | +---------------------+--------------------------------------------------------------------+ |
| 184 | | TEST_S_ITS | Build secure regression ITS tests. | |
| 185 | +---------------------+--------------------------------------------------------------------+ |
| 186 | | TEST_S_PS | Build secure regression PS tests. | |
| 187 | +---------------------+--------------------------------------------------------------------+ |
| 188 | | TEST_S_PLATFORM | Build secure regression Platform tests. | |
| 189 | +---------------------+--------------------------------------------------------------------+ |
| 190 | | TEST_S_FWU | Build secure regression FWU tests. | |
| 191 | +---------------------+--------------------------------------------------------------------+ |
| 192 | | TEST_S_IPC | Build secure regression IPC tests. | |
| 193 | +---------------------+--------------------------------------------------------------------+ |
| 194 | |
| 195 | The single test suite can be opened when their dependencies like partitions or |
| 196 | other specific configurations are set. On the one hand, some test suites depend |
| 197 | on other test suites. On the other hand, some test suites have confict with |
| 198 | other test suites. Test configurations and dependencies will be |
| 199 | checked in ``${TFM_TEST_REPO_PATH}/test/config/check_config.cmake``. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 200 | |
| 201 | If regression testing is enabled, it will then enable all tests for the enabled |
| 202 | secure partitions. If IPC mode is enabled via ``TFM_PSA_API`` the IPC tests will |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 203 | be enabled. Multicore tests will be enabled if ``TFM_MULTI_CORE_TOPOLOGY`` is |
| 204 | enabled. |
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 | |
| 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_CTR | Test CTR cryptography mode | ON | |
| 220 | +-----------------------------+-------------------------------------+---------------+ |
Abbas Bracken Ziad | 3d262f4 | 2021-08-19 15:07:05 +0100 | [diff] [blame^] | 221 | | TFM_CRYPTO_TEST_ALG_OFB | Test OFB cryptography mode | ON | |
| 222 | +-----------------------------+-------------------------------------+---------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 223 | | TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON | |
| 224 | +-----------------------------+-------------------------------------+---------------+ |
| 225 | | TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON | |
| 226 | +-----------------------------+-------------------------------------+---------------+ |
Antonio de Angelis | 6eb5ecb | 2021-07-29 11:33:48 +0200 | [diff] [blame] | 227 | | TFM_CRYPTO_TEST_HKDF | Test HKDF key derivation algorithm | ON | |
| 228 | +-----------------------------+-------------------------------------+---------------+ |
| 229 | | TFM_CRYPTO_TEST_ECDH | Test ECDH key agreement algorithm | ON | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 230 | +-----------------------------+-------------------------------------+---------------+ |
| 231 | |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 232 | TF-M Profiles |
| 233 | ------------- |
| 234 | |
| 235 | TF-M Profiles are implemented as a single cmake configuration file, under the |
| 236 | ``config/profile`` directory. A good understanding can be gained quickly by |
| 237 | looking at the Profile configuration files, but the ultimate reference for |
Summer Qin | abf6698 | 2021-04-06 17:22:15 +0800 | [diff] [blame] | 238 | Profiles are the design documents in the ``docs/technical_references/profiles/`` |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 239 | directory. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 240 | |
| 241 | PSA test configuration |
| 242 | ---------------------- |
| 243 | |
| 244 | PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The |
| 245 | variable should be set to the name of the test suite that is desired. It is |
| 246 | _not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``. |
| 247 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 248 | The Functional API tests are: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 249 | - ``CRYPTO`` |
| 250 | - ``INITIAL_ATTESTATION`` |
| 251 | - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE) |
| 252 | - ``INTERNAL_TRUSTED_STORAGE`` |
| 253 | - ``PROTECTED_STORAGE`` |
| 254 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 255 | The Firmware Framework test suites are: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 256 | - ``IPC`` |
| 257 | |
| 258 | Note that these map directly to the ``SUITE`` cmake variable used in the |
| 259 | psa-arch-tests documentation. |
| 260 | |
David Wang | d6fd6af | 2021-06-21 17:17:26 +0800 | [diff] [blame] | 261 | .. _Migration from legacy buildsystem: |
| 262 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 263 | Migration from legacy buildsystem |
| 264 | --------------------------------- |
| 265 | |
| 266 | The previous (legacy) cmake buildsystem made use of separate configuration |
| 267 | files, where now build options are controlled by variables. For ease of |
| 268 | transition, a table below is provided that maps the legacy files to the current |
| 269 | variables, in the format of cmake command line parameters. |
| 270 | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 271 | +------------------------------------------+---------------------------------------+ |
| 272 | | File | Cmake command line | |
| 273 | +==========================================+=======================================+ |
| 274 | | ConfigDefault.cmake | <No options> | |
| 275 | +------------------------------------------+---------------------------------------+ |
| 276 | | ConfigCoreIPC.cmake | -DTFM_PSA_API=ON | |
| 277 | +------------------------------------------+---------------------------------------+ |
| 278 | | ConfigCoreIPCTfmLevel2.cmake | -DTFM_PSA_API=ON | |
| 279 | | | -DTFM_ISOLATION_LEVEL=2 | |
| 280 | +------------------------------------------+---------------------------------------+ |
| 281 | | ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small | |
| 282 | +------------------------------------------+---------------------------------------+ |
| 283 | | ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium | |
| 284 | +------------------------------------------+---------------------------------------+ |
| 285 | | ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON | |
| 286 | +------------------------------------------+---------------------------------------+ |
| 287 | | ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON | |
| 288 | | | -DTFM_PSA_API=ON | |
| 289 | +------------------------------------------+---------------------------------------+ |
| 290 | | ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON | |
| 291 | | | -DTFM_PSA_API=ON | |
| 292 | | | -DTFM_ISOLATION_LEVEL=2 | |
| 293 | +------------------------------------------+---------------------------------------+ |
| 294 | | ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small | |
| 295 | | | -DTEST_NS=ON -DTEST_S=ON | |
| 296 | +------------------------------------------+---------------------------------------+ |
| 297 | | ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium | |
| 298 | | | -DTEST_NS=ON -DTEST_S=ON | |
| 299 | +------------------------------------------+---------------------------------------+ |
| 300 | | ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> | |
| 301 | +------------------------------------------+---------------------------------------+ |
| 302 | | ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> | |
| 303 | | | -DTFM_PSA_API=ON | |
| 304 | +------------------------------------------+---------------------------------------+ |
| 305 | | ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> | |
| 306 | | | -DTFM_PSA_API=ON | |
| 307 | | | -DTFM_ISOLATION_LEVEL=2 | |
| 308 | +------------------------------------------+---------------------------------------+ |
| 309 | | ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium | |
| 310 | | + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PROTECTED_STORAGE=OFF | |
| 311 | +------------------------------------------+---------------------------------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 312 | |
| 313 | There has also been some changes to the PSA manifest file generation. The files |
| 314 | are now generated into a seperate tree in the ``<tfm build dir>/generated`` |
| 315 | directory. Therefore they have been removed from the source tree. Any changes |
| 316 | should be made only to the template files. |
| 317 | |
| 318 | The api for the ``tools/tfm_parse_manifest_list.py`` script has also changed |
| 319 | slightly. It is no longer required to be run manually as it is run as part of |
| 320 | cmake. |
| 321 | |
| 322 | ******************* |
| 323 | TF-M build examples |
| 324 | ******************* |
| 325 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 326 | .. Note:: |
| 327 | By default, CMAKE_BUILD_TYPE is set to Release, for debug support change |
| 328 | this to Debug. See below for an example. |
| 329 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 330 | Example: building TF-M for AN521 platform using GCC: |
| 331 | ==================================================== |
| 332 | .. code-block:: bash |
| 333 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 334 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 335 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 336 | cmake --build cmake_build -- install |
| 337 | |
| 338 | Alternately using traditional cmake syntax |
| 339 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 340 | .. code-block:: bash |
| 341 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 342 | cd <TF-M base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 343 | mkdir cmake_build |
| 344 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 345 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 346 | make install |
| 347 | |
| 348 | .. Note:: |
| 349 | Unix Makefiles is the default generator. Ninja is also supported by setting |
| 350 | -GNinja |
| 351 | |
| 352 | .. Note:: |
| 353 | |
| 354 | It is recommended to build each different build configuration in a separate |
| 355 | build directory. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 356 | |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 357 | As seen above, the toolchain can be set using the -DTFM_TOOLCHAIN_FILE parameter. Without |
| 358 | it, the build command takes the GNU ARM toolchain as default, so there is no need |
| 359 | to explicitly include it. In case other toolchain is required, i.e. ARM Clang, simply |
| 360 | specify in the command line |
| 361 | |
| 362 | .. code-block:: bash |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 363 | |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 364 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 365 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_ARMCLANG.cmake -DTEST_S=ON -DTEST_NS=ON |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 366 | cmake --build cmake_build -- install |
| 367 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 368 | Regression Tests for the AN521 target platform |
| 369 | ============================================== |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 370 | |
| 371 | Regression tests can be build by using the TEST_S and TEST_NS settings. Either |
| 372 | can be used in isolation or both can be used to enable both suites. All tests |
| 373 | for all enabled partitions are run, along with IPC and Multicore tests if those |
| 374 | features are enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 375 | |
| 376 | .. code-block:: bash |
| 377 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 378 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 379 | 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] | 380 | cmake --build cmake_build -- install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 381 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 382 | Alternately using traditional cmake syntax |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 383 | |
| 384 | .. code-block:: bash |
| 385 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 386 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 387 | mkdir cmake_build |
| 388 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 389 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 390 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 391 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 392 | Build for PSA Functional API compliance tests |
| 393 | ============================================= |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 394 | The build system provides support for building and integrating the PSA API tests |
| 395 | from https://github.com/ARM-software/psa-arch-tests. PSA API tests are |
| 396 | controlled using the TEST_PSA_API variable. Enabling both regression tests and |
| 397 | PSA API tests simultaneously is **not** supported. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 398 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 399 | 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] | 400 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 401 | .. code-block:: bash |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 402 | |
| 403 | -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE |
| 404 | -DTEST_PSA_API=PROTECTED_STORAGE |
| 405 | -DTEST_PSA_API=STORAGE |
| 406 | -DTEST_PSA_API=CRYPTO |
| 407 | -DTEST_PSA_API=INITIAL_ATTESTATION |
| 408 | |
| 409 | Respectively for the corresponding service. For example, to enable the PSA API |
| 410 | tests for the Crypto service: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 411 | |
| 412 | .. code-block:: bash |
| 413 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 414 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 415 | 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] | 416 | cmake --build cmake_build -- install |
| 417 | |
| 418 | Alternately using traditional cmake syntax |
| 419 | |
| 420 | .. code-block:: bash |
| 421 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 422 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 423 | mkdir cmake_build |
| 424 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 425 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 426 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 427 | |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 428 | Build for PSA FF (IPC) compliance tests |
| 429 | ======================================= |
| 430 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 431 | The build system provides support for building and integrating the PSA FF |
| 432 | compliance test. This support is controlled by the TEST_PSA_API variable: |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 433 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 434 | .. code-block:: bash |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 435 | |
| 436 | -DTEST_PSA_API=IPC |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 437 | |
| 438 | .. code-block:: bash |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 439 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 440 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 441 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=IPC -DTFM_PSA_API=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 442 | cmake --build cmake_build -- install |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 443 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 444 | Alternately using traditional cmake syntax |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 445 | |
| 446 | .. code-block:: bash |
| 447 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 448 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 449 | mkdir cmake_build |
| 450 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 451 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=IPC -DTFM_PSA_API=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 452 | make install |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 453 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 454 | Location of build artifacts |
| 455 | =========================== |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 456 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 457 | All build artifacts are provided in the ``<build_dir>/bin`` directory. It is |
| 458 | **not** required to run ``make install`` to generate artifacts in this location. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 459 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 460 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 461 | For the purposes of maintaining compatibility with the legacy cmake build |
| 462 | system, they are also provided in |
| 463 | ``<build_dir>/install/outputs/<target_platform>/``. In order to generate the |
| 464 | artifacts in this location ``make install`` must be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 465 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 466 | **************************** |
| 467 | Manual dependency management |
| 468 | **************************** |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 469 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 470 | The TF-M build system will by default fetch all dependencies with appropriate |
| 471 | versions and store them inside the build tree. In this case, the build tree |
| 472 | location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by |
| 473 | deleting that directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 474 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 475 | If you have local copies already, and wish to avoid having the libraries |
| 476 | downloaded every time the build directory is deleted, then the following |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 477 | variables can be set to the path to the root directory of the local repo. This |
| 478 | will disable the automatic downloading for that dependency. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 479 | |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 480 | +----------------+---------------------+-----------------------------------------------------+ |
| 481 | | Dependency | Cmake variable | Git repo URL | |
| 482 | +================+=====================+=====================================================+ |
| 483 | | Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls | |
| 484 | +----------------+---------------------+-----------------------------------------------------+ |
| 485 | | tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git | |
| 486 | +----------------+---------------------+-----------------------------------------------------+ |
| 487 | | MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot | |
| 488 | +----------------+---------------------+-----------------------------------------------------+ |
| 489 | | psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests | |
| 490 | +----------------+---------------------+-----------------------------------------------------+ |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 491 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 492 | For required versions of the dependencies, refer to ``config/config_default.cmake``. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 493 | |
| 494 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 495 | - Some patches are required to the mbedtls repo to allow building it as part of |
| 496 | TF-M. While these patches are being upstreamed they are stored in |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 497 | ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is |
| 498 | required to apply all patch files in this directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 499 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 500 | .. Note:: |
| 501 | - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different |
| 502 | source for CMSIS 5, it can be configured using CMSIS_5_PATH. |
David Hu | 2cbf5df | 2020-06-15 10:41:44 +0800 | [diff] [blame] | 503 | |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 504 | TF-M Tests |
| 505 | ========== |
| 506 | |
| 507 | Dependency auto downloading is used by default. |
| 508 | The TF-M build system downloads the tf-m-tests repo with a fixed version |
| 509 | specified by ``TFM_TEST_REPO_VERSION`` in ``config/config_default.cmake``. |
| 510 | The version can be a release tag or a commit hash. |
| 511 | |
| 512 | Developers who want a different version of tf-m-tests can override |
| 513 | ``TFM_TEST_REPO_PATH`` to a local copy with the desired version. |
| 514 | |
| 515 | As the test repo is part of the TF-M project and coupled with TF-M repo a lot, |
| 516 | The version should be updated when there are dependency changes between the TF-M |
| 517 | repo and the test repo and when there is a complete change merged in test repo. |
| 518 | |
| 519 | A complete change is one or more patches that are for the same purpose, for |
| 520 | example a new test suite or enhancements on the test cases. |
| 521 | Patches in one change can be merge individually provided they do not break |
| 522 | anything or cause any regressions. |
| 523 | But the version in the TF-M gets updated only when all the patches are merged. |
| 524 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 525 | Example: building TF-M for AN521 platform with local Mbed Crypto |
| 526 | ================================================================ |
| 527 | |
| 528 | Prepare Mbed Crypto repository |
| 529 | ------------------------------ |
| 530 | |
| 531 | This is only required to be done once. For dependencies that do not have any |
| 532 | ``.patch`` files in their ``lib/ext`` directory the only required step is |
| 533 | cloning the repo and checking out the correct branch. |
| 534 | |
| 535 | .. code-block:: bash |
| 536 | |
| 537 | cd <Mbed Crypto base folder> |
| 538 | git clone https://github.com/ARMmbed/mbedtls |
| 539 | cd mbedtls |
| 540 | git checkout <MBEDCRYPTO_VERSION from config_default.cmake> |
| 541 | git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch |
| 542 | |
| 543 | .. Note:: |
| 544 | - <Mbed Crypto base folder> does not need to have any fixed posisition related |
| 545 | to the TF-M repo. |
| 546 | |
| 547 | Build TF-M |
| 548 | ---------- |
| 549 | |
| 550 | With new cmake syntax |
| 551 | |
| 552 | .. code-block:: bash |
| 553 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 554 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 555 | 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] | 556 | cmake --build cmake_build -- install |
| 557 | |
| 558 | Alternately using traditional cmake syntax |
| 559 | |
| 560 | .. code-block:: bash |
| 561 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 562 | cd <TF-M base folder> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 563 | mkdir cmake_build |
| 564 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 565 | 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] | 566 | make install |
| 567 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 568 | -------------- |
| 569 | |
Summer Qin | abf6698 | 2021-04-06 17:22:15 +0800 | [diff] [blame] | 570 | *Copyright (c) 2017-2021, Arm Limited. All rights reserved.* |