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