Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 1 | #################################### |
| 2 | Select and set up build environments |
| 3 | #################################### |
| 4 | |
| 5 | TF-M officially supports a limited set of build environments and setups. In |
| 6 | this context, official support means that the environments listed below |
| 7 | are actively used by team members and active developers, hence users should |
| 8 | be able to recreate the same configurations by following the instructions |
| 9 | described below. In case of problems, the TF-M team provides support |
| 10 | only for these environments, but building in other environments can still be |
| 11 | possible. |
| 12 | |
| 13 | The following environments are supported: |
| 14 | |
| 15 | .. tabs:: |
| 16 | |
| 17 | .. group-tab:: Linux |
| 18 | |
| 19 | 1. version supported: |
| 20 | |
| 21 | Ubuntu 18.04 x64+ |
| 22 | |
| 23 | 2. install dependencies: |
| 24 | |
| 25 | .. code-block:: bash |
| 26 | |
| 27 | sudo apt-get install -y git curl wget build-essential libssl-dev python3 \ |
| 28 | python3-pip cmake make |
| 29 | |
| 30 | 3. verify cmake version: |
| 31 | |
| 32 | .. code-block:: bash |
| 33 | |
| 34 | cmake --version |
| 35 | |
| 36 | .. note:: |
| 37 | |
| 38 | Please download cmake 3.15 or later version from https://cmake.org/download/. |
| 39 | |
| 40 | 4. add CMake path into environment: |
| 41 | |
| 42 | .. code-block:: bash |
| 43 | |
| 44 | export PATH=<CMake path>/bin:$PATH |
| 45 | |
| 46 | .. group-tab:: Windows |
| 47 | |
| 48 | 1. version supported: |
| 49 | |
| 50 | Windows 10 x64 |
| 51 | |
| 52 | 2. install dependecies: |
| 53 | |
| 54 | - Git client latest version (https://git-scm.com/download/win) |
| 55 | - CMake (`native Windows version <https://cmake.org/download/>`__) |
| 56 | - GNU make (http://gnuwin32.sourceforge.net/packages/make.htm) |
| 57 | - Python3 `(native Windows version) <https://www.python.org/downloads/>`__ and |
| 58 | the pip package manager (from Python 3.4 it's included) |
| 59 | |
| 60 | 3. add CMake path into environment: |
| 61 | |
| 62 | .. code-block:: bash |
| 63 | |
| 64 | set PATH=<CMake_Path>\bin;$PATH |
| 65 | |
| 66 | ########################### |
| 67 | Install python dependencies |
| 68 | ########################### |
| 69 | |
| 70 | Clone the TF-M source code, and then install the TF-M's additional Python |
| 71 | dependencies. |
| 72 | |
| 73 | .. tabs:: |
| 74 | |
| 75 | .. group-tab:: Linux |
| 76 | |
| 77 | 1. get the TF-M source code: |
| 78 | |
| 79 | .. code-block:: bash |
| 80 | |
| 81 | cd <base folder> |
| 82 | git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git |
| 83 | |
| 84 | 2. TF-M's ``tools/requirements.txt`` file declares additional Python |
| 85 | dependencies. Install them with ``pip3``: |
| 86 | |
| 87 | .. code-block:: bash |
| 88 | |
| 89 | pip3 install --upgrade pip |
| 90 | cd trusted-firmware-m |
| 91 | pip3 install -r tools/requirements.txt |
| 92 | |
| 93 | .. group-tab:: Windows |
| 94 | |
| 95 | 1. get the TF-M source code: |
| 96 | |
| 97 | .. code-block:: bash |
| 98 | |
| 99 | cd <base folder> |
| 100 | git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git |
| 101 | |
| 102 | 2. TF-M's ``tools/requirements.txt`` file declares additional Python |
| 103 | dependencies. Install them with ``pip3``: |
| 104 | |
| 105 | .. code-block:: bash |
| 106 | |
| 107 | cd trusted-firmware-m |
| 108 | pip3 install -r tools\requirements.txt |
| 109 | |
| 110 | ################### |
| 111 | Install a toolchain |
| 112 | ################### |
| 113 | |
| 114 | To compile TF-M code, at least one of the supported compiler toolchains have to |
| 115 | be available in the build environment. The currently supported compiler |
| 116 | versions are: |
| 117 | |
| 118 | - Arm Compiler v6.10.1+ |
| 119 | |
| 120 | .. tabs:: |
| 121 | |
| 122 | .. group-tab:: Linux |
| 123 | |
| 124 | - Download the standalone packages from `here <https://developer.arm.com/products/software-development-tools/compilers/arm-compiler/downloads/version-6>`__. |
| 125 | - Add Arm Compiler into environment: |
| 126 | |
| 127 | .. code-block:: bash |
| 128 | |
| 129 | export PATH=<ARM_CLANG_PATH>/sw/ARMCompiler6.10.1/bin:$PATH |
| 130 | export ARM_PRODUCT_PATH=<ARM_CLANG_PATH>/sw/mappings |
| 131 | |
| 132 | .. group-tab:: Windows |
| 133 | |
| 134 | - Download the standalone packages from `here <https://developer.arm.com/products/software-development-tools/compilers/arm-compiler/downloads/version-6>`__. |
| 135 | - Add Arm Compiler into environment: |
| 136 | |
| 137 | .. code-block:: bash |
| 138 | |
| 139 | set PATH=<ARM_CLANG_PATH>\sw\ARMCompiler6.10.1\bin;$PATH |
| 140 | set ARM_PRODUCT_PATH=<ARM_CLANG_PATH>\sw\mappings |
| 141 | |
| 142 | - GNU Arm compiler v7.3.1+ |
| 143 | |
| 144 | .. tabs:: |
| 145 | |
| 146 | .. group-tab:: Linux |
| 147 | |
| 148 | - Download the GNU Arm compiler from `here <https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads>`__. |
| 149 | - Add GNU Arm into environment: |
| 150 | |
| 151 | .. code-block:: bash |
| 152 | |
| 153 | export PATH=<GNU_ARM_PATH>/bin:$PATH |
| 154 | |
| 155 | .. group-tab:: Windows |
| 156 | |
| 157 | - Download the GNU Arm compiler from `here <https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads>`__. |
| 158 | - Add GNU Arm into environment: |
| 159 | |
| 160 | .. code-block:: bash |
| 161 | |
| 162 | export PATH=<GNU_ARM_PATH>\bin;$PATH |
| 163 | |
| 164 | .. note:: |
| 165 | |
| 166 | GNU Arm compiler version *10-2020-q4-major* has an issue in CMSE |
| 167 | support. The bug is reported in `here <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99157>`__. |
| 168 | Select other GNU Arm compiler versions instead. |
| 169 | |
| 170 | - IAR Arm compiler v8.42.x, v8.50.x |
| 171 | |
| 172 | .. tabs:: |
| 173 | |
| 174 | .. group-tab:: Linux |
| 175 | |
| 176 | - Download IAR build tools from `here <https://www.iar.com/iar-embedded-workbench/build-tools-for-linux/>`__. |
| 177 | - Add IAR Arm compiler into environment: |
| 178 | |
| 179 | .. code-block:: bash |
| 180 | |
| 181 | export PATH=<IAR_COMPILER_PATH>/bin:$PATH |
| 182 | |
| 183 | .. group-tab:: Windows |
| 184 | |
| 185 | - Download IAR build tools from `here <https://www.iar.com/iar-embedded-workbench/#!?architecture=Arm>`__. |
| 186 | - Add IAR Arm compiler into environment: |
| 187 | |
| 188 | .. code-block:: bash |
| 189 | |
| 190 | export PATH=<IAR_COMPILER_PATH>\bin;$PATH |
| 191 | |
| 192 | ############################# |
| 193 | Build AN521 regression sample |
| 194 | ############################# |
| 195 | |
| 196 | Here, we take building TF-M for AN521 platform with regression tests using GCC |
| 197 | as an example: |
| 198 | |
| 199 | .. tabs:: |
| 200 | |
| 201 | .. group-tab:: Linux |
| 202 | |
| 203 | .. code-block:: bash |
| 204 | |
| 205 | cd trusted-firmware-m |
| 206 | cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DTEST_S=ON -DTEST_NS=ON |
| 207 | cmake --build cmake_build -- install |
| 208 | |
| 209 | Alternately using traditional cmake syntax |
| 210 | |
| 211 | .. code-block:: bash |
| 212 | |
| 213 | cd trusted-firmware-m |
| 214 | mkdir cmake_build |
| 215 | cd cmake_build |
| 216 | cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON |
| 217 | make install |
| 218 | |
| 219 | .. group-tab:: Windows |
| 220 | |
| 221 | .. code-block:: bash |
| 222 | |
| 223 | cd trusted-firmware-m |
| 224 | cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DTEST_S=ON -DTEST_NS=ON |
| 225 | cmake --build cmake_build -- install |
| 226 | |
| 227 | Alternately using traditional cmake syntax |
| 228 | |
| 229 | .. code-block:: bash |
| 230 | |
| 231 | cd trusted-firmware-m |
| 232 | mkdir cmake_build |
| 233 | cd cmake_build |
| 234 | cmake -G"Unix Makefiles" .. -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON |
| 235 | make install |
| 236 | |
| 237 | ########################### |
| 238 | Run AN521 regression sample |
| 239 | ########################### |
| 240 | |
| 241 | Run the sample code on SSE-200 Fast-Model, using FVP_MPS2_AEMv8M provided by |
| 242 | Arm Development Studio. |
| 243 | |
| 244 | .. note:: |
| 245 | |
| 246 | Arm Development Studio is not essential to develop TF-M, you can skip this |
| 247 | section if don't want to try on Arm develop boards. |
| 248 | |
| 249 | .. tabs:: |
| 250 | |
| 251 | .. group-tab:: Linux |
| 252 | |
| 253 | 1. install Arm Development Studio to get the fast-model. |
| 254 | |
| 255 | Download Arm Development Studio from `here <https://developer.arm.com/tools-and-software/embedded/arm-development-studio>`__. |
| 256 | |
| 257 | 2. Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to symbol files in Debug |
| 258 | Configuration menu. |
| 259 | |
| 260 | .. code-block:: bash |
| 261 | |
| 262 | <DS_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \ |
| 263 | --parameter fvp_mps2.platform_type=2 \ |
| 264 | --parameter cpu0.baseline=0 \ |
| 265 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 266 | --parameter cpu0.semihosting-enable=0 \ |
| 267 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 268 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 269 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 270 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 271 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 272 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 273 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 274 | --application cpu0=<build_dir>/bin/bl2.axf \ |
| 275 | --data cpu0=<build_dir>/bin/tfm_s_ns_signed.bin@0x10080000 |
| 276 | |
| 277 | .. group-tab:: Windows |
| 278 | |
| 279 | 1. install Arm Development Studio to get the fast-model. |
| 280 | |
| 281 | Download Arm Development Studio from `here <https://developer.arm.com/tools-and-software/embedded/arm-development-studio>`__. |
| 282 | |
| 283 | 2. Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to symbol files in Debug |
| 284 | Configuration menu. |
| 285 | |
| 286 | .. code-block:: bash |
| 287 | |
| 288 | <DS_PATH>\sw\models\bin\FVP_MPS2_AEMv8M \ |
| 289 | --parameter fvp_mps2.platform_type=2 \ |
| 290 | --parameter cpu0.baseline=0 \ |
| 291 | --parameter cpu0.INITVTOR_S=0x10000000 \ |
| 292 | --parameter cpu0.semihosting-enable=0 \ |
| 293 | --parameter fvp_mps2.DISABLE_GATING=0 \ |
| 294 | --parameter fvp_mps2.telnetterminal0.start_telnet=1 \ |
| 295 | --parameter fvp_mps2.telnetterminal1.start_telnet=0 \ |
| 296 | --parameter fvp_mps2.telnetterminal2.start_telnet=0 \ |
| 297 | --parameter fvp_mps2.telnetterminal0.quiet=0 \ |
| 298 | --parameter fvp_mps2.telnetterminal1.quiet=1 \ |
| 299 | --parameter fvp_mps2.telnetterminal2.quiet=1 \ |
| 300 | --application cpu0=<build_dir>/bin/bl2.axf \ |
| 301 | --data cpu0=<build_dir>/bin/tfm_s_ns_signed.bin@0x10080000 |
| 302 | |
| 303 | After completing the procedure you should see the following messages on the |
| 304 | DAPLink UART (baud 115200 8n1):: |
| 305 | |
| 306 | [INF] Starting bootloader |
| 307 | [INF] Image 0: magic=good, copy_done=0xff, image_ok=0xff |
| 308 | [INF] Scratch: magic=bad, copy_done=0x5, image_ok=0x9 |
| 309 | [INF] Boot source: primary slot |
| 310 | [INF] Swap type: none |
| 311 | [INF] Bootloader chainload address offset: 0x20000 |
| 312 | [INF] Jumping to the first image slot |
| 313 | [Sec Thread] Secure image initializing! |
| 314 | |
| 315 | #### Execute test suites for the protected storage service #### |
| 316 | Running Test Suite PS secure interface tests (TFM_PS_TEST_2XXX)... |
| 317 | > Executing 'TFM_PS_TEST_2001' |
| 318 | Description: 'Create interface' |
| 319 | TEST PASSED! |
| 320 | > Executing 'TFM_PS_TEST_2002' |
| 321 | Description: 'Get handle interface (DEPRECATED)' |
| 322 | This test is DEPRECATED and the test execution was SKIPPED |
| 323 | TEST PASSED! |
| 324 | > Executing 'TFM_PS_TEST_2003' |
| 325 | Description: 'Get handle with null handle pointer (DEPRECATED)' |
| 326 | This test is DEPRECATED and the test execution was SKIPPED |
| 327 | TEST PASSED! |
| 328 | > Executing 'TFM_PS_TEST_2004' |
| 329 | Description: 'Get attributes interface' |
| 330 | TEST PASSED! |
| 331 | > Executing 'TFM_PS_TEST_2005' |
| 332 | Description: 'Get attributes with null attributes struct pointer' |
| 333 | .... |
| 334 | |
| 335 | ########################## |
| 336 | Tool & Dependency overview |
| 337 | ########################## |
| 338 | |
| 339 | To build the TF-M firmware the following tools are needed: |
| 340 | |
Anton Komlev | 4c436bf | 2021-10-18 21:59:55 +0100 | [diff] [blame^] | 341 | - C compiler of supported toolchains |
| 342 | - CMake version 3.15 or later |
| 343 | - Git |
| 344 | - gmake, aka GNU Make |
| 345 | - Python v3.x |
| 346 | - a set of python modules listed in ``tools/requiremtns.txt`` |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 347 | |
Anton Komlev | 4c436bf | 2021-10-18 21:59:55 +0100 | [diff] [blame^] | 348 | Dependency chain |
| 349 | ---------------- |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 350 | |
| 351 | .. uml:: |
| 352 | |
| 353 | @startuml |
| 354 | skinparam state { |
| 355 | BackgroundColor #92AEE0 |
| 356 | FontColor black |
| 357 | FontSize 16 |
| 358 | AttributeFontColor black |
| 359 | AttributeFontSize 16 |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 360 | } |
| 361 | state fw as "Firmware" : TF-M binary |
| 362 | state c_comp as "C Compiler" : C99 |
Anton Komlev | 4c436bf | 2021-10-18 21:59:55 +0100 | [diff] [blame^] | 363 | state python as "Python" : v3.x |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 364 | |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 365 | fw --> c_comp |
| 366 | fw --> CMake |
| 367 | CMake --> gmake |
Anton Komlev | 4c436bf | 2021-10-18 21:59:55 +0100 | [diff] [blame^] | 368 | CMake --> Ninja |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 369 | fw --> cryptography |
| 370 | fw --> pyasn1 |
| 371 | fw --> yaml |
| 372 | fw --> jinja2 |
| 373 | fw --> cbor |
| 374 | fw --> click |
| 375 | fw --> imgtool |
Anton Komlev | 4c436bf | 2021-10-18 21:59:55 +0100 | [diff] [blame^] | 376 | c_comp --> GCC |
| 377 | c_comp --> CLANG |
| 378 | c_comp --> IAR |
| 379 | cryptography --> python |
| 380 | pyasn1 --> python |
| 381 | yaml --> python |
| 382 | jinja2 --> python |
| 383 | cbor --> python |
| 384 | click --> python |
| 385 | imgtool --> python |
Summer Qin | 6d5c91c | 2021-05-24 15:32:44 +0800 | [diff] [blame] | 386 | @enduml |
| 387 | |
| 388 | ########## |
| 389 | Next steps |
| 390 | ########## |
| 391 | |
| 392 | Here are some next steps for exploring TF-M: |
| 393 | |
| 394 | - Detailed :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`. |
| 395 | - :doc:`IAR Build instructions </docs/technical_references/instructions/tfm_build_instruction_iar>`. |
| 396 | - Try other :doc:`Samples and Demos </docs/technical_references/instructions/run_tfm_examples_on_arm_platforms>`. |
| 397 | - :doc:`Documentation generation </docs/technical_references/instructions/documentation_generation>`. |
| 398 | |
| 399 | -------------- |
| 400 | |
| 401 | *Copyright (c) 2017-2021, Arm Limited. All rights reserved.* |