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