blob: 93146102d46896658bc9f115a3d744579b993a66 [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
Anton Komlevc52e2d92021-11-25 17:20:09 +0000142 .. note::
143
144 ArmClang compiler *v6.17* may cause MemManage fault in TF-M higher level isolations.
145 The issue is under investigation and recommended to avoid using this version.
146
Summer Qin6d5c91c2021-05-24 15:32:44 +0800147 - GNU Arm compiler v7.3.1+
148
149 .. tabs::
150
151 .. group-tab:: Linux
152
153 - Download the GNU Arm compiler from `here <https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads>`__.
154 - Add GNU Arm into environment:
155
156 .. code-block:: bash
157
158 export PATH=<GNU_ARM_PATH>/bin:$PATH
159
160 .. group-tab:: Windows
161
162 - Download the GNU Arm compiler from `here <https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads>`__.
163 - Add GNU Arm into environment:
164
165 .. code-block:: bash
166
167 export PATH=<GNU_ARM_PATH>\bin;$PATH
168
169 .. note::
170
171 GNU Arm compiler version *10-2020-q4-major* has an issue in CMSE
172 support. The bug is reported in `here <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99157>`__.
173 Select other GNU Arm compiler versions instead.
174
175 - IAR Arm compiler v8.42.x, v8.50.x
176
177 .. tabs::
178
179 .. group-tab:: Linux
180
181 - Download IAR build tools from `here <https://www.iar.com/iar-embedded-workbench/build-tools-for-linux/>`__.
182 - Add IAR Arm compiler into environment:
183
184 .. code-block:: bash
185
186 export PATH=<IAR_COMPILER_PATH>/bin:$PATH
187
188 .. group-tab:: Windows
189
190 - Download IAR build tools from `here <https://www.iar.com/iar-embedded-workbench/#!?architecture=Arm>`__.
191 - Add IAR Arm compiler into environment:
192
193 .. code-block:: bash
194
195 export PATH=<IAR_COMPILER_PATH>\bin;$PATH
196
197#############################
198Build AN521 regression sample
199#############################
200
201Here, we take building TF-M for AN521 platform with regression tests using GCC
202as an example:
203
204.. tabs::
205
206 .. group-tab:: Linux
207
208 .. code-block:: bash
209
210 cd trusted-firmware-m
211 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
212 cmake --build cmake_build -- install
213
214 Alternately using traditional cmake syntax
215
216 .. code-block:: bash
217
218 cd trusted-firmware-m
219 mkdir cmake_build
220 cd cmake_build
221 cmake .. -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
222 make install
223
224 .. group-tab:: Windows
225
226 .. code-block:: bash
227
228 cd trusted-firmware-m
229 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
230 cmake --build cmake_build -- install
231
232 Alternately using traditional cmake syntax
233
234 .. code-block:: bash
235
236 cd trusted-firmware-m
237 mkdir cmake_build
238 cd cmake_build
239 cmake -G"Unix Makefiles" .. -DTFM_PLATFORM=arm/mps2/an521 -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake -DTEST_S=ON -DTEST_NS=ON
240 make install
241
242###########################
243Run AN521 regression sample
244###########################
245
246Run the sample code on SSE-200 Fast-Model, using FVP_MPS2_AEMv8M provided by
247Arm Development Studio.
248
249.. note::
250
251 Arm Development Studio is not essential to develop TF-M, you can skip this
252 section if don't want to try on Arm develop boards.
253
254.. tabs::
255
256 .. group-tab:: Linux
257
258 1. install Arm Development Studio to get the fast-model.
259
260 Download Arm Development Studio from `here <https://developer.arm.com/tools-and-software/embedded/arm-development-studio>`__.
261
262 2. Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to symbol files in Debug
263 Configuration menu.
264
265 .. code-block:: bash
266
267 <DS_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \
268 --parameter fvp_mps2.platform_type=2 \
269 --parameter cpu0.baseline=0 \
270 --parameter cpu0.INITVTOR_S=0x10000000 \
271 --parameter cpu0.semihosting-enable=0 \
272 --parameter fvp_mps2.DISABLE_GATING=0 \
273 --parameter fvp_mps2.telnetterminal0.start_telnet=1 \
274 --parameter fvp_mps2.telnetterminal1.start_telnet=0 \
275 --parameter fvp_mps2.telnetterminal2.start_telnet=0 \
276 --parameter fvp_mps2.telnetterminal0.quiet=0 \
277 --parameter fvp_mps2.telnetterminal1.quiet=1 \
278 --parameter fvp_mps2.telnetterminal2.quiet=1 \
279 --application cpu0=<build_dir>/bin/bl2.axf \
280 --data cpu0=<build_dir>/bin/tfm_s_ns_signed.bin@0x10080000
281
282 .. group-tab:: Windows
283
284 1. install Arm Development Studio to get the fast-model.
285
286 Download Arm Development Studio from `here <https://developer.arm.com/tools-and-software/embedded/arm-development-studio>`__.
287
288 2. Add ``bl2.axf`` and ``tfm_s_ns_signed.bin`` to symbol files in Debug
289 Configuration menu.
290
291 .. code-block:: bash
292
293 <DS_PATH>\sw\models\bin\FVP_MPS2_AEMv8M \
294 --parameter fvp_mps2.platform_type=2 \
295 --parameter cpu0.baseline=0 \
296 --parameter cpu0.INITVTOR_S=0x10000000 \
297 --parameter cpu0.semihosting-enable=0 \
298 --parameter fvp_mps2.DISABLE_GATING=0 \
299 --parameter fvp_mps2.telnetterminal0.start_telnet=1 \
300 --parameter fvp_mps2.telnetterminal1.start_telnet=0 \
301 --parameter fvp_mps2.telnetterminal2.start_telnet=0 \
302 --parameter fvp_mps2.telnetterminal0.quiet=0 \
303 --parameter fvp_mps2.telnetterminal1.quiet=1 \
304 --parameter fvp_mps2.telnetterminal2.quiet=1 \
305 --application cpu0=<build_dir>/bin/bl2.axf \
306 --data cpu0=<build_dir>/bin/tfm_s_ns_signed.bin@0x10080000
307
308After completing the procedure you should see the following messages on the
309DAPLink UART (baud 115200 8n1)::
310
311 [INF] Starting bootloader
312 [INF] Image 0: magic=good, copy_done=0xff, image_ok=0xff
313 [INF] Scratch: magic=bad, copy_done=0x5, image_ok=0x9
314 [INF] Boot source: primary slot
315 [INF] Swap type: none
316 [INF] Bootloader chainload address offset: 0x20000
317 [INF] Jumping to the first image slot
318 [Sec Thread] Secure image initializing!
319
320 #### Execute test suites for the protected storage service ####
321 Running Test Suite PS secure interface tests (TFM_PS_TEST_2XXX)...
322 > Executing 'TFM_PS_TEST_2001'
323 Description: 'Create interface'
324 TEST PASSED!
325 > Executing 'TFM_PS_TEST_2002'
326 Description: 'Get handle interface (DEPRECATED)'
327 This test is DEPRECATED and the test execution was SKIPPED
328 TEST PASSED!
329 > Executing 'TFM_PS_TEST_2003'
330 Description: 'Get handle with null handle pointer (DEPRECATED)'
331 This test is DEPRECATED and the test execution was SKIPPED
332 TEST PASSED!
333 > Executing 'TFM_PS_TEST_2004'
334 Description: 'Get attributes interface'
335 TEST PASSED!
336 > Executing 'TFM_PS_TEST_2005'
337 Description: 'Get attributes with null attributes struct pointer'
338 ....
339
340##########################
341Tool & Dependency overview
342##########################
343
344To build the TF-M firmware the following tools are needed:
345
Anton Komlev4c436bf2021-10-18 21:59:55 +0100346 - C compiler of supported toolchains
347 - CMake version 3.15 or later
348 - Git
349 - gmake, aka GNU Make
350 - Python v3.x
351 - a set of python modules listed in ``tools/requiremtns.txt``
Summer Qin6d5c91c2021-05-24 15:32:44 +0800352
Anton Komlev4c436bf2021-10-18 21:59:55 +0100353Dependency chain
354----------------
Summer Qin6d5c91c2021-05-24 15:32:44 +0800355
356.. uml::
357
358 @startuml
359 skinparam state {
360 BackgroundColor #92AEE0
361 FontColor black
362 FontSize 16
363 AttributeFontColor black
364 AttributeFontSize 16
Summer Qin6d5c91c2021-05-24 15:32:44 +0800365 }
366 state fw as "Firmware" : TF-M binary
367 state c_comp as "C Compiler" : C99
Anton Komlev4c436bf2021-10-18 21:59:55 +0100368 state python as "Python" : v3.x
Summer Qin6d5c91c2021-05-24 15:32:44 +0800369
Summer Qin6d5c91c2021-05-24 15:32:44 +0800370 fw --> c_comp
371 fw --> CMake
372 CMake --> gmake
Anton Komlev4c436bf2021-10-18 21:59:55 +0100373 CMake --> Ninja
Summer Qin6d5c91c2021-05-24 15:32:44 +0800374 fw --> cryptography
375 fw --> pyasn1
376 fw --> yaml
377 fw --> jinja2
Ross Burton5ba82392021-11-10 16:56:10 +0000378 fw --> cbor2
Summer Qin6d5c91c2021-05-24 15:32:44 +0800379 fw --> click
380 fw --> imgtool
Anton Komlev4c436bf2021-10-18 21:59:55 +0100381 c_comp --> GCC
382 c_comp --> CLANG
383 c_comp --> IAR
384 cryptography --> python
385 pyasn1 --> python
386 yaml --> python
387 jinja2 --> python
Ross Burton5ba82392021-11-10 16:56:10 +0000388 cbor2 --> python
Anton Komlev4c436bf2021-10-18 21:59:55 +0100389 click --> python
390 imgtool --> python
Summer Qin6d5c91c2021-05-24 15:32:44 +0800391 @enduml
392
393##########
394Next steps
395##########
396
397Here are some next steps for exploring TF-M:
398
399 - Detailed :doc:`Build instructions </docs/technical_references/instructions/tfm_build_instruction>`.
400 - :doc:`IAR Build instructions </docs/technical_references/instructions/tfm_build_instruction_iar>`.
401 - Try other :doc:`Samples and Demos </docs/technical_references/instructions/run_tfm_examples_on_arm_platforms>`.
402 - :doc:`Documentation generation </docs/technical_references/instructions/documentation_generation>`.
403
404--------------
405
406*Copyright (c) 2017-2021, Arm Limited. All rights reserved.*