blob: cb4ac5c85f8042decd849771b6afdde0ea2ecc5e [file] [log] [blame]
Joakim Bech8e5c5b32018-10-25 08:18:32 +02001.. _aosp:
2
3####
4AOSP
5####
6This page contains information that tells how to get OP-TEE up and running on
7HiKey devices (see :ref:`hikey`, :ref:`hikey960`) together with AOSP. The build
8is based on the latest OP-TEE release and updated every quarter together with
9the regular OP-TEE releases.
10
11.. note::
12
13 We **only** use and support this static/stable configuration. If you try
14 using it with latest available AOSP, there is a risk that both OP-TEE and
15 other parts are not working as expected.
16
Joakim Bech8e5c5b32018-10-25 08:18:32 +020017Prerequisites
18*************
19
Victor Chong20441fe2019-02-13 08:37:23 +000020 - You should already be able to build AOSP for Hikey according to the
21 `official instructions`_. Note that the official build is **NOT** part
22 of the OP-TEE build. It is a separate and non-related build used only
23 to verify and make sure that your system has everything needed to
24 build AOSP without any issues.
25
26 - Distro should have necessary packages installed, and the repo tool
27 should be installed. Note that AOSP is built with Java. Also make sure
28 that the ``mtools`` package is installed, which is needed to make the
29 hikey boot image.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020030
31 - In addition, you will need the pre-requisites necessary to build
32 optee-os.
33
34After following the AOSP setup instructions, the following additional packages
Victor Chong20441fe2019-02-13 08:37:23 +000035from main `Prerequisites`_ page are needed. Please install them.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020036
37Build instructions
38******************
39
40.. code-block:: bash
41
42 $ git clone https://github.com/linaro-swg/optee_android_manifest
43 $ cd optee_android_manifest
44
45
46HiKey620 - LeMaker 8GB
47 .. code-block:: bash
48
49 $ ./sync-p.sh
50 $ ./build-p.sh
51
52HiKey620 - CircuitCo 4GB
53 .. code-block:: bash
54
55 $ ./sync-p.sh
Victor Chong20441fe2019-02-13 08:37:23 +000056 $ ./build-p.sh -4g
Joakim Bech8e5c5b32018-10-25 08:18:32 +020057
58HiKey960
59 .. code-block:: bash
60
61 $ ./sync-p-hikey960.sh
62 $ ./build-p-hikey960.sh
63
64These steps should (must) finish with no errors. In case there are errors, then
65there is no need trying to flash the device.
66
67.. warning::
68
69 - ``--force-sync`` is used which means you might **lose your work** so save
70 often, save frequent, and save accordingly, especially before running
71 ``sync-p.sh`` again!
72
73 - **Attention!** Do **NOT** use ``git clean`` with ``-x`` or ``-X`` or
74 ``-e`` option in ``optee_android_manifest/``, else risk **losing all
75 files** in the directory!!!
76
77.. hint::
78
79 You can add the ``-squashfs`` option to ``build.sh`` option to make
80 ``system.img`` size smaller, but this will make ``/system`` read-only, so
81 you won't be able to push files to it.
82
83For older releases (other versions of relatively stable builds), use
84below instead of ``./sync-p.sh``.
85
86.. code-block:: bash
87
88 $ ./wrappers/sync.sh -v p -t <hikey|hikey960> \
89 -bm <name of a pinned manifest file in archive/> \
90 2>&1 |tee logs/sync-p.log
91
92E.g.
93 .. code-block:: bash
94
95 $ ./wrappers/sync.sh -v p -t hikey \
96 -bm pinned-manifest-stable_yvr18.xml \
97 2>&1 |tee logs/sync-p.log
98
99Other existing files are for internal development purposes ONLY and
100**NOT SUPPORTED**!
101
102Flashing the image
103******************
104The instructions for flashing the image can be found in detail under
105``device/linaro/hikey/installer/hikey{960}/README`` in the tree.
106
107 1. Set jumpers/switches ``1-2`` and ``3-4``, and unset ``5-6``.
108 2. Reset the board. After that, invoke:
109
110HiKey620
111 .. code-block:: bash
112
113 $ cp -a out/target/product/hikey/*.img device/linaro/hikey/installer/hikey/
114 $ sudo ./device/linaro/hikey/installer/hikey/flash-all.sh /dev/ttyUSBn
115
116HiKey960
117 .. code-block:: bash
118
119 $ cp -a out/target/product/hikey960/*.img device/linaro/hikey/installer/hikey960/
120 $ sudo ./device/linaro/hikey/installer/hikey960/flash-all.sh /dev/ttyUSBn
121
122where the ``/dev/ttyUSBn`` device is the one that appears after rebooting with
Victor Chong20441fe2019-02-13 08:37:23 +0000123the 3-4 jumper set. Note that the device only remains in this recovery mode for
124about 90 seconds. If you take too long to run the flash commands, it will need
125to be reset again. After flashing, unset the 3-4 jumper again to boot normally.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200126
127Partial flashing
128****************
129The last handful of lines in the ``flash-all.sh`` script flash various images.
130After modifying and rebuilding Android, it is only necessary to flash `boot`,
131`system`, `cache`, `vendor` and `userdata`. If you aren't modifying the kernel,
132`boot` is not necessary, either.
133
134Experimental prebuilts
135**********************
136Available at http://snapshots.linaro.org/android under ``android-hikey*``
137directories.
138
139Running xtest
140*************
141Do NOT try to run ``tee-supplicant`` as it has already been started
142automatically as a service! Once booted to the command prompt, ``xtest`` can be
Victor Chong20441fe2019-02-13 08:37:23 +0000143run immediately from the console or an ``adb`` shell. For more details about
144running OP-TEE, please see :ref:`optee_test_run_xtest` at :ref:`optee_test`.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200145
146Running VTS Gtest unit for Gatekeeper and Keymaster (Optional)
147**************************************************************
148On the device after going into the command prompt, run:
149
150.. code-block:: bash
151
Victor Chong20441fe2019-02-13 08:37:23 +0000152 $ su
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200153 $ ./data/nativetest64/VtsHalGatekeeperV1_0TargetTest/VtsHalGatekeeperV1_0TargetTest
154 $ ./data/nativetest64/VtsHalKeymasterV3_0TargetTest/VtsHalKeymasterV3_0TargetTest
155
156.. note::
157
Victor Chong20441fe2019-02-13 08:37:23 +0000158 These tests need to be run as root.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200159
160Enable adb over USB
161*******************
162
163Boot the device. On serial console:
164
165.. code-block:: bash
166
167 $ su setprop sys.usb.configfs 1
168 $ stop adbd
169 $ start adbd
170
171Known issues
172************
Victor Chong20441fe2019-02-13 08:37:23 +0000173 - If you don't have a monitor or hdmi emulator (dummy plug) connected to
174 the board, you'll see constant errors scrolling on the console. As a
175 workaround, move ``android.hardware.graphics.composer@2.1-service.rc``
176 out of ``/vendor/etc/init``. Move it back in when working with a
177 monitor again.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200178
Victor Chong20441fe2019-02-13 08:37:23 +0000179 - Adb over USB currently doesn't work on HiKey960. As a workaround, use
180 adb over tcpip. See https://bugs.96boards.org/show_bug.cgi?id=502 for
181 details on how to connect. There are still some limitations however.
182 E.g. running ``adb shell`` or a second ``adb`` instance will break the
183 current adb tcpip connection. This might be due to unstable WiFi
184 (there are periodic error messages like ``wlcore: WARNING corrupted
185 packet in RX: status: 0x1 len: 76``) or just incompleteness of the
186 generic HiKey960 builds under P.
187
188.. _official instructions: https://source.android.com/source/devices.html
189.. _Prerequisites: https://optee.readthedocs.io/building/prerequisites.html#prerequisites