Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 1 | ###################### |
| 2 | TF-M build instruction |
| 3 | ###################### |
| 4 | Please make sure you have all required software installed as explained in the |
| 5 | :doc:`software requirements <tfm_sw_requirement>`. |
| 6 | |
| 7 | ********************* |
| 8 | Configuring the build |
| 9 | ********************* |
| 10 | The build configuration for TF-M is provided to the build system using command |
| 11 | line arguments: |
| 12 | |
| 13 | .. list-table:: |
| 14 | :widths: 20 80 |
| 15 | |
| 16 | * - -DPROJ_CONFIG=<file> |
| 17 | - Specifies the way the application is built. |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 18 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 19 | | <file> is the absolute path to configurations file |
| 20 | named as ``Config<APP_NAME>.cmake``. |
| 21 | | i.e. On Linux: |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 22 | ``-DPROJ_CONFIG=`readlink -f ../configs/ConfigRegression.cmake``` |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 23 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 24 | * - -DTARGET_PLATFORM=<target platform name> |
| 25 | - Specifies the target platform. |
| 26 | Supported platforms: |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 27 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 28 | - Cortex-M33 SSE-200 subsystem for MPS2+ (AN521) |
| 29 | ``-DTARGET_PLATFORM=AN521`` |
| 30 | - Cortex-M23 IoT Kit subsystem for MPS2+ (AN519) |
| 31 | ``-DTARGET_PLATFORM=AN519`` |
Jamie Fox | b8a9270 | 2019-06-05 17:19:31 +0100 | [diff] [blame] | 32 | - Musca-A test chip board (Cortex-M33 SSE-200 subsystem) |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 33 | ``-DTARGET_PLATFORM=MUSCA_A`` |
| 34 | - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem) |
| 35 | ``-DTARGET_PLATFORM=MUSCA_B1`` |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 36 | - Cortex-M33 SSE-200 subsystem for MPS3 (AN524) |
| 37 | ``-DTARGET_PLATFORM=AN524`` |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 38 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 39 | * - -DCOMPILER=<compiler name> |
| 40 | - Specifies the compiler toolchain |
| 41 | The possible values are: |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 42 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 43 | - ``ARMCLANG`` |
| 44 | - ``GNUARM`` |
| 45 | * - -DCMAKE_BUILD_TYPE=<build type> |
| 46 | - Configures debugging support. |
| 47 | The possible values are: |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 48 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 49 | - ``Debug`` |
| 50 | - ``Release`` |
| 51 | - ``Relwithdebinfo`` |
| 52 | - ``Minsizerel`` |
| 53 | * - -DMBEDTLS_DEBUG=<ON|OFF> |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 54 | - Enables debug symbols for the Mbed TLS and Mbed Crypto libraries. |
Edison Ai | 75d69c8 | 2019-07-09 18:50:41 +0800 | [diff] [blame] | 55 | * - -DBUILD_DWARF_VERSION=<dwarf version> |
| 56 | - Configures DWARF version. |
| 57 | The possible values are: |
| 58 | |
| 59 | - 2 |
| 60 | - 3 |
| 61 | - 4 |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 62 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 63 | .. Note:: |
| 64 | Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or |
| 65 | without BL2 bootloader. |
| 66 | |
| 67 | ******************* |
| 68 | External dependency |
| 69 | ******************* |
Antonio de Angelis | 70ae80f | 2019-02-26 14:57:40 +0000 | [diff] [blame] | 70 | - `CMSIS_5` is used to import RTX for the example non-secure app |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame] | 71 | - Mbed TLS and Mbed Crypto are used as crypto libraries on the secure side |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 72 | |
| 73 | **************** |
| 74 | TF-M build steps |
| 75 | **************** |
| 76 | TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source |
| 77 | build environment. The instructions are below. |
| 78 | |
| 79 | .. Note:: |
| 80 | |
| 81 | It is recommended to build each different build configurations in separate |
| 82 | directories. |
| 83 | |
| 84 | Getting the source-code |
| 85 | ======================= |
| 86 | .. code-block:: bash |
| 87 | |
| 88 | cd <TF-M base folder> |
| 89 | git clone https://git.trustedfirmware.org/trusted-firmware-m.git |
| 90 | git clone https://github.com/ARMmbed/mbedtls.git -b mbedtls-2.7.9 |
Antonio de Angelis | 2e7d296 | 2019-06-27 11:30:04 +0100 | [diff] [blame] | 91 | git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-1.1.0 |
Antonio de Angelis | 70ae80f | 2019-02-26 14:57:40 +0000 | [diff] [blame] | 92 | git clone https://github.com/ARM-software/CMSIS_5.git -b 5.5.0 |
| 93 | |
| 94 | .. Note:: |
| 95 | `CMSIS_5` now uses `git-lfs` for storing large size binaries so the cloning |
| 96 | process has changed from previous releases. Please refer to the `CMSIS_5` |
| 97 | documentation for more details. |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 98 | |
| 99 | Build steps for the AN521 target platform: |
| 100 | ========================================== |
| 101 | .. code-block:: bash |
| 102 | |
| 103 | cd <TF-M base folder> |
| 104 | cd trusted-firmware-m |
| 105 | mkdir cmake_build |
| 106 | cd cmake_build |
| 107 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG |
| 108 | cmake --build ./ -- install |
| 109 | |
| 110 | Regression Tests for the AN521 target platform |
| 111 | ============================================== |
| 112 | *TF-M build regression tests on Linux* |
| 113 | |
| 114 | .. code-block:: bash |
| 115 | |
| 116 | cd <TF-M base folder> |
| 117 | cd trusted-firmware-m |
| 118 | mkdir cmake_test |
| 119 | cd cmake_test |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 120 | 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] | 121 | cmake --build ./ -- install |
| 122 | |
| 123 | *TF-M build regression tests on Windows* |
| 124 | |
| 125 | .. code-block:: bash |
| 126 | |
| 127 | cd <TF-M base folder> |
| 128 | cd trusted-firmware-m |
| 129 | mkdir cmake_test |
| 130 | cd cmake_test |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 131 | 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] | 132 | cmake --build ./ -- install |
| 133 | |
| 134 | Build for PSA API compliance tests |
| 135 | ================================== |
| 136 | The build system provides the support for linking with prebuilt PSA API |
| 137 | compliance NS test libraries when using the ``ConfigPsaApiTest.cmake`` |
| 138 | config file. The build system assumes that the PSA API compliance test suite |
| 139 | is checked out at the same level of the TF-M root folder and the default |
| 140 | name for the build folder has been used when compiling the PSA API compliance |
| 141 | tests. Each set of tests for the Secure Storage, Crypto and Attestation services |
| 142 | needs to be enabled at the build configuration step by defining:: |
| 143 | |
| 144 | -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION |
| 145 | |
| 146 | respectively for the corresponding service. For example, to enable the PSA API |
| 147 | tests for the Crypto service only: |
| 148 | |
| 149 | .. code-block:: bash |
| 150 | |
| 151 | cd <TF-M base folder> |
| 152 | cd trusted-firmware-m |
| 153 | mkdir cmake_psa_test |
| 154 | cd cmake_psa_test |
Antonio de Angelis | 0169b9f | 2019-06-28 11:37:24 +0100 | [diff] [blame] | 155 | 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] | 156 | cmake --build ./ -- install |
| 157 | |
| 158 | Location of build artifacts |
| 159 | =========================== |
| 160 | The build system defines an API which allow easy usage of build |
| 161 | artifacts. The ``install`` build target copies all files which might be needed |
| 162 | as a dependency by external tools or build systems to the |
| 163 | ``<build_dir>/install/outputs`` |
| 164 | directory, with the following directory hierarchy: |
| 165 | |
| 166 | :: |
| 167 | |
| 168 | <build_dir>/install/outputs/fvp/ |
| 169 | <build_dir>/install/outputs/<target_platform>/ |
| 170 | |
| 171 | There is one folder for FVP testing, with more elaborate naming and |
| 172 | there is an other for testing on target hardware platform (AN521, etc.), where |
| 173 | naming convention is aligned with 8.3 format. The dependency tree of |
| 174 | ``install`` build target ensures a proper update (i.e. build) of all output |
| 175 | files before the actual installation step takes place. As such it is suggested |
| 176 | to use this build target to build TF-M. |
| 177 | |
| 178 | Export dependency files for NS applications |
| 179 | ------------------------------------------- |
| 180 | An NS application requires a number of files to interface with TF-M. |
| 181 | The build system exports these files as part of the ``install`` target and |
| 182 | places them in to a single directory:: |
| 183 | |
| 184 | <build_dir>/install/export/tfm |
| 185 | |
| 186 | Further details on how to integrate a new NS app with TF-M are available in the |
| 187 | :doc:`integration guide <tfm_integration_guide>`. |
| 188 | |
| 189 | Building the documentation |
| 190 | ========================== |
| 191 | Please ensure the dependencies for building the firmware and the |
| 192 | documentation are installed as explained in the |
| 193 | :doc:`software requirements <tfm_sw_requirement>`. |
| 194 | |
| 195 | Building PDF output is optional and can be disabled by removing LaTex from the |
| 196 | PATH. |
| 197 | |
| 198 | .. Note:: |
| 199 | For building the documentation all tools needed to build the firmware must |
| 200 | be available. |
| 201 | |
| 202 | Building the Reference Manual |
| 203 | ----------------------------- |
| 204 | .. code-block:: bash |
| 205 | |
| 206 | cd <TF-M base folder> |
| 207 | mkdir cmake_doc |
| 208 | cd cmake_doc |
| 209 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM |
| 210 | cmake --build ./ -- install_doc |
| 211 | |
| 212 | The documentation files will be available under the directory:: |
| 213 | |
| 214 | cmake_doc/install/doc/reference_manual |
| 215 | |
| 216 | Building the User Guide |
| 217 | ----------------------- |
| 218 | .. code-block:: bash |
| 219 | |
| 220 | cd <TF-M base folder> |
| 221 | mkdir cmake_doc |
| 222 | cd cmake_doc |
| 223 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG |
| 224 | cmake --build ./ -- install_userguide |
| 225 | |
| 226 | The documentation files will be available under the directory:: |
| 227 | |
| 228 | cmake_doc/install/doc/user_guide |
| 229 | |
| 230 | -------------- |
| 231 | |
| 232 | *Copyright (c) 2017-2019, Arm Limited. All rights reserved.* |