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