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: |
| 22 | ``-DPROJ_CONFIG=`readlink -f ../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`` |
| 32 | - Musca-A1 test chip board (Cortex-M33 SSE-200 subsystem) |
| 33 | ``-DTARGET_PLATFORM=MUSCA_A`` |
| 34 | - Musca-B1 test chip board (Cortex-M33 SSE-200 subsystem) |
| 35 | ``-DTARGET_PLATFORM=MUSCA_B1`` |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame^] | 36 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 37 | * - -DCOMPILER=<compiler name> |
| 38 | - Specifies the compiler toolchain |
| 39 | The possible values are: |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame^] | 40 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 41 | - ``ARMCLANG`` |
| 42 | - ``GNUARM`` |
| 43 | * - -DCMAKE_BUILD_TYPE=<build type> |
| 44 | - Configures debugging support. |
| 45 | The possible values are: |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame^] | 46 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 47 | - ``Debug`` |
| 48 | - ``Release`` |
| 49 | - ``Relwithdebinfo`` |
| 50 | - ``Minsizerel`` |
| 51 | * - -DMBEDTLS_DEBUG=<ON|OFF> |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame^] | 52 | - Enables debug symbols for the Mbed TLS and Mbed Crypto libraries. |
| 53 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 54 | .. Note:: |
| 55 | Follow :doc:`secure boot <./tfm_secure_boot>` to build the binaries with or |
| 56 | without BL2 bootloader. |
| 57 | |
| 58 | ******************* |
| 59 | External dependency |
| 60 | ******************* |
| 61 | - 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^] | 62 | - 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] | 63 | |
| 64 | **************** |
| 65 | TF-M build steps |
| 66 | **************** |
| 67 | TF-M uses `cmake <https://cmake.org/overview/>`__ to provide an out-of-source |
| 68 | build environment. The instructions are below. |
| 69 | |
| 70 | .. Note:: |
| 71 | |
| 72 | It is recommended to build each different build configurations in separate |
| 73 | directories. |
| 74 | |
| 75 | Getting the source-code |
| 76 | ======================= |
| 77 | .. code-block:: bash |
| 78 | |
| 79 | cd <TF-M base folder> |
| 80 | git clone https://git.trustedfirmware.org/trusted-firmware-m.git |
| 81 | git clone https://github.com/ARMmbed/mbedtls.git -b mbedtls-2.7.9 |
Antonio de Angelis | ee774c2 | 2019-05-03 13:44:01 +0100 | [diff] [blame^] | 82 | git clone https://github.com/ARMmbed/mbed-crypto.git -b mbedcrypto-1.0.0 |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 83 | git clone https://github.com/ARM-software/CMSIS_5.git -b 5.2.0 |
| 84 | |
| 85 | Build steps for the AN521 target platform: |
| 86 | ========================================== |
| 87 | .. code-block:: bash |
| 88 | |
| 89 | cd <TF-M base folder> |
| 90 | cd trusted-firmware-m |
| 91 | mkdir cmake_build |
| 92 | cd cmake_build |
| 93 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG |
| 94 | cmake --build ./ -- install |
| 95 | |
| 96 | Regression Tests for the AN521 target platform |
| 97 | ============================================== |
| 98 | *TF-M build regression tests on Linux* |
| 99 | |
| 100 | .. code-block:: bash |
| 101 | |
| 102 | cd <TF-M base folder> |
| 103 | cd trusted-firmware-m |
| 104 | mkdir cmake_test |
| 105 | cd cmake_test |
| 106 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
| 107 | cmake --build ./ -- install |
| 108 | |
| 109 | *TF-M build regression tests on Windows* |
| 110 | |
| 111 | .. code-block:: bash |
| 112 | |
| 113 | cd <TF-M base folder> |
| 114 | cd trusted-firmware-m |
| 115 | mkdir cmake_test |
| 116 | cd cmake_test |
| 117 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`cygpath -am ../ConfigRegression.cmake` -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
| 118 | cmake --build ./ -- install |
| 119 | |
| 120 | Build for PSA API compliance tests |
| 121 | ================================== |
| 122 | The build system provides the support for linking with prebuilt PSA API |
| 123 | compliance NS test libraries when using the ``ConfigPsaApiTest.cmake`` |
| 124 | config file. The build system assumes that the PSA API compliance test suite |
| 125 | is checked out at the same level of the TF-M root folder and the default |
| 126 | name for the build folder has been used when compiling the PSA API compliance |
| 127 | tests. Each set of tests for the Secure Storage, Crypto and Attestation services |
| 128 | needs to be enabled at the build configuration step by defining:: |
| 129 | |
| 130 | -DPSA_API_TEST_SECURE_STORAGE -DPSA_API_TEST_CRYPTO -DPSA_API_TEST_ATTESTATION |
| 131 | |
| 132 | respectively for the corresponding service. For example, to enable the PSA API |
| 133 | tests for the Crypto service only: |
| 134 | |
| 135 | .. code-block:: bash |
| 136 | |
| 137 | cd <TF-M base folder> |
| 138 | cd trusted-firmware-m |
| 139 | mkdir cmake_psa_test |
| 140 | cd cmake_psa_test |
| 141 | cmake -G"Unix Makefiles" -DPROJ_CONFIG=`readlink -f ../ConfigPsaApiTest.cmake` -DPSA_API_TEST_CRYPTO -DTARGET_PLATFORM=AN521 -DCOMPILER=ARMCLANG ../ |
| 142 | cmake --build ./ -- install |
| 143 | |
| 144 | Location of build artifacts |
| 145 | =========================== |
| 146 | The build system defines an API which allow easy usage of build |
| 147 | artifacts. The ``install`` build target copies all files which might be needed |
| 148 | as a dependency by external tools or build systems to the |
| 149 | ``<build_dir>/install/outputs`` |
| 150 | directory, with the following directory hierarchy: |
| 151 | |
| 152 | :: |
| 153 | |
| 154 | <build_dir>/install/outputs/fvp/ |
| 155 | <build_dir>/install/outputs/<target_platform>/ |
| 156 | |
| 157 | There is one folder for FVP testing, with more elaborate naming and |
| 158 | there is an other for testing on target hardware platform (AN521, etc.), where |
| 159 | naming convention is aligned with 8.3 format. The dependency tree of |
| 160 | ``install`` build target ensures a proper update (i.e. build) of all output |
| 161 | files before the actual installation step takes place. As such it is suggested |
| 162 | to use this build target to build TF-M. |
| 163 | |
| 164 | Export dependency files for NS applications |
| 165 | ------------------------------------------- |
| 166 | An NS application requires a number of files to interface with TF-M. |
| 167 | The build system exports these files as part of the ``install`` target and |
| 168 | places them in to a single directory:: |
| 169 | |
| 170 | <build_dir>/install/export/tfm |
| 171 | |
| 172 | Further details on how to integrate a new NS app with TF-M are available in the |
| 173 | :doc:`integration guide <tfm_integration_guide>`. |
| 174 | |
| 175 | Building the documentation |
| 176 | ========================== |
| 177 | Please ensure the dependencies for building the firmware and the |
| 178 | documentation are installed as explained in the |
| 179 | :doc:`software requirements <tfm_sw_requirement>`. |
| 180 | |
| 181 | Building PDF output is optional and can be disabled by removing LaTex from the |
| 182 | PATH. |
| 183 | |
| 184 | .. Note:: |
| 185 | For building the documentation all tools needed to build the firmware must |
| 186 | be available. |
| 187 | |
| 188 | Building the Reference Manual |
| 189 | ----------------------------- |
| 190 | .. code-block:: bash |
| 191 | |
| 192 | cd <TF-M base folder> |
| 193 | mkdir cmake_doc |
| 194 | cd cmake_doc |
| 195 | cmake ../ -G"Unix Makefiles" -DTARGET_PLATFORM=AN521 -DCOMPILER=GNUARM |
| 196 | cmake --build ./ -- install_doc |
| 197 | |
| 198 | The documentation files will be available under the directory:: |
| 199 | |
| 200 | cmake_doc/install/doc/reference_manual |
| 201 | |
| 202 | Building the User Guide |
| 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=ARMCLANG |
| 210 | cmake --build ./ -- install_userguide |
| 211 | |
| 212 | The documentation files will be available under the directory:: |
| 213 | |
| 214 | cmake_doc/install/doc/user_guide |
| 215 | |
| 216 | -------------- |
| 217 | |
| 218 | *Copyright (c) 2017-2019, Arm Limited. All rights reserved.* |