blob: d68c4eac08ffc07f0f76df8eea5c40395735b29e [file] [log] [blame]
Joakim Bech8e5c5b32018-10-25 08:18:32 +02001.. _build:
2
3#####
4build
5#####
6Why this particular git? As it turns out it's totally possible to put together
7everything on your own. You can build all the individual components, os, client,
8xtest, Linux kernel, TF-A, TianoCore, QEMU, Buildroot_ etc and put all the
9binaries at correct locations and write your own command lines, Makefiles,
10shell-scripts etc that will work nicely on the devices you are interested in. If
11you know how to do that, fine, please go a head. But for newcomers it's way to
12much behind the scenes to be able to setup a working environment. Also, if you
13for some reason want to run something in an automated way, then you need
14something else wrapping it up for you.
15
16With this particular git **built.git** our goal is to simply to make it easy for
17newcomers to get started with OP-TEE using the devices we've listed in this
18document.
19
20
21git location
22************
23https://github.com/OP-TEE/build
24
25
26Why repo?
27*********
28We discussed alternatives, initially we started out with having a simple
29shell-script, that worked to start with, but after getting more gits in use and
30support for more devices it started to be difficult to maintain. In the end we
31ended up choosing between repo_ from the Google AOSP project and `git
32submodules`_. No matter which you choose, there will always be some person
33arguing that one is better than the other. For us we decided to use repo. Not
34directly for the features itself from repo, but for the ability to simply work
35with different manifests containing both stable and non-stable release. Using
36some tips and tricks you can also speed up setup time significantly. For day to
37day work with commits, branches etc we tend to use git commands directly.
38
39
40.. _root_fs:
41
42Root filesystem
43***************
44The rootfs in the builds that we cover here are as small as possible and is
45based on a stripped down Buildroot_ configuration adding just enough in the
46rootfs such that one can:
47
48 - Boot OP-TEE.
49 - Run xtest with no regressions.
50 - Easily add additional developer tools like, strace, valgrind etc.
51
52.. note::
53
54 As a consequence of enabling "just enough", it is likely that **non-UART**
55 based enviroments won't work out of the box. I.e., if you try to boot up an
56 enviroment using HDMI and connect keyboards and other devices it is likely
57 that things will not work. To make them work, you probably need to rebuild
58 Linux kernel with correct drivers/frameworks enabled and in addition to that
59 enable binaries/daemons in Buildroot that might be necessary (user space
60 tools and drivers).
61
62
63How do I build using AOSP / OpenEmbedded?
64*****************************************
65For guides how to build AOSP, please refer to our :ref:`aosp` page. For
Joakim Beche58b15c2020-04-15 10:48:41 +020066OpenEmbedded we have no guide ready.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020067
68.. _optee_developer_setup:
69
70Platforms supported by build.git
71********************************
72Below is a table showing the platforms supported by build.git. OP-TEE as such
Joakim Beche58b15c2020-04-15 10:48:41 +020073supports many more platforms. To find out how to run OP-TEE on those, please
74reach out to the maintainer of that platform directly if you have build related
75questions etc. Please see the MAINTAINERS_ file for contact information.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020076
77.. Please keep this list sorted in alphabetic order:
78.. list-table::
79 :header-rows: 1
80
81 * - Platform
82 - Composite flag
83 - Publicly available?
84
85 * - `ARM Juno Board`_
86 - ``PLATFORM=vexpress-juno``
87 - Yes
88
89 * - `ARM Foundation FVP`_
90 - ``PLATFORM=vexpress-fvp``
91 - Yes
92
Pipat Methavanitpong83e734b2019-06-05 17:20:31 +090093 * - `DeveloperBox`_
94 - ``PLATFORM=synquacer``
95 - Yes
96
Joakim Bech8e5c5b32018-10-25 08:18:32 +020097 * - `HiKey Kirin 620`_
98 - ``PLATFORM=hikey``
99 - Yes
100
101 * - `HiKey 960`_
102 - ``PLATFORM=hikey-hikey960``
103 - Yes
104
105 * - `MediaTek MT8173 EVB Board`_ (deprecated)
106 - ``PLATFORM=mediatek-mt8173``
107 - No
108
109 * - `Poplar`_
110 - ``PLATFORM=poplar``
111 - Yes
112
113 * - `QEMU`_
114 - ``PLATFORM=vexpress-qemu_virt``
115 - Yes
116
117 * - `QEMUv8`_
118 - ``PLATFORM=vexpress-qemu_armv8a``
119 - Yes
120
121 * - `Raspberry Pi 3`_
122 - ``PLATFORM=rpi3``
123 - Yes
124
125 * - `Texas Instruments DRA7xx`_
126 - ``PLATFORM=ti-dra7xx``
127 - Yes
128
129 * - `Texas Instruments AM57xx`_
130 - ``PLATFORM=ti-am57xx``
131 - Yes
132
133 * - `Texas Instruments AM43xx`_
134 - ``PLATFORM=ti-am43xx``
135 - Yes
136
137
138Manifests
139*********
140.. _current_version:
141
142Current version
143===============
144Here is a list of manifests for the devices currently supported in
145``build.git``. With these you will get a setup containing the all necessary
146software components to run OP-TEE on the chosen device. Beware that this will
147run latest available on OP-TEE gits meaning that if you re-sync then you will
148most likely get new commits. If you need a stable/tagged version with non-moving
149gits, then please refer to the next section instead.
150
151.. Please keep this list sorted in alphabetic order:
152
Pipat Methavanitpong83e734b2019-06-05 17:20:31 +0900153+----------------+-------------------+----------------------+
154| Target | Manifest xml | Device documentation |
155+================+===================+======================+
156| AM43xx | ``am43xx.xml`` | :ref:`ti` |
157+----------------+-------------------+----------------------+
158| AM57xx | ``am57xx.xml`` | :ref:`ti` |
159+----------------+-------------------+----------------------+
160| DeveloperBox | ``synquacer.xml`` | :ref:`devbox` |
161+----------------+-------------------+----------------------+
162| ARM Juno board | ``juno.xml`` | :ref:`juno` |
163+----------------+-------------------+----------------------+
164| DRA7xx | ``dra7xx.xml`` | :ref:`ti` |
165+----------------+-------------------+----------------------+
166| FVP | ``fvp.xml`` | :ref:`fvp` |
167+----------------+-------------------+----------------------+
168| HiKey 960 | ``hikey960.xml`` | :ref:`hikey960` |
169+----------------+-------------------+----------------------+
170| HiKey | ``hikey.xml`` | :ref:`hikey` |
171+----------------+-------------------+----------------------+
172| Poplar Debian | ``poplar.xml`` | |
173+----------------+-------------------+----------------------+
174| QEMU | ``default.xml`` | :ref:`qemu_v7` |
175+----------------+-------------------+----------------------+
176| QEMUv8 | ``qemu_v8.xml`` | :ref:`qemu_v8` |
177+----------------+-------------------+----------------------+
178| Raspberry Pi 3 | ``rpi3.xml`` | :ref:`rpi3` |
179+----------------+-------------------+----------------------+
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200180
181Stable releases
182===============
183Starting from OP-TEE ``v3.1`` you can check out stable releases by using the
184same manifests as for current version above, but with the difference that **you
185also need to specify a branch** where the name corresponds to the release
186version. I.e., when we are doing releases we are creating a branch with a name
187corresponding to the release version. So, let's for example say that you want to
188checkout a stable OP-TEE ``v3.4`` for Raspberry Pi 3, then you do like this
189instead of what is mentioned further down in section
190":ref:`build_get_the_source`" (note the ``-b 3.4.0``):
191
192.. code-block:: bash
193
194 ...
195 $ repo init -u https://github.com/OP-TEE/manifest.git -m rpi3.xml -b 3.4.0
196 ...
197
198Stable releases prior to OP-TEE v3.1 (v1.0.0 to v3.0.0)
199=======================================================
200Before OP-TEE ``v3.1`` we used to have separate xml-manifest files for the
201stable builds. If you for some reason need an older stable release, then you can
202use the ``xyz_stable.xml`` file corresponding to your device. The way to init
203``repo`` is almost the same as described above, the major difference is the name
204of manifest being referenced (``-m xyz_stable.xml``) and that we are referring
205to a tag instead of a branch (``-b refs/tags/MAJOR.MINOR.PATCH``). So as an
206example, if you need to setup the ``2.1.0`` stable release for HiKey, then you
207would do like this instead of what is mentioned further down in section
208":ref:`build_get_the_source`".
209
210.. code-block:: bash
211
212 ...
213 repo init -u https://github.com/OP-TEE/manifest.git -m hikey_stable.xml -b refs/tags/2.1.0
214 ...
215
216Here is a list of targets and the names of the stable manifests files which were
217supported by older releases:
218
219.. Please keep this list sorted in alphabetic order:
220
221+----------------+-----------------------------+
222| Target | Stable manifest xml |
223+================+=============================+
224| AM43xx | ``am43xx_stable.xml`` |
225+----------------+-----------------------------+
226| AM57xx | ``am57xx_stable.xml`` |
227+----------------+-----------------------------+
228| ARM Juno board | ``juno_stable.xml`` |
229+----------------+-----------------------------+
230| DRA7xx | ``dra7xx_stable.xml`` |
231+----------------+-----------------------------+
232| FVP | ``fvp_stable.xml`` |
233+----------------+-----------------------------+
234| HiKey 960 | ``hikey960_stable.xml`` |
235+----------------+-----------------------------+
236| HiKey Debian | ``hikey_debian_stable.xml`` |
237+----------------+-----------------------------+
238| HiKey | ``hikey_stable.xml`` |
239+----------------+-----------------------------+
240| MTK8173 | ``mt8173-evb_stable.xml`` |
241+----------------+-----------------------------+
242| QEMU | ``default_stable.xml`` |
243+----------------+-----------------------------+
244| QEMUv8 | ``qemu_v8_stable.xml`` |
245+----------------+-----------------------------+
246| Raspberry Pi 3 | ``rpi3_stable.xml`` |
247+----------------+-----------------------------+
248
249.. _get_and_build_the_solution:
250
251
252Get and build the solution
253**************************
254Below we will describe the general way of how to get the source, build the
255solution and how to run xtest on the device. For device specific instructions,
256please see the links in the table in the ":ref:`current_version`" section.
257
258.. _build_prerequisites:
259
260Step 1 - Prerequisites
261======================
262Install prerequisites according to the :ref:`prerequisites` page.
263
264
265.. _build_install_repo:
266
267Step 2 - Install Android repo
268=============================
269Note that here you don't install a huge SDK, it's simply a Python script that
270you download and put in your ``$PATH``, that's it. Exactly how to "install"
271repo, can be found at the Google repo_ pages, so follow those instructions
272before continuing.
273
274
275.. _build_get_the_source:
276
277Step 3 - Get the source code
278============================
279Choose the manifest corresponding to the platform you intend to use (see the
280table in section ":ref:`current_version`". For example, if you intend to use
281Raspberry Pi3, then at line 3 below, ``${TARGET}.xml`` shall be ``rpi3.xml``.
282The ``<optee-project>`` is whatever location where you want to store the entire
283OP-TEE developer setup.
284
285.. code-block:: bash
286 :linenos:
287 :emphasize-lines: 3
288
289 $ mkdir -p <optee-project>
290 $ cd <optee-project>
291 $ repo init -u https://github.com/OP-TEE/manifest.git -m ${TARGET}.xml [-b ${BRANCH}]
292 $ repo sync -j4 --no-clone-bundle
293
294.. hint::
295
296 By referencing an existing and locally saved repo forest you can save lots
297 of time. We are talking about doing repo sync in 30 seconds instead of 15-30
298 minutes (see the :ref:`tips_and_tricks` section for more details).
299
300
301.. _build_get_toolchains:
302
303Step 4 - Get the toolchains
304===========================
305In OP-TEE we're using different toolchains for different targets (depends on
306ARMv7-A ARMv8-A 64/32bit solutions). In any case start by downloading the
307toolchains by:
308
309.. code-block:: bash
310
311 $ cd <optee-project>/build
312 $ make -j2 toolchains
313
314
315.. _build_make:
316
317Step 5 - Build the solution
318===========================
319We've configured our repo manifests, so that repo will always automatically
320symlink the ``Makefile`` to the correct device specific makefile, that means
321that you simply start the build by running (still in ``<optee-project>/build``)
322
323.. code-block:: bash
324
325 $ make -j `nproc`
326
327This step will also take some time, but you can speed up subsequent builds by
328enabling ccache_ (again see :ref:`tips_and_tricks`).
329
330.. hint::
331
332 **If you're having build issues**, then you can pipe the entire build log to
333 a file, which makes it easier to search for the issue using a regular
334 editor. In that case also avoid the ``-j`` flag so it's easier to see in what
335 order things are happening. To create a ``build.log`` file do: ``$ make 2>&1
336 | tee build.log``
337
338
339.. _build_flash:
340
341Step 6 - Flash the device
342=========================
343On **non-emulated** solutions (this means that you shouldn't do this step when
344you are running QEMU-v7/v8 and FVP), you will need to flash the software in some
345way. We've tried to "hide" that under the following make target:
346
347.. code-block:: bash
348
349 $ make flash
350
351But, since some devices are trickier to flash than others, please see the
352:ref:`device_specific`. See this just as a general instruction.
353
354Step 7 - Boot up the device
355===========================
356This is device specific (see :ref:`device_specific`).
357
358
359.. _build_tee_supplicant:
360
361Step 8 - Load tee-supplicant
362============================
363On **most** solutions tee-supplicant is already running (check by running ``$ ps
364aux | grep tee-supplicant``) on others not. If it's **not** running, then start
365it by running:
366
367.. code-block:: bash
368
369 $ tee-supplicant -d
370
371.. note::
372 If you've built using our manifest you should not need to modprobe any
373 OP-TEE/TEE kernel driver since it's built into the kernel in all our setups.
374
375
376.. _build_run_xtest:
377
378Step 9 - Run xtest
379==================
380The entire xtest test suite has been deployed when you we're making the builds
381in previous steps, i.e, in general there is no need to copy any binaries
382manually. Everything has been put into the :ref:`root_fs` automatically. So, to
383run xtest, you simply type:
384
385.. code-block:: bash
386
387 $ xtest
388
389If there are no regressions / issues found, xtest should end with something like
390this:
391
392.. code-block:: none
393
394 ...
395 +-----------------------------------------------------
396 23476 subtests of which 0 failed
397 67 test cases of which 0 failed
398 0 test case was skipped
399 TEE test application done!
400
401.. hint::
402
403 For other ways to run xtest, please refer to the ":ref:`optee_test_run_xtest`"
404 page at :ref:`optee_test`.
405
406.. _tips_and_tricks:
407
408Tips and Tricks
409***************
410Reference existing project to speed up repo sync
411================================================
412Doing a ``repo init``, ``repo sync`` from scratch can take a fair amount of
413time. The main reason for that is simply because of the size of some of the gits
414we are using, like for the Linux kernel and EDK2. With repo you can reference an
415existing forest and by doing so you can speed up repo sync to taking 30 seconds
416instead of 15-30 minutes. The way to do this are as follows.
417
418 1. Start by setup a clean forest that you will not touch, in this example,
419 let us call that ``optee-ref`` and put that under for
420 ``$HOME/devel/optee-ref``. This step will take somewhere between 15- to
421 45 minutes, depending on your connection speed to internet.
422
423 2. Then setup a cronjob (``crontab -e``) that does a ``repo sync`` in this
424 folder particular folder once a night (that is more than enough).
425
426 3. Now you should setup your actual tree which you are going to use as your
427 working tree. The way to do this is almost the same as stated in the
428 instructions above (see the ":ref:`build_get_the_source`" section) , the
429 only difference is that you **also** reference the other local forest
430 when running ``repo init``, like this
431
432 .. code-block:: bash
433
434 $ repo init -u https://github.com/OP-TEE/manifest.git --reference $HOME/devel/optee-ref
435
436 4. The rest is the same above, but now it will only take a couple of seconds
437 to clone a forest.
438
439Normally '1' and '2' above is something you will only do once. Also if you
440ignore step '2', then you will **still** get the latest from official git trees,
441since repo will also check for updates that aren't at the local reference.
442
443Use ccache
444==========
445ccache_ is a tool that caches build object-files etc locally on the disc and can
446speed up build time significantly in subsequent builds. On Debian-based systems
447(Ubuntu, Mint etc) you simply install it by running:
448
449.. code-block:: bash
450
451 $ sudo apt-get install ccache
452
453The makefiles in build.git are configured to automatically find and use ccache
454if ccache is installed on your system, so other than having it installed you
455don't have to think about anything.
456
457.. _Buildroot: https://buildroot.org
458.. _ccache: https://ccache.samba.org
459.. _git submodules: https://git-scm.com/book/en/v2/Git-Tools-Submodules
460.. _MAINTAINERS: https://github.com/OP-TEE/optee_os/blob/master/MAINTAINERS
461.. _repo: https://source.android.com/source/downloading.html
462
463.. Links to devices etc:
464.. _ARM Juno Board: http://www.arm.com/products/tools/development-boards/versatile-express/juno-arm-development-platform.php
465.. _ARM Foundation FVP: http://www.arm.com/fvp
Pipat Methavanitpong83e734b2019-06-05 17:20:31 +0900466.. _DeveloperBox: https://www.96boards.org/product/developerbox
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200467.. _HiKey Kirin 620: https://www.96boards.org/products/hikey
468.. _HiKey 960: https://www.96boards.org/product/hikey960
469.. _MediaTek MT8173 EVB Board: http://www.mediatek.com/en/products/mobile-communications/tablet/mt8173
470.. _Poplar: https://www.96boards.org/product/poplar/
471.. _QEMU: http://wiki.qemu.org/Main_Page
472.. _QEMUv8: http://wiki.qemu.org/Main_Page
473.. _Raspberry Pi 3: https://www.raspberrypi.org/products/raspberry-pi-3-model-b
474.. _Texas Instruments DRA7xx: http://www.ti.com/product/DRA746
475.. _Texas Instruments AM57xx: http://www.ti.com/product/AM5728
476.. _Texas Instruments AM43xx: http://www.ti.com/product/AM4379