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