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 | |
| 341 | .. csv-table:: Tool dependencies |
| 342 | :header: "Name", "Version", "Component" |
| 343 | |
| 344 | "C compiler",,"Firmware" |
| 345 | "CMake",, |
| 346 | "GNU Make",, |
| 347 | "tf-m-tests",CMake handles it, |
| 348 | "mbed-crypto",CMake handles it, |
| 349 | "MCUboot",CMake handles it, |
| 350 | "Python",3.x,"Firmware, User Guide" |
| 351 | "yaml",,"Firmware" |
| 352 | "pyasn1",,"Firmware" |
| 353 | "jinja2",,"Firmware" |
| 354 | "cryptography",,"Firmware" |
| 355 | "cbor",,"Firmware" |
| 356 | "click",,"Firmware" |
| 357 | "imgtool",,"Firmware" |
| 358 | "Doxygen",">1.8","Reference manual" |
| 359 | "Sphinx","=1.7.9","User Guide" |
| 360 | "sphinxcontrib-plantuml",,"User Guide" |
| 361 | "sphinxcontrib-svg2pdfconverter",,"User Guide" |
| 362 | "sphinx-rtd-theme",,"User Guide" |
| 363 | "sphinx-tabs",,"User Guide" |
| 364 | "Git",, |
| 365 | "PlantUML",">v1.2018.11","Reference Manual, User Guide" |
| 366 | "Graphviz dot",">v2.38.0","Reference manual" |
| 367 | "Java runtime environment (JRE)",">1.8","Reference Manual, User Guide" |
| 368 | "LaTex",,"pdf version of Reference Manual and User Guide" |
| 369 | "PdfLaTex",,"pdf version of Reference Manual and User Guide" |
| 370 | |
| 371 | Dependency chain: |
| 372 | |
| 373 | .. uml:: |
| 374 | |
| 375 | @startuml |
| 376 | skinparam state { |
| 377 | BackgroundColor #92AEE0 |
| 378 | FontColor black |
| 379 | FontSize 16 |
| 380 | AttributeFontColor black |
| 381 | AttributeFontSize 16 |
| 382 | BackgroundColor<<pdf>> #A293E2 |
| 383 | BackgroundColor<<doc>> #90DED6 |
| 384 | } |
| 385 | state fw as "Firmware" : TF-M binary |
| 386 | state c_comp as "C Compiler" : C99 |
| 387 | state gmake as "GNU make" |
| 388 | state u_guide as "User Guide" <<doc>> |
| 389 | state refman as "Reference Manual" <<doc>> |
| 390 | state rtd_theme as "sphinx-rtd-theme" <<doc>> |
| 391 | state tabs as "sphinx-tabs" <<doc>> |
| 392 | state sphnix_puml as "sphinxcontrib-plantuml" <<doc>> |
| 393 | state sphnix_svg as "sphinxcontrib-svg2pdfconverter" <<doc>> |
| 394 | state JRE as "JRE" <<doc>> : Java Runtime Environment |
| 395 | state gwiz as "Graphwiz dot" <<doc>> |
| 396 | state Sphinx as "Sphinx" <<doc>> |
| 397 | state m2r as "m2r" <<doc>> |
| 398 | state PlantUML as "PlantUML" <<doc>> |
| 399 | state LaTex as "LaTex" <<pdf>> |
| 400 | state PdfLaTex as "PdfLaTex" <<<<pdf>>>> |
| 401 | state Doxygen as "Doxygen" <<doc>> |
| 402 | |
| 403 | [*] --> fw |
| 404 | fw --> c_comp |
| 405 | fw --> CMake |
| 406 | CMake --> gmake |
| 407 | fw --> cryptography |
| 408 | fw --> pyasn1 |
| 409 | fw --> yaml |
| 410 | fw --> jinja2 |
| 411 | fw --> cbor |
| 412 | fw --> click |
| 413 | fw --> imgtool |
| 414 | cryptography --> Python3 |
| 415 | pyasn1 --> Python3 |
| 416 | yaml --> Python3 |
| 417 | jinja2 --> Python3 |
| 418 | cbor --> Python3 |
| 419 | click --> Python3 |
| 420 | imgtool --> Python3 |
| 421 | |
| 422 | [*] --> u_guide |
| 423 | u_guide --> Sphinx |
| 424 | Sphinx --> m2r |
| 425 | Sphinx --> rtd_theme |
| 426 | Sphinx --> tabs |
| 427 | Sphinx --> sphnix_puml |
| 428 | Sphinx --> sphnix_svg |
| 429 | m2r --> Python3 |
| 430 | rtd_theme --> Python3 |
| 431 | tabs --> Python3 |
| 432 | sphnix_puml --> Python3 |
| 433 | sphnix_svg --> Python3 |
| 434 | Sphinx --> PlantUML |
| 435 | PlantUML --> JRE |
| 436 | PlantUML --> gwiz |
| 437 | Sphinx --> LaTex |
| 438 | LaTex --> PdfLaTex |
| 439 | |
| 440 | [*] --> refman |
| 441 | refman --> Doxygen |
| 442 | Doxygen --> PlantUML |
| 443 | Doxygen --> LaTex |
| 444 | state Legend { |
| 445 | state x as "For PDF generation only" <<pdf>> |
| 446 | state y as "For document generation only" <<doc>> |
| 447 | state z as "Mandatory" |
| 448 | } |
| 449 | |
| 450 | @enduml |
| 451 | |
| 452 | ########## |
| 453 | Next steps |
| 454 | ########## |
| 455 | |
| 456 | Here are some next steps for exploring TF-M: |
| 457 | |
| 458 | - Detailed :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`. |
| 459 | - :doc:`IAR Build instructions </docs/technical_references/instructions/tfm_build_instruction_iar>`. |
| 460 | - Try other :doc:`Samples and Demos </docs/technical_references/instructions/run_tfm_examples_on_arm_platforms>`. |
| 461 | - :doc:`Documentation generation </docs/technical_references/instructions/documentation_generation>`. |
| 462 | |
| 463 | -------------- |
| 464 | |
| 465 | *Copyright (c) 2017-2021, Arm Limited. All rights reserved.* |