blob: 4e32ec3d1f50879bcb8f540d5a5628ae3d26362e [file] [log] [blame]
Summer Qin6d5c91c2021-05-24 15:32:44 +08001####################################
2Select and set up build environments
3####################################
4
5TF-M officially supports a limited set of build environments and setups. In
6this context, official support means that the environments listed below
7are actively used by team members and active developers, hence users should
8be able to recreate the same configurations by following the instructions
9described below. In case of problems, the TF-M team provides support
10only for these environments, but building in other environments can still be
11possible.
12
13The 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###########################
67Install python dependencies
68###########################
69
70Clone the TF-M source code, and then install the TF-M's additional Python
71dependencies.
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###################
111Install a toolchain
112###################
113
114To compile TF-M code, at least one of the supported compiler toolchains have to
115be available in the build environment. The currently supported compiler
116versions 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#############################
193Build AN521 regression sample
194#############################
195
196Here, we take building TF-M for AN521 platform with regression tests using GCC
197as 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###########################
238Run AN521 regression sample
239###########################
240
241Run the sample code on SSE-200 Fast-Model, using FVP_MPS2_AEMv8M provided by
242Arm 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
303After completing the procedure you should see the following messages on the
304DAPLink 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##########################
336Tool & Dependency overview
337##########################
338
339To 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"
David Hu802f5882021-07-08 21:44:05 +0800359 "Sphinx","=2.0.1","User Guide"
Summer Qin6d5c91c2021-05-24 15:32:44 +0800360 "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"
David Hu828aa572021-07-08 22:09:16 +0800370 "librsvg2-bin",, "User Guide"
Summer Qin6d5c91c2021-05-24 15:32:44 +0800371
372Dependency chain:
373
374.. uml::
375
376 @startuml
377 skinparam state {
378 BackgroundColor #92AEE0
379 FontColor black
380 FontSize 16
381 AttributeFontColor black
382 AttributeFontSize 16
383 BackgroundColor<<pdf>> #A293E2
384 BackgroundColor<<doc>> #90DED6
385 }
386 state fw as "Firmware" : TF-M binary
387 state c_comp as "C Compiler" : C99
388 state gmake as "GNU make"
389 state u_guide as "User Guide" <<doc>>
390 state refman as "Reference Manual" <<doc>>
391 state rtd_theme as "sphinx-rtd-theme" <<doc>>
392 state tabs as "sphinx-tabs" <<doc>>
393 state sphnix_puml as "sphinxcontrib-plantuml" <<doc>>
394 state sphnix_svg as "sphinxcontrib-svg2pdfconverter" <<doc>>
395 state JRE as "JRE" <<doc>> : Java Runtime Environment
396 state gwiz as "Graphwiz dot" <<doc>>
397 state Sphinx as "Sphinx" <<doc>>
398 state m2r as "m2r" <<doc>>
399 state PlantUML as "PlantUML" <<doc>>
400 state LaTex as "LaTex" <<pdf>>
401 state PdfLaTex as "PdfLaTex" <<<<pdf>>>>
402 state Doxygen as "Doxygen" <<doc>>
David Hu828aa572021-07-08 22:09:16 +0800403 state librsvg as "librsvg2-bin" <<doc>>
Summer Qin6d5c91c2021-05-24 15:32:44 +0800404
405 [*] --> fw
406 fw --> c_comp
407 fw --> CMake
408 CMake --> gmake
409 fw --> cryptography
410 fw --> pyasn1
411 fw --> yaml
412 fw --> jinja2
413 fw --> cbor
414 fw --> click
415 fw --> imgtool
416 cryptography --> Python3
417 pyasn1 --> Python3
418 yaml --> Python3
419 jinja2 --> Python3
420 cbor --> Python3
421 click --> Python3
422 imgtool --> Python3
423
424 [*] --> u_guide
425 u_guide --> Sphinx
426 Sphinx --> m2r
427 Sphinx --> rtd_theme
428 Sphinx --> tabs
429 Sphinx --> sphnix_puml
430 Sphinx --> sphnix_svg
431 m2r --> Python3
432 rtd_theme --> Python3
433 tabs --> Python3
434 sphnix_puml --> Python3
435 sphnix_svg --> Python3
David Hu828aa572021-07-08 22:09:16 +0800436 sphnix_svg --> librsvg
Summer Qin6d5c91c2021-05-24 15:32:44 +0800437 Sphinx --> PlantUML
438 PlantUML --> JRE
439 PlantUML --> gwiz
440 Sphinx --> LaTex
441 LaTex --> PdfLaTex
442
443 [*] --> refman
444 refman --> Doxygen
445 Doxygen --> PlantUML
446 Doxygen --> LaTex
447 state Legend {
448 state x as "For PDF generation only" <<pdf>>
449 state y as "For document generation only" <<doc>>
450 state z as "Mandatory"
451 }
452
453 @enduml
454
455##########
456Next steps
457##########
458
459Here are some next steps for exploring TF-M:
460
461 - Detailed :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`.
462 - :doc:`IAR Build instructions </docs/technical_references/instructions/tfm_build_instruction_iar>`.
463 - Try other :doc:`Samples and Demos </docs/technical_references/instructions/run_tfm_examples_on_arm_platforms>`.
464 - :doc:`Documentation generation </docs/technical_references/instructions/documentation_generation>`.
465
466--------------
467
468*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*