blob: a43e551aa705469cb7eb22c139e916cae239a738 [file] [log] [blame]
Joakim Bech8e5c5b32018-10-25 08:18:32 +02001.. todo::
2
3 Joakim: Technically this would belong under "gits". But I think it is more
4 visible to have it directly under "AOSP" under "Build and run".
5
6.. _aosp:
7
8####
9AOSP
10####
11This page contains information that tells how to get OP-TEE up and running on
12HiKey devices (see :ref:`hikey`, :ref:`hikey960`) together with AOSP. The build
13is based on the latest OP-TEE release and updated every quarter together with
14the regular OP-TEE releases.
15
16.. note::
17
18 We **only** use and support this static/stable configuration. If you try
19 using it with latest available AOSP, there is a risk that both OP-TEE and
20 other parts are not working as expected.
21
22As a reference, there are official instructions for HiKey builds at Google
23pages, see `AOSP Hikey build instructions`_.
24
25Prerequisites
26*************
27
28 - You should already be able to build AOSP according to the official
29 instructions. Distro should have necessary packages installed, and the repo
30 tool should be installed. Note that AOSP needs to be built with Java.
31 Also make sure that the ``mtools`` package is installed, which is needed
32 to make the hikey boot image.
33
34 - In addition, you will need the pre-requisites necessary to build
35 optee-os.
36
37After following the AOSP setup instructions, the following additional packages
38are needed.
39
40.. todo::
41
42 Joakim: How much does this really differ from the "global" prerequisites.
43 Could we instead refer to the global as the "main" prerequisites and then
44 just list the delta here?
45
46.. code-block:: bash
47
48 $ sudo apt-get install android-tools-adb android-tools-fastboot autoconf \
49 automake bc bison build-essential cscope curl device-tree-compiler flex \
50 ftp-upload gdisk iasl libattr1-dev libc6:i386 libcap-dev libfdt-dev \
51 libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev \
52 libpixman-1-dev libssl-dev libstdc++6:i386 libtool libz1:i386 make \
53 mtools netcat python-crypto python-serial python-wand unzip uuid-dev \
54 xdg-utils xterm xz-utils zlib1g-dev python-mako openjdk-8-jdk \
55 ncurses-dev realpath android-tools-fsutils dosfstools libxml2-utils
56
57Build instructions
58******************
59
60.. code-block:: bash
61
62 $ git clone https://github.com/linaro-swg/optee_android_manifest
63 $ cd optee_android_manifest
64
65
66HiKey620 - LeMaker 8GB
67 .. code-block:: bash
68
69 $ ./sync-p.sh
70 $ ./build-p.sh
71
72HiKey620 - CircuitCo 4GB
73 .. code-block:: bash
74
75 $ ./sync-p.sh
76 $ ./build.sh -v p -4g
77
78HiKey960
79 .. code-block:: bash
80
81 $ ./sync-p-hikey960.sh
82 $ ./build-p-hikey960.sh
83
84These steps should (must) finish with no errors. In case there are errors, then
85there is no need trying to flash the device.
86
87.. warning::
88
89 - ``--force-sync`` is used which means you might **lose your work** so save
90 often, save frequent, and save accordingly, especially before running
91 ``sync-p.sh`` again!
92
93 - **Attention!** Do **NOT** use ``git clean`` with ``-x`` or ``-X`` or
94 ``-e`` option in ``optee_android_manifest/``, else risk **losing all
95 files** in the directory!!!
96
97.. hint::
98
99 You can add the ``-squashfs`` option to ``build.sh`` option to make
100 ``system.img`` size smaller, but this will make ``/system`` read-only, so
101 you won't be able to push files to it.
102
103For older releases (other versions of relatively stable builds), use
104below instead of ``./sync-p.sh``.
105
106.. code-block:: bash
107
108 $ ./wrappers/sync.sh -v p -t <hikey|hikey960> \
109 -bm <name of a pinned manifest file in archive/> \
110 2>&1 |tee logs/sync-p.log
111
112E.g.
113 .. code-block:: bash
114
115 $ ./wrappers/sync.sh -v p -t hikey \
116 -bm pinned-manifest-stable_yvr18.xml \
117 2>&1 |tee logs/sync-p.log
118
119Other existing files are for internal development purposes ONLY and
120**NOT SUPPORTED**!
121
122Flashing the image
123******************
124The instructions for flashing the image can be found in detail under
125``device/linaro/hikey/installer/hikey{960}/README`` in the tree.
126
127 1. Set jumpers/switches ``1-2`` and ``3-4``, and unset ``5-6``.
128 2. Reset the board. After that, invoke:
129
130HiKey620
131 .. code-block:: bash
132
133 $ cp -a out/target/product/hikey/*.img device/linaro/hikey/installer/hikey/
134 $ sudo ./device/linaro/hikey/installer/hikey/flash-all.sh /dev/ttyUSBn
135
136HiKey960
137 .. code-block:: bash
138
139 $ cp -a out/target/product/hikey960/*.img device/linaro/hikey/installer/hikey960/
140 $ sudo ./device/linaro/hikey/installer/hikey960/flash-all.sh /dev/ttyUSBn
141
142where the ``/dev/ttyUSBn`` device is the one that appears after rebooting with
143the 3-4 jumper installed. Note that the device only remains in this recovery
144mode for about 90 seconds. If you take too long to run the flash commands, it
145will need to be reset again.
146
147Partial flashing
148****************
149The last handful of lines in the ``flash-all.sh`` script flash various images.
150After modifying and rebuilding Android, it is only necessary to flash `boot`,
151`system`, `cache`, `vendor` and `userdata`. If you aren't modifying the kernel,
152`boot` is not necessary, either.
153
154Experimental prebuilts
155**********************
156Available at http://snapshots.linaro.org/android under ``android-hikey*``
157directories.
158
159Running xtest
160*************
161Do NOT try to run ``tee-supplicant`` as it has already been started
162automatically as a service! Once booted to the command prompt, ``xtest`` can be
163run immediately from an ``adb`` shell. For more details about running OP-TEE,
164please see :ref:`optee_test_run_xtest` at :ref:`optee_test`.
165
166.. note::
167
168 If running from the console shell, run ``su shell,shell,inet xtest``
169 instead. This is due to the console ``shell`` user not belonging to the
170 ``inet`` group by default. We're looking into improving this limitation, and
171 contributions are welcome!
172
173Running VTS Gtest unit for Gatekeeper and Keymaster (Optional)
174**************************************************************
175On the device after going into the command prompt, run:
176
177.. code-block:: bash
178
179 $ su system
180 $ ./data/nativetest64/VtsHalGatekeeperV1_0TargetTest/VtsHalGatekeeperV1_0TargetTest
181 $ ./data/nativetest64/VtsHalKeymasterV3_0TargetTest/VtsHalKeymasterV3_0TargetTest
182
183.. note::
184
185 These tests need to be run as the ``system`` user.
186
187Enable adb over USB
188*******************
189
190Boot the device. On serial console:
191
192.. code-block:: bash
193
194 $ su setprop sys.usb.configfs 1
195 $ stop adbd
196 $ start adbd
197
198Known issues
199************
200Adb over USB currently doesn't work on HiKey960. As a workaround, use adb over
201tcpip. See https://bugs.96boards.org/show_bug.cgi?id=502 for details on how to
202connect. There are still some limitations however. E.g. running ``adb shell`` or
203a second ``adb`` instance will break the current adb tcpip connection. This
204might be due to unstable WiFi (there are periodic error messages like ``wlcore:
205WARNING corrupted packet in RX: status: 0x1 len: 76``) or just incompleteness of
206the generic HiKey960 builds under P.
207
208.. _AOSP Hikey build instructions: https://source.android.com/source/devices.html