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