blob: 40dbb1ffc9348ad2aaecc88d167d2441b3327291 [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
Joakim Bech9fd65312023-10-16 10:19:59 +02007HiKey devices (see :ref:`hikey`, :ref:`hikey960`) together with AOSP.
8
9.. warning::
10
11 The build used to be based on the latest OP-TEE release and used to be
12 updated every quarter together with the regular OP-TEE releases. However, the
13 AOSP build hasn't been updated since July 2021 and is **no longer
14 maintained**.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020015
16.. note::
17
18 We **only** use and support this static/stable configuration. If you try
Victor Chong731a5502020-04-23 10:08:14 +010019 using it with the latest available AOSP, there is a risk that both OP-TEE
20 and other parts are not working as expected.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020021
Joakim Bech8e5c5b32018-10-25 08:18:32 +020022Prerequisites
23*************
24
Victor Chong20441fe2019-02-13 08:37:23 +000025 - You should already be able to build AOSP for Hikey according to the
26 `official instructions`_. Note that the official build is **NOT** part
27 of the OP-TEE build. It is a separate and non-related build used only
28 to verify and make sure that your system has everything needed to
29 build AOSP without any issues.
30
31 - Distro should have necessary packages installed, and the repo tool
32 should be installed. Note that AOSP is built with Java. Also make sure
33 that the ``mtools`` package is installed, which is needed to make the
34 hikey boot image.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020035
36 - In addition, you will need the pre-requisites necessary to build
37 optee-os.
38
39After following the AOSP setup instructions, the following additional packages
Victor Chong04dd2d02020-05-18 07:06:15 +010040from main :ref:`prerequisites` page are needed. Please install them.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020041
42Build instructions
43******************
44
45.. code-block:: bash
46
Victor Chongc03db892019-10-08 07:10:38 +010047 $ git clone https://github.com/linaro-swg/optee_android_manifest [-b <release_tag>]
Victor Chong731a5502020-04-23 10:08:14 +010048 # release tags come in the form of X.Y.Z, e.g. 3.8.0
Joakim Bech8e5c5b32018-10-25 08:18:32 +020049 $ cd optee_android_manifest
50
51
52HiKey620 - LeMaker 8GB
53 .. code-block:: bash
54
55 $ ./sync-p.sh
56 $ ./build-p.sh
57
58HiKey620 - CircuitCo 4GB
59 .. code-block:: bash
60
61 $ ./sync-p.sh
Victor Chong20441fe2019-02-13 08:37:23 +000062 $ ./build-p.sh -4g
Joakim Bech8e5c5b32018-10-25 08:18:32 +020063
64HiKey960
65 .. code-block:: bash
66
67 $ ./sync-p-hikey960.sh
68 $ ./build-p-hikey960.sh
69
Victor Chong731a5502020-04-23 10:08:14 +010070These steps **MUST** finish with **no errors**. For ``sync*.sh`` scripts, that
71means there must be no errors prior to the ``Sync done!`` console output. For
72``build*.sh`` scripts, that means there must be a ``#### build completed
73successfully (MM:SS (mm:ss)) ####`` console output! If there are errors, then
74there is no point in trying to flash the device.
Joakim Bech8e5c5b32018-10-25 08:18:32 +020075
76.. warning::
77
78 - ``--force-sync`` is used which means you might **lose your work** so save
79 often, save frequent, and save accordingly, especially before running
80 ``sync-p.sh`` again!
81
82 - **Attention!** Do **NOT** use ``git clean`` with ``-x`` or ``-X`` or
83 ``-e`` option in ``optee_android_manifest/``, else risk **losing all
84 files** in the directory!!!
85
86.. hint::
87
88 You can add the ``-squashfs`` option to ``build.sh`` option to make
89 ``system.img`` size smaller, but this will make ``/system`` read-only, so
90 you won't be able to push files to it.
91
Victor Chong731a5502020-04-23 10:08:14 +010092Currently, only version P is supported. Other existing files are for internal
93development purposes ONLY and **NOT SUPPORTED**!
Joakim Bech8e5c5b32018-10-25 08:18:32 +020094
95Flashing the image
96******************
97The instructions for flashing the image can be found in detail under
98``device/linaro/hikey/installer/hikey{960}/README`` in the tree.
99
100 1. Set jumpers/switches ``1-2`` and ``3-4``, and unset ``5-6``.
101 2. Reset the board. After that, invoke:
102
103HiKey620
104 .. code-block:: bash
105
106 $ cp -a out/target/product/hikey/*.img device/linaro/hikey/installer/hikey/
107 $ sudo ./device/linaro/hikey/installer/hikey/flash-all.sh /dev/ttyUSBn
108
109HiKey960
110 .. code-block:: bash
111
112 $ cp -a out/target/product/hikey960/*.img device/linaro/hikey/installer/hikey960/
113 $ sudo ./device/linaro/hikey/installer/hikey960/flash-all.sh /dev/ttyUSBn
114
115where the ``/dev/ttyUSBn`` device is the one that appears after rebooting with
Victor Chong20441fe2019-02-13 08:37:23 +0000116the 3-4 jumper set. Note that the device only remains in this recovery mode for
117about 90 seconds. If you take too long to run the flash commands, it will need
118to be reset again. After flashing, unset the 3-4 jumper again to boot normally.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200119
120Partial flashing
121****************
122The last handful of lines in the ``flash-all.sh`` script flash various images.
123After modifying and rebuilding Android, it is only necessary to flash `boot`,
124`system`, `cache`, `vendor` and `userdata`. If you aren't modifying the kernel,
125`boot` is not necessary, either.
126
127Experimental prebuilts
128**********************
129Available at http://snapshots.linaro.org/android under ``android-hikey*``
Victor Chong731a5502020-04-23 10:08:14 +0100130directories. Note that these images do not always work and are **NOT
131SUPPORTED** as well!
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200132
133Running xtest
134*************
135Do NOT try to run ``tee-supplicant`` as it has already been started
136automatically as a service! Once booted to the command prompt, ``xtest`` can be
Victor Chong20441fe2019-02-13 08:37:23 +0000137run immediately from the console or an ``adb`` shell. For more details about
138running OP-TEE, please see :ref:`optee_test_run_xtest` at :ref:`optee_test`.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200139
140Running VTS Gtest unit for Gatekeeper and Keymaster (Optional)
141**************************************************************
142On the device after going into the command prompt, run:
143
144.. code-block:: bash
145
Victor Chong20441fe2019-02-13 08:37:23 +0000146 $ su
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200147 $ ./data/nativetest64/VtsHalGatekeeperV1_0TargetTest/VtsHalGatekeeperV1_0TargetTest
148 $ ./data/nativetest64/VtsHalKeymasterV3_0TargetTest/VtsHalKeymasterV3_0TargetTest
149
150.. note::
151
Victor Chong20441fe2019-02-13 08:37:23 +0000152 These tests need to be run as root.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200153
154Enable adb over USB
155*******************
156
157Boot the device. On serial console:
158
159.. code-block:: bash
160
161 $ su setprop sys.usb.configfs 1
162 $ stop adbd
163 $ start adbd
164
165Known issues
166************
Victor Chong20441fe2019-02-13 08:37:23 +0000167 - If you don't have a monitor or hdmi emulator (dummy plug) connected to
168 the board, you'll see constant errors scrolling on the console. As a
169 workaround, move ``android.hardware.graphics.composer@2.1-service.rc``
170 out of ``/vendor/etc/init``. Move it back in when working with a
171 monitor again.
Joakim Bech8e5c5b32018-10-25 08:18:32 +0200172
Victor Chong20441fe2019-02-13 08:37:23 +0000173 - Adb over USB currently doesn't work on HiKey960. As a workaround, use
174 adb over tcpip. See https://bugs.96boards.org/show_bug.cgi?id=502 for
175 details on how to connect. There are still some limitations however.
176 E.g. running ``adb shell`` or a second ``adb`` instance will break the
177 current adb tcpip connection. This might be due to unstable WiFi
178 (there are periodic error messages like ``wlcore: WARNING corrupted
179 packet in RX: status: 0x1 len: 76``) or just incompleteness of the
180 generic HiKey960 builds under P.
181
182.. _official instructions: https://source.android.com/source/devices.html