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 | |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 7 | The external dependecies are briefly listed in the |
Minos Galanakis | ac6b06c | 2020-03-19 12:57:02 +0000 | [diff] [blame^] | 8 | :ref:`docs/user_guides/tfm_sw_requirement:External dependencies` section. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 9 | |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 10 | The configuration-table |
| 11 | :ref:`docs/user_guides/tfm_build_instruction:Configuring the build` section |
| 12 | explains all the supported build parameters: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 13 | |
| 14 | **************** |
| 15 | TF-M build steps |
| 16 | **************** |
| 17 | TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source |
| 18 | build environment. The instructions are below. |
| 19 | |
| 20 | .. Note:: |
| 21 | |
| 22 | It is recommended to build each different build configurations in separate |
| 23 | directories. |
| 24 | |
| 25 | Getting the source-code |
| 26 | ======================= |
| 27 | .. code-block:: bash |
| 28 | |
| 29 | cd <TF-M base folder> |
| 30 | git clone https://git.trustedfirmware.org/trusted-firmware-m.git |
Antonio de Angelis | 04debbd | 2019-10-14 12:12:52 +0100 | [diff] [blame] | 31 | git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-3.0.1 |
Antonio de Angelis | 70ae80f | 2019-02-26 14:57:40 +0000 | [diff] [blame] | 32 | git clone https://github.com/ARM-software/CMSIS_5.git -b 5.5.0 |
| 33 | |
| 34 | .. Note:: |
| 35 | `CMSIS_5` now uses `git-lfs` for storing large size binaries so the cloning |
| 36 | process has changed from previous releases. Please refer to the `CMSIS_5` |
| 37 | documentation for more details. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 38 | |
Minos Galanakis | ac6b06c | 2020-03-19 12:57:02 +0000 | [diff] [blame^] | 39 | .. Note:: |
| 40 | For building with Armclang compiler version 6.10.0, please follow the note |
| 41 | in :ref:`docs/user_guides/tfm_sw_requirement:External dependencies` section. |
| 42 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 43 | Build steps for the AN521 target platform: |
| 44 | ========================================== |
| 45 | .. code-block:: bash |
| 46 | |
| 47 | cd <TF-M base folder> |
| 48 | cd trusted-firmware-m |
| 49 | mkdir cmake_build |
| 50 | cd cmake_build |
| 51 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG |
| 52 | cmake --build ./ -- install |
| 53 | |
| 54 | Regression Tests for the AN521 target platform |
| 55 | ============================================== |
| 56 | *TF-M build regression tests on Linux* |
| 57 | |
| 58 | .. code-block:: bash |
| 59 | |
| 60 | cd <TF-M base folder> |
| 61 | cd trusted-firmware-m |
| 62 | mkdir cmake_test |
| 63 | cd cmake_test |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 64 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 65 | cmake --build ./ -- install |
| 66 | |
| 67 | *TF-M build regression tests on Windows* |
| 68 | |
| 69 | .. code-block:: bash |
| 70 | |
| 71 | cd <TF-M base folder> |
| 72 | cd trusted-firmware-m |
| 73 | mkdir cmake_test |
| 74 | cd cmake_test |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 75 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../configs/ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 76 | cmake --build ./ -- install |
| 77 | |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 78 | Build for PSA Developer API compliance tests |
| 79 | ============================================ |
| 80 | The build system provides the support for linking with prebuilt PSA Developer |
| 81 | API compliance NS test libraries when using the ``ConfigPsaApiTest.cmake``, |
Jamie Fox | 6b6a19b | 2019-09-30 16:54:17 +0100 | [diff] [blame] | 82 | ``ConfigPsaApiTestIPC.cmake`` or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config |
| 83 | file. The build system assumes that the PSA API compliance test suite is checked |
| 84 | out at the same level of the TF-M root folder and the default name for the build |
| 85 | folder has been used when compiling the PSA API compliance tests. Each set of |
| 86 | tests for the Internal Trusted Storage, Secure Storage, Crypto and Attestation |
| 87 | services needs to be enabled at the build configuration step by defining:: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 88 | |
Jamie Fox | 6b6a19b | 2019-09-30 16:54:17 +0100 | [diff] [blame] | 89 | -DPSA_API_TEST_INTERNAL_TRUSTED_STORAGE=ON |
Karl Zhang | 1895a2c | 2020-03-08 18:27:32 +0800 | [diff] [blame] | 90 | -DPSA_API_TEST_PROTECTED_STORAGE=ON |
Jamie Fox | 6b6a19b | 2019-09-30 16:54:17 +0100 | [diff] [blame] | 91 | -DPSA_API_TEST_CRYPTO=ON |
Karl Zhang | 1895a2c | 2020-03-08 18:27:32 +0800 | [diff] [blame] | 92 | -DPSA_API_TEST_INITIAL_ATTESTATION=ON |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 93 | |
| 94 | respectively for the corresponding service. For example, to enable the PSA API |
| 95 | tests for the Crypto service only: |
| 96 | |
| 97 | .. code-block:: bash |
| 98 | |
| 99 | cd <TF-M base folder> |
| 100 | cd trusted-firmware-m |
| 101 | mkdir cmake_psa_test |
| 102 | cd cmake_psa_test |
Antonio de Angelis | 0169b9f | 2019-06-28 11:37:24 +0100 | [diff] [blame] | 103 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTest.cmake` -DPSA_API_TEST_CRYPTO=ON -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 104 | cmake --build ./ -- install |
| 105 | |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 106 | Build for PSA FF (IPC) compliance tests |
| 107 | ======================================= |
| 108 | |
| 109 | The build system assumes that the PSA FF compliance test suite is checked out |
| 110 | at the same level of the TF-M root folder and the default name for the build |
| 111 | folder has been used when compiling the PSA FF compliance tests. |
| 112 | |
| 113 | Parse the PSA FF compliance tests partition manifests using a tool script named |
| 114 | as ``tfm_parse_manifest_list.py``. This tool updates the TFM partitions data |
| 115 | structure with PSA test suite partitions detail and creates the manifest output |
| 116 | files that are required for the PSA test suite build. Using these manifest |
| 117 | output files, build the PSA FF compliance tests as per the instructions |
| 118 | given in the PSA FF compliance tests README. |
| 119 | |
| 120 | .. code-block:: bash |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 121 | |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 122 | cd <TF-M base folder> |
| 123 | cd trusted-firmware-m |
Shawn Shan | adfb80f | 2020-03-11 10:25:21 +0800 | [diff] [blame] | 124 | python tools/tfm_parse_manifest_list.py -m tools/tfm_psa_ff_test_manifest_list.yaml append |
Jaykumar Pitambarbhai Patel | 6891b8b | 2020-01-23 14:32:20 +0530 | [diff] [blame] | 125 | |
| 126 | The build system provides the support for linking with prebuilt PSA FF |
| 127 | compliance NS and S test libraries when using the ``ConfigPsaApiTestIPC.cmake`` |
| 128 | or ``ConfigPsaApiTestIPCTfmLevel2.cmake`` config file. The PSA FF compliance |
| 129 | tests need to be enabled at the build configuration step by defining:: |
| 130 | |
| 131 | -DPSA_API_TEST_IPC=ON. |
| 132 | |
| 133 | For example, to enable the PSA FF tests for ConfigPsaApiTestIPCTfmLevel2.cmake |
| 134 | config : |
| 135 | |
| 136 | .. code-block:: bash |
| 137 | |
| 138 | cd <TF-M base folder> |
| 139 | cd trusted-firmware-m |
| 140 | mkdir cmake_psa_test |
| 141 | cd cmake_psa_test |
| 142 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../configs/ConfigPsaApiTestIPCTfmLevel2.cmake` -DPSA_API_TEST_IPC=ON -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
| 143 | cmake --build ./ -- install |
| 144 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 145 | Location of build artifacts |
| 146 | =========================== |
| 147 | The build system defines an API which allow easy usage of build |
| 148 | artifacts. The ``install`` build target copies all files which might be needed |
| 149 | as a dependency by external tools or build systems to the |
| 150 | ``<build_dir>/install/outputs`` |
| 151 | directory, with the following directory hierarchy: |
| 152 | |
| 153 | :: |
| 154 | |
| 155 | <build_dir>/install/outputs/fvp/ |
| 156 | <build_dir>/install/outputs/<target_platform>/ |
| 157 | |
| 158 | There is one folder for FVP testing, with more elaborate naming and |
| 159 | there is an other for testing on target hardware platform (AN521, etc.), where |
| 160 | naming convention is aligned with 8.3 format. The dependency tree of |
| 161 | ``install`` build target ensures a proper update (i.e. build) of all output |
| 162 | files before the actual installation step takes place. As such it is suggested |
| 163 | to use this build target to build TF-M. |
| 164 | |
| 165 | Export dependency files for NS applications |
| 166 | ------------------------------------------- |
| 167 | An NS application requires a number of files to interface with TF-M. |
| 168 | The build system exports these files as part of the ``install`` target and |
| 169 | places them in to a single directory:: |
| 170 | |
| 171 | <build_dir>/install/export/tfm |
| 172 | |
| 173 | Further details on how to integrate a new NS app with TF-M are available in the |
| 174 | :doc:`integration guide <tfm_integration_guide>`. |
| 175 | |
| 176 | Building the documentation |
| 177 | ========================== |
| 178 | Please ensure the dependencies for building the firmware and the |
| 179 | documentation are installed as explained in the |
| 180 | :doc:`software requirements <tfm_sw_requirement>`. |
| 181 | |
| 182 | Building PDF output is optional and can be disabled by removing LaTex from the |
| 183 | PATH. |
| 184 | |
| 185 | .. Note:: |
| 186 | For building the documentation all tools needed to build the firmware must |
| 187 | be available. |
| 188 | |
| 189 | Building the Reference Manual |
| 190 | ----------------------------- |
| 191 | .. code-block:: bash |
| 192 | |
| 193 | cd <TF-M base folder> |
| 194 | mkdir cmake_doc |
| 195 | cd cmake_doc |
| 196 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM |
| 197 | cmake --build ./ -- install_doc |
| 198 | |
| 199 | The documentation files will be available under the directory:: |
| 200 | |
| 201 | cmake_doc/install/doc/reference_manual |
| 202 | |
| 203 | Building the User Guide |
| 204 | ----------------------- |
| 205 | .. code-block:: bash |
| 206 | |
| 207 | cd <TF-M base folder> |
| 208 | mkdir cmake_doc |
| 209 | cd cmake_doc |
| 210 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG |
| 211 | cmake --build ./ -- install_userguide |
| 212 | |
| 213 | The documentation files will be available under the directory:: |
| 214 | |
| 215 | cmake_doc/install/doc/user_guide |
| 216 | |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 217 | ********************* |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 218 | Configuring the build |
| 219 | ********************* |
| 220 | The build configuration for TF-M is provided to the build system using command |
| 221 | line arguments: |
| 222 | |
| 223 | .. list-table:: |
| 224 | :widths: 20 80 |
| 225 | |
| 226 | * - -DPROJ_CONFIG=<file> |
| 227 | - Specifies the way the application is built. |
| 228 | |
| 229 | | <file> is the absolute path to configurations file |
| 230 | named as ``Config<APP_NAME>.cmake``. |
| 231 | | i.e. On Linux: |
| 232 | ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake``` |
| 233 | |
| 234 | * - -DTARGET_PLATFORM=<target platform name> |
| 235 | - Specifies the target platform. |
| 236 | Supported platforms: |
| 237 | |
| 238 | - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521) |
| 239 | ``-DTARGET_PLATFORM=AN521`` |
| 240 | - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519) |
| 241 | ``-DTARGET_PLATFORM=AN519`` |
Marton Berke | 8aae06f | 2019-11-25 16:46:12 +0100 | [diff] [blame] | 242 | - Arm SSE-123 Example Subsystem for MPS2+ (AN539) |
| 243 | ``-DTARGET_PLATFORM=AN539`` |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 244 | - Musca-A test chip board (Cortex-M33 SSE-200 subsystem) |
| 245 | ``-DTARGET_PLATFORM=MUSCA_A`` |
| 246 | - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem) |
| 247 | ``-DTARGET_PLATFORM=MUSCA_B1`` |
Marton Berke | 8aae06f | 2019-11-25 16:46:12 +0100 | [diff] [blame] | 248 | - Musca-S1 test chip board (Cortex-M33 SSE-200 subsystem) |
| 249 | ``-DTARGET_PLATFORM=MUSCA_S1`` |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 250 | - Cortex-M33 SSE-200 subsystem for MPS3 (AN524) |
| 251 | ``-DTARGET_PLATFORM=AN524`` |
Chris Brand | b42fed5 | 2019-12-02 16:10:17 -0800 | [diff] [blame] | 252 | - Cypress CYS0644ABZI-S2D44 board (PSoC64 platform) |
| 253 | ``-DTARGET_PLATFORM=psoc64`` |
Galanakis, Minos | dc6694b | 2020-01-06 13:54:56 +0000 | [diff] [blame] | 254 | See :doc:`Cypress PSoC 64 platform specifics </platform/ext/target/cypress/psoc64/cypress_psoc64_spec>` |
Marton Berke | e980366 | 2019-11-11 14:11:05 +0100 | [diff] [blame] | 255 | - DesignStart FPGA on Cloud: Cortex-M33 based platform (SSE-200_AWS platform) |
| 256 | ``-DTARGET_PLATFORM=SSE-200_AWS`` |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 257 | |
| 258 | * - -DCOMPILER=<compiler name> |
| 259 | - Specifies the compiler toolchain |
| 260 | The possible values are: |
| 261 | |
| 262 | - ``ARMCLANG`` |
| 263 | - ``GNUARM`` |
| 264 | * - -DCMAKE_BUILD_TYPE=<build type> |
| 265 | - Configures debugging support. |
| 266 | The possible values are: |
| 267 | |
| 268 | - ``Debug`` |
| 269 | - ``Release`` |
| 270 | - ``Relwithdebinfo`` |
| 271 | - ``Minsizerel`` |
Raef Coles | 1bb168e | 2019-10-17 09:04:55 +0100 | [diff] [blame] | 272 | * - -DMBEDCRYPTO_DEBUG=<ON|OFF> |
Raef Coles | a657a9c | 2019-10-24 14:36:43 +0100 | [diff] [blame] | 273 | - Enables debug symbols for Mbed Crypto library. If a cryptographic |
| 274 | accelerator is enabled then this will also enable debug symbols and |
| 275 | logging for any accelerator libraries. |
Galanakis, Minos | 757139a | 2019-11-11 15:00:11 +0000 | [diff] [blame] | 276 | * - -DBUILD_DWARF_VERSION=<dwarf version> |
| 277 | - Configures DWARF version. |
| 278 | The possible values are: |
| 279 | |
| 280 | - 2 |
| 281 | - 3 |
| 282 | - 4 |
| 283 | |
| 284 | .. Note:: |
| 285 | Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or |
| 286 | without BL2 bootloader. |
| 287 | |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 288 | ************** |
Kevin Peng | d9d1920 | 2020-01-15 19:34:39 +0800 | [diff] [blame] | 289 | Configurations |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 290 | ************** |
Kevin Peng | d9d1920 | 2020-01-15 19:34:39 +0800 | [diff] [blame] | 291 | Configurations files under `configs` are TF-M provided configurations for building. |
| 292 | They are used by the `-DPROJ_CONFIG` argument for the build command line. |
| 293 | The following table describes the differences between the configurations: |
| 294 | |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 295 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 296 | | Configuration | Model [1]_ | TF-M LVL [2]_ | Regression [3]_ | Core Test [4]_ | IPC Test [5]_ | PSA API Test [6]_ | Comment | |
| 297 | +========================+============+===============+=================+================+===============+===================+=========================+ |
| 298 | | Default | Library | 1 | No | No | No | No | TF-M, no tests | |
| 299 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 300 | | Regression | Library | 1 | Yes | Yes | No | No | TF-M & Regression tests | |
| 301 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 302 | | CoreIPC | IPC | 1 | No | No | No | No | TF-M, no tests | |
| 303 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 304 | | CoreIPCTfmLevel2 | IPC | 2 | No | No | No | No | TF-M, no tests | |
| 305 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 306 | | RegressionIPC | IPC | 1 | Yes | Yes | Yes | No | TF-M & Regression tests | |
| 307 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 308 | | RegressionIPCTfmLevel2 | IPC | 2 | Yes | Yes | Yes | No | TF-M & Regression tests | |
| 309 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 310 | | PsaApiTest | Library | 1 | No | No | No | Yes | TF-M & PSA API tests | |
| 311 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 312 | | PsaApiTestIPC | IPC | 1 | No | No | No | Yes | TF-M & PSA API tests | |
| 313 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
| 314 | | PsaApiTestIPCTfmLevel2 | IPC | 2 | No | No | No | Yes | TF-M & PSA API tests | |
| 315 | +------------------------+------------+---------------+-----------------+----------------+---------------+-------------------+-------------------------+ |
Kevin Peng | d9d1920 | 2020-01-15 19:34:39 +0800 | [diff] [blame] | 316 | |
| 317 | .. [1] Which TF-M Model is set: `CORE_IPC`. If `CORE_IPC` is set to true then the model is IPC model, otherwise it's library model. |
| 318 | |
| 319 | .. [2] The TF-M isolation level `TFM_LVL`. Currently Library model supports level 1. IPC model supports level 1 and 2. |
| 320 | |
| 321 | .. [3] Build regression tests or not: `REGRESSION`. |
| 322 | |
| 323 | .. [4] Build core tests or not: `CORE_TEST`. |
| 324 | |
| 325 | .. [5] Build IPC tests or not: `IPC_TEST`. It can be only enabled in IPC model |
| 326 | |
Minos Galanakis | fc6804e | 2020-03-10 11:03:34 +0000 | [diff] [blame] | 327 | .. [6] Build for PSA API compliance tests or not: `PSA_API_TEST`. |
Kevin Peng | d9d1920 | 2020-01-15 19:34:39 +0800 | [diff] [blame] | 328 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 329 | -------------- |
| 330 | |
Galanakis, Minos | dc6694b | 2020-01-06 13:54:56 +0000 | [diff] [blame] | 331 | *Copyright (c) 2017-2020, Arm Limited. All rights reserved.* |