blob: e2a4c22f2614152eeb61cd6a831559fbc7d3739c [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
Victor Chong731a5502020-04-23 10:08:14 +010014 using it with the latest available AOSP, there is a risk that both OP-TEE
15 and other parts are not working as expected.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020016
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 Chong04dd2d02020-05-18 07:06:15 +010035from main :ref:`prerequisites` page are needed. Please install them.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020036
37Build instructions
38******************
39
40.. code-block:: bash
41
Victor Chongc03db892019-10-08 07:10:38 +010042 $ git clone https://github.com/linaro-swg/optee_android_manifest [-b <release_tag>]
Victor Chong731a5502020-04-23 10:08:14 +010043 # release tags come in the form of X.Y.Z, e.g. 3.8.0
Joakim Bech8e5c5b32018-10-25 08:18:32 +020044 $ cd optee_android_manifest
45
46
47HiKey620 - LeMaker 8GB
48 .. code-block:: bash
49
50 $ ./sync-p.sh
51 $ ./build-p.sh
52
53HiKey620 - CircuitCo 4GB
54 .. code-block:: bash
55
56 $ ./sync-p.sh
Victor Chong20441fe2019-02-13 08:37:23 +000057 $ ./build-p.sh -4g
Joakim Bech8e5c5b32018-10-25 08:18:32 +020058
59HiKey960
60 .. code-block:: bash
61
62 $ ./sync-p-hikey960.sh
63 $ ./build-p-hikey960.sh
64
Victor Chong731a5502020-04-23 10:08:14 +010065These steps **MUST** finish with **no errors**. For ``sync*.sh`` scripts, that
66means there must be no errors prior to the ``Sync done!`` console output. For
67``build*.sh`` scripts, that means there must be a ``#### build completed
68successfully (MM:SS (mm:ss)) ####`` console output! If there are errors, then
69there is no point in trying to flash the device.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020070
71.. warning::
72
73 - ``--force-sync`` is used which means you might **lose your work** so save
74 often, save frequent, and save accordingly, especially before running
75 ``sync-p.sh`` again!
76
77 - **Attention!** Do **NOT** use ``git clean`` with ``-x`` or ``-X`` or
78 ``-e`` option in ``optee_android_manifest/``, else risk **losing all
79 files** in the directory!!!
80
81.. hint::
82
83 You can add the ``-squashfs`` option to ``build.sh`` option to make
84 ``system.img`` size smaller, but this will make ``/system`` read-only, so
85 you won't be able to push files to it.
86
Victor Chong731a5502020-04-23 10:08:14 +010087Currently, only version P is supported. Other existing files are for internal
88development purposes ONLY and **NOT SUPPORTED**!
Joakim Bech8e5c5b32018-10-25 08:18:32 +020089
90Flashing the image
91******************
92The instructions for flashing the image can be found in detail under
93``device/linaro/hikey/installer/hikey{960}/README`` in the tree.
94
95 1. Set jumpers/switches ``1-2`` and ``3-4``, and unset ``5-6``.
96 2. Reset the board. After that, invoke:
97
98HiKey620
99 .. code-block:: bash
100
101 $ cp -a out/target/product/hikey/*.img device/linaro/hikey/installer/hikey/
102 $ sudo ./device/linaro/hikey/installer/hikey/flash-all.sh /dev/ttyUSBn
103
104HiKey960
105 .. code-block:: bash
106
107 $ cp -a out/target/product/hikey960/*.img device/linaro/hikey/installer/hikey960/
108 $ sudo ./device/linaro/hikey/installer/hikey960/flash-all.sh /dev/ttyUSBn
109
110where the ``/dev/ttyUSBn`` device is the one that appears after rebooting with
Victor Chong20441fe2019-02-13 08:37:23 +0000111the 3-4 jumper set. Note that the device only remains in this recovery mode for
112about 90 seconds. If you take too long to run the flash commands, it will need
113to be reset again. After flashing, unset the 3-4 jumper again to boot normally.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200114
115Partial flashing
116****************
117The last handful of lines in the ``flash-all.sh`` script flash various images.
118After modifying and rebuilding Android, it is only necessary to flash `boot`,
119`system`, `cache`, `vendor` and `userdata`. If you aren't modifying the kernel,
120`boot` is not necessary, either.
121
122Experimental prebuilts
123**********************
124Available at http://snapshots.linaro.org/android under ``android-hikey*``
Victor Chong731a5502020-04-23 10:08:14 +0100125directories. Note that these images do not always work and are **NOT
126SUPPORTED** as well!
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200127
128Running xtest
129*************
130Do NOT try to run ``tee-supplicant`` as it has already been started
131automatically as a service! Once booted to the command prompt, ``xtest`` can be
Victor Chong20441fe2019-02-13 08:37:23 +0000132run immediately from the console or an ``adb`` shell. For more details about
133running OP-TEE, please see :ref:`optee_test_run_xtest` at :ref:`optee_test`.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200134
135Running VTS Gtest unit for Gatekeeper and Keymaster (Optional)
136**************************************************************
137On the device after going into the command prompt, run:
138
139.. code-block:: bash
140
Victor Chong20441fe2019-02-13 08:37:23 +0000141 $ su
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200142 $ ./data/nativetest64/VtsHalGatekeeperV1_0TargetTest/VtsHalGatekeeperV1_0TargetTest
143 $ ./data/nativetest64/VtsHalKeymasterV3_0TargetTest/VtsHalKeymasterV3_0TargetTest
144
145.. note::
146
Victor Chong20441fe2019-02-13 08:37:23 +0000147 These tests need to be run as root.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200148
149Enable adb over USB
150*******************
151
152Boot the device. On serial console:
153
154.. code-block:: bash
155
156 $ su setprop sys.usb.configfs 1
157 $ stop adbd
158 $ start adbd
159
160Known issues
161************
Victor Chong20441fe2019-02-13 08:37:23 +0000162 - If you don't have a monitor or hdmi emulator (dummy plug) connected to
163 the board, you'll see constant errors scrolling on the console. As a
164 workaround, move ``android.hardware.graphics.composer@2.1-service.rc``
165 out of ``/vendor/etc/init``. Move it back in when working with a
166 monitor again.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200167
Victor Chong20441fe2019-02-13 08:37:23 +0000168 - Adb over USB currently doesn't work on HiKey960. As a workaround, use
169 adb over tcpip. See https://bugs.96boards.org/show_bug.cgi?id=502 for
170 details on how to connect. There are still some limitations however.
171 E.g. running ``adb shell`` or a second ``adb`` instance will break the
172 current adb tcpip connection. This might be due to unstable WiFi
173 (there are periodic error messages like ``wlcore: WARNING corrupted
174 packet in RX: status: 0x1 len: 76``) or just incompleteness of the
175 generic HiKey960 builds under P.
176
177.. _official instructions: https://source.android.com/source/devices.html