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 | |
| 22 | Dependency management is now handled by cmake. If you wish to alter this |
| 23 | behaviour, see :ref:`docs/getting_started/tfm_build_instruction:Manual |
| 24 | dependency management` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 25 | |
Minos Galanakis | ac6b06c | 2020-03-19 12:57:02 +0000 | [diff] [blame] | 26 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 27 | |
Minos Galanakis | 3b740a1 | 2020-10-15 11:10:26 +0100 | [diff] [blame] | 28 | - For building with Armclang compiler version 6.10.0+, please follow the note |
| 29 | in :doc:`software requirements <tfm_sw_requirement>`. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 30 | - For building with the IAR toolchain, please see the notes in |
Minos Galanakis | 3b740a1 | 2020-10-15 11:10:26 +0100 | [diff] [blame] | 31 | :doc:`IAR software requirements <tfm_build_instruction_iar>` |
TTornblom | b9e5ed0 | 2020-02-13 16:53:15 +0100 | [diff] [blame] | 32 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 33 | .. _tfm_cmake_configuration: |
| 34 | |
| 35 | Cmake configuration |
| 36 | =================== |
| 37 | |
| 38 | All configuration options are provided by cmake variables, and their default |
| 39 | values, with docstrings, can be found in ``config/config_default.cmake``. |
| 40 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 41 | Configuration is provided in multiple stages. Each stage will not override any |
| 42 | config that has already been set at any of the prior stages. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 43 | |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 44 | 1. Command-line variable settings are applied. |
| 45 | 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] | 46 | loaded. |
Tamas Ban | 6921920 | 2020-10-27 08:13:18 +0000 | [diff] [blame] | 47 | 3. If TEST_PSA_TEST is set, then PSA API test related config is applied from |
| 48 | ``config/tests/config_test_psa_api.cmake``. |
| 49 | 4. If it exists, CMAKE_BUILD_TYPE specific config is applied from |
| 50 | ``config/build_type/<build_type>.cmake``. |
| 51 | 5. Target specific config from ``platform/ext/target/<target_platform>/config.cmake`` |
| 52 | is applied. |
| 53 | 6. If CRYPTO_HW_ACCELERATOR is set, then a config specific to the |
| 54 | accelerator type is applied if it exists. |
| 55 | 7. If it exists, TFM Profile specific config is applied from |
| 56 | ``config/profile/<tfm_profile>.cmake``. |
| 57 | 8. ``config/config_default.cmake`` is loaded. |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 58 | |
| 59 | .. Warning:: |
| 60 | This means that command-line settings are not applied when they conflict |
| 61 | with required platform settings. If it is required to override platform |
| 62 | settings (this is not usually a good idea) then TFM_EXTRA_CONFIG_PATH should be |
| 63 | used. |
| 64 | |
| 65 | Required cmake parameters for building TF-M |
| 66 | ------------------------------------------- |
| 67 | |
| 68 | +----------------------+-------------------------------------------------------+ |
| 69 | | Parameter | Description | |
| 70 | +======================+=======================================================+ |
| 71 | | TFM_PLATFORM | The target platform as a path from the base directory | |
| 72 | | | ``/platform/ext/target`` | |
| 73 | +----------------------+-------------------------------------------------------+ |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 74 | | TFM_TOOLCHAIN_FILE | The path to the toolchain file that corresponds to | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 75 | | | the desired compiler. | |
| 76 | +----------------------+-------------------------------------------------------+ |
| 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 |
| 170 | Profiles are the design documents in the ``docs/design_documents/profiles/`` |
| 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 | |
| 256 | Example: building TF-M for AN521 platform using GCC: |
| 257 | ==================================================== |
| 258 | .. code-block:: bash |
| 259 | |
| 260 | cd <base folder> |
| 261 | cd trusted-firmware-m |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 262 | 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] | 263 | cmake --build cmake_build -- install |
| 264 | |
| 265 | Alternately using traditional cmake syntax |
| 266 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 267 | .. code-block:: bash |
| 268 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 269 | cd <base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 270 | cd trusted-firmware-m |
| 271 | mkdir cmake_build |
| 272 | cd cmake_build |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 273 | cmake .. -DTFM_PLATFORM=mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 274 | make install |
| 275 | |
| 276 | .. Note:: |
| 277 | Unix Makefiles is the default generator. Ninja is also supported by setting |
| 278 | -GNinja |
| 279 | |
| 280 | .. Note:: |
| 281 | |
| 282 | It is recommended to build each different build configuration in a separate |
| 283 | build directory. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 284 | |
| 285 | Regression Tests for the AN521 target platform |
| 286 | ============================================== |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 287 | |
| 288 | Regression tests can be build by using the TEST_S and TEST_NS settings. Either |
| 289 | can be used in isolation or both can be used to enable both suites. All tests |
| 290 | for all enabled partitions are run, along with IPC and Multicore tests if those |
| 291 | features are enabled. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 292 | |
| 293 | .. code-block:: bash |
| 294 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 295 | cd <base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 296 | cd trusted-firmware-m |
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 | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 304 | cd <base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 305 | cd trusted-firmware-m |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 306 | mkdir cmake_build |
| 307 | cd cmake_build |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 308 | 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] | 309 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 310 | |
Jamie Fox | 19c91c2 | 2019-02-10 18:04:58 +0000 | [diff] [blame] | 311 | Build for PSA Functional API compliance tests |
| 312 | ============================================= |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 313 | The build system provides support for building and integrating the PSA API tests |
| 314 | from https://github.com/ARM-software/psa-arch-tests. PSA API tests are |
| 315 | controlled using the TEST_PSA_API variable. Enabling both regression tests and |
| 316 | PSA API tests simultaneously is **not** supported. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 317 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 318 | 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] | 319 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 320 | .. code-block:: |
| 321 | |
| 322 | -DTEST_PSA_API=INTERNAL_TRUSTED_STORAGE |
| 323 | -DTEST_PSA_API=PROTECTED_STORAGE |
| 324 | -DTEST_PSA_API=STORAGE |
| 325 | -DTEST_PSA_API=CRYPTO |
| 326 | -DTEST_PSA_API=INITIAL_ATTESTATION |
| 327 | |
| 328 | Respectively for the corresponding service. For example, to enable the PSA API |
| 329 | tests for the Crypto service: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 330 | |
| 331 | .. code-block:: bash |
| 332 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 333 | cd <base folder> |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 334 | cd trusted-firmware-m |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 335 | 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] | 336 | cmake --build cmake_build -- install |
| 337 | |
| 338 | Alternately using traditional cmake syntax |
| 339 | |
| 340 | .. code-block:: bash |
| 341 | |
| 342 | cd <base folder> |
| 343 | cd trusted-firmware-m |
| 344 | mkdir cmake_build |
| 345 | cd cmake_build |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 346 | 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] | 347 | make install |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 348 | |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 349 | Build for PSA FF (IPC) compliance tests |
| 350 | ======================================= |
| 351 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 352 | The build system provides support for building and integrating the PSA FF |
| 353 | 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] | 354 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 355 | .. code-block:: |
| 356 | |
| 357 | -DTEST_PSA_API=IPC |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 358 | |
| 359 | .. code-block:: bash |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 360 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 361 | cd <base folder> |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 362 | cd trusted-firmware-m |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 363 | 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] | 364 | cmake --build cmake_build -- install |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 365 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 366 | Alternately using traditional cmake syntax |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 367 | |
| 368 | .. code-block:: bash |
| 369 | |
Leonardo Sandoval | d7f72d5 | 2020-07-28 18:02:34 -0500 | [diff] [blame] | 370 | cd <base folder> |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 371 | cd trusted-firmware-m |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 372 | mkdir cmake_build |
| 373 | cd cmake_build |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 374 | 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] | 375 | make install |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 376 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 377 | Location of build artifacts |
| 378 | =========================== |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 379 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 380 | All build artifacts are provided in the ``<build_dir>/bin`` directory. It is |
| 381 | **not** required to run ``make install`` to generate artifacts in this location. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 382 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 383 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 384 | For the purposes of maintaining compatibility with the legacy cmake build |
| 385 | system, they are also provided in |
| 386 | ``<build_dir>/install/outputs/<target_platform>/``. In order to generate the |
| 387 | artifacts in this location ``make install`` must be run. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 388 | |
| 389 | Building the documentation |
| 390 | ========================== |
Minos Galanakis | d19a19f | 2020-06-03 15:38:03 +0100 | [diff] [blame] | 391 | Please ensure the dependencies for building the documentation are installed |
| 392 | as explained in the :doc:`software requirements <tfm_sw_requirement>`. The |
| 393 | requirements to build the firmware, are only required when using the CMAKE |
| 394 | method |
| 395 | |
| 396 | There are currently two ways of building the documentation: |
| 397 | - Using the CMake build system as custom targets |
| 398 | - Manually using the appropriate tools (`sphinx-build`_/ `Doxygen`_) |
| 399 | |
| 400 | Using the CMake build-system |
| 401 | ---------------------------- |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 402 | |
Minos Galanakis | dff2eae | 2020-07-21 15:13:52 +0100 | [diff] [blame] | 403 | Building PDF output can be requested by invoking `tfm_docs_userguide_pdf/ |
| 404 | tfm_docs_userguide_pdf` |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 405 | |
| 406 | .. Note:: |
| 407 | For building the documentation all tools needed to build the firmware must |
| 408 | be available. |
| 409 | |
| 410 | Building the Reference Manual |
Minos Galanakis | d19a19f | 2020-06-03 15:38:03 +0100 | [diff] [blame] | 411 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 412 | .. code-block:: bash |
| 413 | |
| 414 | cd <TF-M base folder> |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 415 | 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] | 416 | cmake --build cmake_doc -- tfm_docs_refman_html tfm_docs_refman_pdf |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 417 | |
| 418 | The documentation files will be available under the directory:: |
| 419 | |
Minos Galanakis | dff2eae | 2020-07-21 15:13:52 +0100 | [diff] [blame] | 420 | cmake_doc/docs/reference_manual |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 421 | |
| 422 | Building the User Guide |
Minos Galanakis | d19a19f | 2020-06-03 15:38:03 +0100 | [diff] [blame] | 423 | ^^^^^^^^^^^^^^^^^^^^^^^ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 424 | .. code-block:: bash |
| 425 | |
| 426 | cd <TF-M base folder> |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 427 | 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] | 428 | cmake --build cmake_doc -- tfm_docs_userguide_html tfm_docs_userguide_pdf |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 429 | |
| 430 | The documentation files will be available under the directory:: |
| 431 | |
Minos Galanakis | dff2eae | 2020-07-21 15:13:52 +0100 | [diff] [blame] | 432 | cmake_doc/docs/user_guide |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 433 | |
Minos Galanakis | d19a19f | 2020-06-03 15:38:03 +0100 | [diff] [blame] | 434 | Manually using documentation generation tools |
| 435 | --------------------------------------------- |
| 436 | |
| 437 | Invoking Sphinx-build will build both user_guide and reference_manual |
| 438 | targets. |
| 439 | |
| 440 | .. code-block:: bash |
| 441 | |
| 442 | # Build the documentation from build_docs directory |
| 443 | cd <TF-M base folder>/ build_docs/ |
| 444 | sphinx-build ./ user_guide |
| 445 | |
| 446 | # Build the documentation from a custom location |
| 447 | # setting the build_docs as input |
| 448 | |
| 449 | # Note that using this method will still generate the reference manual |
| 450 | # to the <TF-M base folder>/build_docs/reference_manual |
| 451 | cd <TF-M base folder>/OTHER_DIR/OTHER_DIR2 |
| 452 | sphinx-build <TF-M base folder>/build_docs/ DESIRED_OUTPUT_DIR |
| 453 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 454 | **************************** |
| 455 | Manual dependency management |
| 456 | **************************** |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 457 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 458 | The TF-M build system will by default fetch all dependencies with appropriate |
| 459 | versions and store them inside the build tree. In this case, the build tree |
| 460 | location is ``<build_dir>/lib/ext``, and the extra libraries can be cleaned by |
| 461 | deleting that directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 462 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 463 | If you have local copies already, and wish to avoid having the libraries |
| 464 | downloaded every time the build directory is deleted, then the following |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame^] | 465 | variables can be set to the path to the root directory of the local repo. This |
| 466 | will disable the automatic downloading for that dependency. |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 467 | |
Raef Coles | c630b88 | 2020-12-10 15:46:18 +0000 | [diff] [blame^] | 468 | +----------------+---------------------+-----------------------------------------------------+ |
| 469 | | Dependency | Cmake variable | Git repo URL | |
| 470 | +================+=====================+=====================================================+ |
| 471 | | Mbed Crypto | MBEDCRYPTO_PATH | https://github.com/ARMmbed/mbedtls | |
| 472 | +----------------+---------------------+-----------------------------------------------------+ |
| 473 | | tf-m-tests | TFM_TEST_REPO_PATH | https://git.trustedfirmware.org/TF-M/tf-m-tests.git | |
| 474 | +----------------+---------------------+-----------------------------------------------------+ |
| 475 | | MCUboot | MCUBOOT_PATH | https://github.com/mcu-tools/mcuboot | |
| 476 | +----------------+---------------------+-----------------------------------------------------+ |
| 477 | | psa-arch-tests | PSA_ARCH_TESTS_PATH | https://github.com/ARM-software/psa-arch-tests | |
| 478 | +----------------+---------------------+-----------------------------------------------------+ |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 479 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 480 | For required versions of the dependencies, refer to ``config/config_default.cmake``. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 481 | |
| 482 | .. Note:: |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 483 | - Some patches are required to the mbedtls repo to allow building it as part of |
| 484 | TF-M. While these patches are being upstreamed they are stored in |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 485 | ``lib/ext/mbedcrypo``. In order to use a local copy of Mbed Crypto it is |
| 486 | required to apply all patch files in this directory. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 487 | |
Anton Komlev | b8e3af0 | 2020-08-28 10:23:57 +0100 | [diff] [blame] | 488 | .. Note:: |
| 489 | - CMSIS 5 is provided by the TF-M tests repo. If you wish to use a different |
| 490 | source for CMSIS 5, it can be configured using CMSIS_5_PATH. |
David Hu | 2cbf5df | 2020-06-15 10:41:44 +0800 | [diff] [blame] | 491 | |
Minos Galanakis | d19a19f | 2020-06-03 15:38:03 +0100 | [diff] [blame] | 492 | .. _sphinx-build: https://www.sphinx-doc.org/en/master/man/sphinx-build.html |
| 493 | .. _Doxygen: https://www.doxygen.nl |
| 494 | |
Raef Coles | 1ecb813 | 2020-10-02 15:11:24 +0100 | [diff] [blame] | 495 | Example: building TF-M for AN521 platform with local Mbed Crypto |
| 496 | ================================================================ |
| 497 | |
| 498 | Prepare Mbed Crypto repository |
| 499 | ------------------------------ |
| 500 | |
| 501 | This is only required to be done once. For dependencies that do not have any |
| 502 | ``.patch`` files in their ``lib/ext`` directory the only required step is |
| 503 | cloning the repo and checking out the correct branch. |
| 504 | |
| 505 | .. code-block:: bash |
| 506 | |
| 507 | cd <Mbed Crypto base folder> |
| 508 | git clone https://github.com/ARMmbed/mbedtls |
| 509 | cd mbedtls |
| 510 | git checkout <MBEDCRYPTO_VERSION from config_default.cmake> |
| 511 | git apply <TF-M base folder>/trusted-firmware-m/lib/ext/mbedcrypo/*.patch |
| 512 | |
| 513 | .. Note:: |
| 514 | - <Mbed Crypto base folder> does not need to have any fixed posisition related |
| 515 | to the TF-M repo. |
| 516 | |
| 517 | Build TF-M |
| 518 | ---------- |
| 519 | |
| 520 | With new cmake syntax |
| 521 | |
| 522 | .. code-block:: bash |
| 523 | |
| 524 | cd <base folder> |
| 525 | cd trusted-firmware-m |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 526 | 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] | 527 | cmake --build cmake_build -- install |
| 528 | |
| 529 | Alternately using traditional cmake syntax |
| 530 | |
| 531 | .. code-block:: bash |
| 532 | |
| 533 | cd <base folder> |
| 534 | cd trusted-firmware-m |
| 535 | mkdir cmake_build |
| 536 | cd cmake_build |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 537 | 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] | 538 | make install |
| 539 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 540 | -------------- |
| 541 | |
Galanakis, Minos | dc6694b | 2020-01-06 13:54:56 +0000 | [diff] [blame] | 542 | *Copyright (c) 2017-2020, Arm Limited. All rights reserved.* |