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 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 87 | Build type |
| 88 | ---------- |
| 89 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 90 | By default, a release configuration is built. Alternate build types can be |
| 91 | specified with the ``CMAKE_BUILD_TYPE`` variable. The possible |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 92 | types are: |
| 93 | |
| 94 | - ``Debug`` |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 95 | - ``RelWithDebInfo`` |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 96 | - ``Release`` |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 97 | - ``MinSizeRel`` |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 98 | |
| 99 | ``Release`` is default. |
| 100 | |
Sebastian Bøe | b73f176 | 2021-10-28 14:23:13 +0200 | [diff] [blame] | 101 | Debug symbols are added by default to all builds, but can be removed |
| 102 | from ``Release`` and ``MinSizeRel`` builds by setting |
| 103 | ``TFM_DEBUG_SYMBOLS`` to ``OFF``. |
| 104 | |
| 105 | ``RelWithDebInfo``, ``Release`` and ``MinSizeRel`` all have different |
| 106 | optimizations turned on and hence will produce smaller, faster code |
| 107 | than ``Debug``. ``MinSizeRel`` will produce the smallest code, and |
| 108 | hence is often a good idea on RAM or flash constrained systems. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 109 | |
| 110 | Other cmake parameters |
| 111 | ---------------------- |
| 112 | |
| 113 | The full list of default options is in ``config/config_default.cmake``. Several |
| 114 | important options are listed below. |
| 115 | |
| 116 | |
| 117 | +---------------------+----------------------------------------+---------------+ |
| 118 | | Parameter | Description | Default value | |
| 119 | +=====================+========================================+===============+ |
| 120 | | BL2 | Build level 2 secure bootloader. | ON | |
| 121 | +---------------------+----------------------------------------+---------------+ |
| 122 | | NS | Build NS app. Required for test code. | ON | |
| 123 | +---------------------+----------------------------------------+---------------+ |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 124 | | TFM_LIB_MODEL | Use secure library model instead of | OFF | |
| 125 | | | PSA api (IPC model). | | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 126 | +---------------------+----------------------------------------+---------------+ |
| 127 | | TFM_ISOLATION_LEVEL | Set TFM isolation level. | 1 | |
| 128 | +---------------------+----------------------------------------+---------------+ |
| 129 | | TFM_PROFILE | Set TFM profile. | | |
| 130 | +---------------------+----------------------------------------+---------------+ |
| 131 | | TEST_S | Build secure regression tests. | OFF | |
| 132 | +---------------------+----------------------------------------+---------------+ |
| 133 | | TEST_NS | Build non-secure regression tests. | OFF | |
| 134 | +---------------------+----------------------------------------+---------------+ |
| 135 | | TEST_PSA_API | Build PSA API TESTS for the given | | |
| 136 | | | suite. Takes a PSA api ``SUITE`` as an | | |
| 137 | | | argument (``CRYPTO`` etc). | | |
| 138 | +---------------------+----------------------------------------+---------------+ |
| 139 | |
| 140 | Regression test configuration |
| 141 | ----------------------------- |
| 142 | |
shejia01 | bfd3712 | 2021-06-03 13:31:51 +0800 | [diff] [blame] | 143 | Regression test configuration is controlled entirely by ``TEST_NS`` or |
| 144 | ``TEST_S`` or single test suite configuration. The group test |
| 145 | configurations and single test suite configurations are listed below, all of |
| 146 | them are disabled by default. |
| 147 | |
| 148 | +---------------------+--------------------------------------------------------------------+ |
| 149 | | Parameter | Description | |
| 150 | +=====================+====================================================================+ |
| 151 | | TEST_NS_ATTESTATION | Build non-secure regression Attestation tests. | |
| 152 | +---------------------+--------------------------------------------------------------------+ |
| 153 | | TEST_NS_T_COSE | Build non-secure regression t_cose tests. | |
| 154 | +---------------------+--------------------------------------------------------------------+ |
| 155 | | TEST_NS_QCBOR | Build non-secure regression QCBOR tests. | |
| 156 | +---------------------+--------------------------------------------------------------------+ |
| 157 | | TEST_NS_AUDIT | Build non-secure regression Audit log tests. | |
| 158 | +---------------------+--------------------------------------------------------------------+ |
| 159 | | TEST_NS_CORE | Build non-secure regression Core tests. | |
| 160 | +---------------------+--------------------------------------------------------------------+ |
| 161 | | TEST_NS_CRYPTO | Build non-secure regression Crypto tests. | |
| 162 | +---------------------+--------------------------------------------------------------------+ |
| 163 | | TEST_NS_ITS | Build non-secure regression ITS tests. | |
| 164 | +---------------------+--------------------------------------------------------------------+ |
| 165 | | TEST_NS_PS | Build non-secure regression PS tests. | |
| 166 | +---------------------+--------------------------------------------------------------------+ |
| 167 | | TEST_NS_PLATFORM | Build non-secure regression Platform tests. | |
| 168 | +---------------------+--------------------------------------------------------------------+ |
| 169 | | TEST_NS_FWU | Build non-secure regression FWU tests. | |
| 170 | +---------------------+--------------------------------------------------------------------+ |
| 171 | | TEST_NS_IPC | Build non-secure regression IPC tests. | |
| 172 | +---------------------+--------------------------------------------------------------------+ |
| 173 | | TEST_NS_SLIH_IRQ | Build non-secure regression Second-Level Interrupt Handling tests. | |
| 174 | +---------------------+--------------------------------------------------------------------+ |
| 175 | | TEST_NS_FLIH_IRQ | Build non-secure regression First-Level Interrupt Handling tests. | |
| 176 | +---------------------+--------------------------------------------------------------------+ |
| 177 | | TEST_NS_MULTI_CORE | Build non-secure regression multi-core tests. | |
| 178 | +---------------------+--------------------------------------------------------------------+ |
| 179 | | TEST_S_ATTESTATION | Build secure regression Attestation tests. | |
| 180 | +---------------------+--------------------------------------------------------------------+ |
| 181 | | TEST_S_AUDIT | Build secure regression Audit log tests. | |
| 182 | +---------------------+--------------------------------------------------------------------+ |
| 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 | |
| 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 | +-----------------------------+-------------------------------------+---------------+ |
Abbas Bracken Ziad | 46a21b6 | 2021-08-31 13:03:56 +0100 | [diff] [blame] | 219 | | TFM_CRYPTO_TEST_ALG_ECB | Test ECB cryptography mode | ON | |
| 220 | +-----------------------------+-------------------------------------+---------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 221 | | TFM_CRYPTO_TEST_ALG_CTR | Test CTR cryptography mode | ON | |
| 222 | +-----------------------------+-------------------------------------+---------------+ |
Abbas Bracken Ziad | 3d262f4 | 2021-08-19 15:07:05 +0100 | [diff] [blame] | 223 | | TFM_CRYPTO_TEST_ALG_OFB | Test OFB cryptography mode | ON | |
| 224 | +-----------------------------+-------------------------------------+---------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 225 | | TFM_CRYPTO_TEST_ALG_GCM | Test GCM cryptography mode | ON | |
| 226 | +-----------------------------+-------------------------------------+---------------+ |
| 227 | | TFM_CRYPTO_TEST_ALG_SHA_512 | Test SHA-512 cryptography algorithm | ON | |
| 228 | +-----------------------------+-------------------------------------+---------------+ |
Antonio de Angelis | 6eb5ecb | 2021-07-29 11:33:48 +0200 | [diff] [blame] | 229 | | TFM_CRYPTO_TEST_HKDF | Test HKDF key derivation algorithm | ON | |
| 230 | +-----------------------------+-------------------------------------+---------------+ |
| 231 | | TFM_CRYPTO_TEST_ECDH | Test ECDH key agreement algorithm | ON | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 232 | +-----------------------------+-------------------------------------+---------------+ |
| 233 | |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 234 | TF-M Profiles |
| 235 | ------------- |
| 236 | |
| 237 | TF-M Profiles are implemented as a single cmake configuration file, under the |
| 238 | ``config/profile`` directory. A good understanding can be gained quickly by |
| 239 | looking at the Profile configuration files, but the ultimate reference for |
Summer Qin | abf6698 | 2021-04-06 17:22:15 +0800 | [diff] [blame] | 240 | Profiles are the design documents in the ``docs/technical_references/profiles/`` |
Anton Komlev | 211aacf | 2020-11-02 12:48:11 +0000 | [diff] [blame] | 241 | directory. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 242 | |
| 243 | PSA test configuration |
| 244 | ---------------------- |
| 245 | |
| 246 | PSA tests are configured by using the ``TEST_PSA_API`` cmake variable. The |
| 247 | variable should be set to the name of the test suite that is desired. It is |
| 248 | _not_ supported to set both ``TEST_PSA_API`` and ``TEST_S`` or ``TEST_NS``. |
| 249 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 250 | The Functional API tests are: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 251 | - ``CRYPTO`` |
| 252 | - ``INITIAL_ATTESTATION`` |
| 253 | - ``STORAGE`` (INTERNAL_TRUSTED_STORAGE and PROTECTED_STORAGE) |
| 254 | - ``INTERNAL_TRUSTED_STORAGE`` |
| 255 | - ``PROTECTED_STORAGE`` |
| 256 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 257 | The Firmware Framework test suites are: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 258 | - ``IPC`` |
| 259 | |
| 260 | Note that these map directly to the ``SUITE`` cmake variable used in the |
| 261 | psa-arch-tests documentation. |
| 262 | |
David Wang | d6fd6af | 2021-06-21 17:17:26 +0800 | [diff] [blame] | 263 | .. _Migration from legacy buildsystem: |
| 264 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 265 | Migration from legacy buildsystem |
| 266 | --------------------------------- |
| 267 | |
| 268 | The previous (legacy) cmake buildsystem made use of separate configuration |
| 269 | files, where now build options are controlled by variables. For ease of |
| 270 | transition, a table below is provided that maps the legacy files to the current |
| 271 | variables, in the format of cmake command line parameters. |
| 272 | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 273 | +------------------------------------------+---------------------------------------+ |
| 274 | | File | Cmake command line | |
| 275 | +==========================================+=======================================+ |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 276 | | ConfigDefault.cmake | -DTFM_LIB_MODEL=ON | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 277 | +------------------------------------------+---------------------------------------+ |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 278 | | ConfigCoreIPC.cmake | <no options> | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 279 | +------------------------------------------+---------------------------------------+ |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 280 | | ConfigCoreIPCTfmLevel2.cmake | -DTFM_ISOLATION_LEVEL=2 | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 281 | +------------------------------------------+---------------------------------------+ |
| 282 | | ConfigDefaultProfileS.cmake | -DTFM_PROFILE=profile_small | |
| 283 | +------------------------------------------+---------------------------------------+ |
| 284 | | ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium | |
| 285 | +------------------------------------------+---------------------------------------+ |
| 286 | | ConfigRegression.cmake | -DTEST_NS=ON -DTEST_S=ON | |
| 287 | +------------------------------------------+---------------------------------------+ |
| 288 | | ConfigRegressionIPC.cmake | -DTEST_NS=ON -DTEST_S=ON | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 289 | +------------------------------------------+---------------------------------------+ |
| 290 | | ConfigRegressionIPCTfmLevel2.cmake | -DTEST_NS=ON -DTEST_S=ON | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 291 | | | -DTFM_ISOLATION_LEVEL=2 | |
| 292 | +------------------------------------------+---------------------------------------+ |
| 293 | | ConfigRegressionProfileS.cmake | -DTFM_PROFILE=profile_small | |
| 294 | | | -DTEST_NS=ON -DTEST_S=ON | |
| 295 | +------------------------------------------+---------------------------------------+ |
| 296 | | ConfigRegressionProfileM.cmake | -DTFM_PROFILE=profile_medium | |
| 297 | | | -DTEST_NS=ON -DTEST_S=ON | |
| 298 | +------------------------------------------+---------------------------------------+ |
| 299 | | ConfigPsaApiTest.cmake | -DTEST_PSA_API=<test_suite> | |
| 300 | +------------------------------------------+---------------------------------------+ |
| 301 | | ConfigPsaApiTestIPC.cmake | -DTEST_PSA_API=<test_suite> | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 302 | +------------------------------------------+---------------------------------------+ |
| 303 | | ConfigPsaApiTestIPCTfmLevel2.cmake | -DTEST_PSA_API=<test_suite> | |
Summer Qin | 001ce9d | 2020-11-04 14:41:54 +0800 | [diff] [blame] | 304 | | | -DTFM_ISOLATION_LEVEL=2 | |
| 305 | +------------------------------------------+---------------------------------------+ |
| 306 | | ConfigDefaultProfileM.cmake | -DTFM_PROFILE=profile_medium | |
| 307 | | + profile_m_config_ext_ps_disabled.cmake | -DTFM_PARTITION_PROTECTED_STORAGE=OFF | |
| 308 | +------------------------------------------+---------------------------------------+ |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 309 | |
| 310 | There has also been some changes to the PSA manifest file generation. The files |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 311 | are now generated into a separate tree in the ``<tfm build dir>/generated`` |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 312 | directory. Therefore they have been removed from the source tree. Any changes |
| 313 | should be made only to the template files. |
| 314 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 315 | The API for the ``tools/tfm_parse_manifest_list.py`` script has also changed |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 316 | slightly. It is no longer required to be run manually as it is run as part of |
| 317 | cmake. |
| 318 | |
| 319 | ******************* |
| 320 | TF-M build examples |
| 321 | ******************* |
| 322 | |
| 323 | Example: building TF-M for AN521 platform using GCC: |
| 324 | ==================================================== |
| 325 | .. code-block:: bash |
| 326 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 327 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 328 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 329 | cmake --build cmake_build -- install |
| 330 | |
| 331 | Alternately using traditional cmake syntax |
| 332 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 333 | .. code-block:: bash |
| 334 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 335 | cd <TF-M base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 336 | mkdir cmake_build |
| 337 | cd cmake_build |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 338 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 339 | make install |
| 340 | |
| 341 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 342 | |
| 343 | It is recommended to build each different build configuration in a separate |
| 344 | build directory. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 345 | |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 346 | The default build uses Unix Makefiles. The ``-G`` option can be used to change |
| 347 | this. The default build uses the GNU ARM toolchain and creates a Release build. |
| 348 | These options can be overridden using the ``TFM_TOOLCHAIN_FILE`` and |
| 349 | ``CMAKE_BUILD_TYPE`` parameters, as shown below |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 350 | |
| 351 | .. code-block:: bash |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 352 | |
Leonardo Sandoval | 49a558c | 2021-02-03 17:04:22 -0600 | [diff] [blame] | 353 | cd <TF-M base folder> |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 354 | 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] | 355 | cmake --build cmake_build -- install |
| 356 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 357 | Regression Tests for the AN521 target platform |
| 358 | ============================================== |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 359 | |
| 360 | Regression tests can be build by using the TEST_S and TEST_NS settings. Either |
| 361 | can be used in isolation or both can be used to enable both suites. All tests |
| 362 | for all enabled partitions are run, along with IPC and Multicore tests if those |
| 363 | features are enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 364 | |
| 365 | .. code-block:: bash |
| 366 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 367 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 368 | 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] | 369 | cmake --build cmake_build -- install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 370 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 371 | Alternately using traditional cmake syntax |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 372 | |
| 373 | .. code-block:: bash |
| 374 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 375 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 376 | mkdir cmake_build |
| 377 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 378 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_S=ON -DTEST_NS=ON |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 379 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 380 | |
Kevin Peng | 23a583c | 2021-09-08 22:33:33 +0800 | [diff] [blame] | 381 | Build for PSA API tests |
| 382 | ======================= |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 383 | The build system provides support for building and integrating the PSA API tests |
| 384 | from https://github.com/ARM-software/psa-arch-tests. PSA API tests are |
| 385 | controlled using the TEST_PSA_API variable. Enabling both regression tests and |
| 386 | PSA API tests simultaneously is **not** supported. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 387 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 388 | 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] | 389 | |
Subhasish Ghosh | bc84930 | 2021-04-08 20:21:20 +0100 | [diff] [blame] | 390 | .. code-block:: bash |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 391 | |
| 392 | -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE |
| 393 | -DTEST_PSA_API=PROTECTED_STORAGE |
| 394 | -DTEST_PSA_API=STORAGE |
| 395 | -DTEST_PSA_API=CRYPTO |
| 396 | -DTEST_PSA_API=INITIAL_ATTESTATION |
| 397 | |
| 398 | Respectively for the corresponding service. For example, to enable the PSA API |
| 399 | tests for the Crypto service: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 400 | |
| 401 | .. code-block:: bash |
| 402 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 403 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 404 | 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] | 405 | cmake --build cmake_build -- install |
| 406 | |
| 407 | Alternately using traditional cmake syntax |
| 408 | |
| 409 | .. code-block:: bash |
| 410 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 411 | cd <TF-M base folder> |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 412 | mkdir cmake_build |
| 413 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 414 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTEST_PSA_API=CRYPTO |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 415 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 416 | |
| 417 | Location of build artifacts |
| 418 | =========================== |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 419 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 420 | All build artifacts are provided in the ``<build_dir>/bin`` directory. It is |
| 421 | **not** required to run ``make install`` to generate artifacts in this location. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 422 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 423 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 424 | For the purposes of maintaining compatibility with the legacy cmake build |
| 425 | system, they are also provided in |
| 426 | ``<build_dir>/install/outputs/<target_platform>/``. In order to generate the |
| 427 | artifacts in this location ``make install`` must be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 428 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 429 | **************************** |
| 430 | Manual dependency management |
| 431 | **************************** |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 432 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 433 | The TF-M build system will by default fetch all dependencies with appropriate |
| 434 | versions and store them inside the build tree. In this case, the build tree |
| 435 | location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by |
| 436 | deleting that directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 437 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 438 | If you have local copies already, and wish to avoid having the libraries |
| 439 | downloaded every time the build directory is deleted, then the following |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 440 | variables can be set to the path to the root directory of the local repo. This |
| 441 | will disable the automatic downloading for that dependency. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 442 | |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame] | 443 | +----------------+---------------------+-----------------------------------------------------+ |
| 444 | | Dependency | Cmake variable | Git repo URL | |
| 445 | +================+=====================+=====================================================+ |
| 446 | | Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls | |
| 447 | +----------------+---------------------+-----------------------------------------------------+ |
| 448 | | tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git | |
| 449 | +----------------+---------------------+-----------------------------------------------------+ |
| 450 | | MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot | |
| 451 | +----------------+---------------------+-----------------------------------------------------+ |
| 452 | | psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests | |
| 453 | +----------------+---------------------+-----------------------------------------------------+ |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 454 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 455 | For required versions of the dependencies, refer to ``config/config_default.cmake``. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 456 | |
| 457 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 458 | - Some patches are required to the mbedtls repo to allow building it as part of |
| 459 | TF-M. While these patches are being upstreamed they are stored in |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 460 | ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is |
| 461 | required to apply all patch files in this directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 462 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 463 | .. Note:: |
| 464 | - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different |
| 465 | source for CMSIS 5, it can be configured using CMSIS_5_PATH. |
David Hu | 2cbf5df | 2020-06-15 10:41:44 +0800 | [diff] [blame] | 466 | |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 467 | TF-M Tests |
| 468 | ========== |
| 469 | |
| 470 | Dependency auto downloading is used by default. |
| 471 | 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] | 472 | specified by ``TFM_TEST_REPO_VERSION`` in |
| 473 | :file:`lib/ext/tf-m-tests/repo_config_default.cmake`. |
Kevin Peng | cba37d3 | 2020-12-07 17:07:39 +0800 | [diff] [blame] | 474 | The version can be a release tag or a commit hash. |
| 475 | |
| 476 | Developers who want a different version of tf-m-tests can override |
| 477 | ``TFM_TEST_REPO_PATH`` to a local copy with the desired version. |
| 478 | |
David Hu | f89bcb6 | 2021-09-06 15:02:34 +0800 | [diff] [blame] | 479 | As the test repo is part of the TF-M project and coupled with TF-M repo, |
| 480 | 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] | 481 | repo and the test repo and when there is a complete change merged in test repo. |
| 482 | |
| 483 | A complete change is one or more patches that are for the same purpose, for |
| 484 | example a new test suite or enhancements on the test cases. |
| 485 | Patches in one change can be merge individually provided they do not break |
| 486 | anything or cause any regressions. |
| 487 | But the version in the TF-M gets updated only when all the patches are merged. |
| 488 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 489 | Example: building TF-M for AN521 platform with local Mbed Crypto |
| 490 | ================================================================ |
| 491 | |
| 492 | Prepare Mbed Crypto repository |
| 493 | ------------------------------ |
| 494 | |
| 495 | This is only required to be done once. For dependencies that do not have any |
| 496 | ``.patch`` files in their ``lib/ext`` directory the only required step is |
| 497 | cloning the repo and checking out the correct branch. |
| 498 | |
| 499 | .. code-block:: bash |
| 500 | |
| 501 | cd <Mbed Crypto base folder> |
| 502 | git clone https://github.com/ARMmbed/mbedtls |
| 503 | cd mbedtls |
| 504 | git checkout <MBEDCRYPTO_VERSION from config_default.cmake> |
| 505 | git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch |
| 506 | |
| 507 | .. Note:: |
| 508 | - <Mbed Crypto base folder> does not need to have any fixed posisition related |
| 509 | to the TF-M repo. |
| 510 | |
| 511 | Build TF-M |
| 512 | ---------- |
| 513 | |
| 514 | With new cmake syntax |
| 515 | |
| 516 | .. code-block:: bash |
| 517 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 518 | cd <TF-M base folder> |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 519 | 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] | 520 | cmake --build cmake_build -- install |
| 521 | |
| 522 | Alternately using traditional cmake syntax |
| 523 | |
| 524 | .. code-block:: bash |
| 525 | |
Leonardo Sandoval | 9835014 | 2021-02-03 16:32:14 -0600 | [diff] [blame] | 526 | cd <TF-M base folder> |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 527 | mkdir cmake_build |
| 528 | cd cmake_build |
Summer Qin | 2de23d0 | 2021-05-14 13:44:14 +0800 | [diff] [blame] | 529 | 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] | 530 | make install |
| 531 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 532 | -------------- |
| 533 | |
Summer Qin | abf6698 | 2021-04-06 17:22:15 +0800 | [diff] [blame] | 534 | *Copyright (c) 2017-2021, Arm Limited. All rights reserved.* |
Chris Brand | 80266ba | 2022-01-05 09:14:52 -0800 | [diff] [blame] | 535 | *Copyright (c) 2022, Cypress Semiconductor Corporation. All rights reserved.* |