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