Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _aosp: |
| 2 | |
| 3 | #### |
| 4 | AOSP |
| 5 | #### |
| 6 | This page contains information that tells how to get OP-TEE up and running on |
| 7 | HiKey devices (see :ref:`hikey`, :ref:`hikey960`) together with AOSP. The build |
| 8 | is based on the latest OP-TEE release and updated every quarter together with |
| 9 | the regular OP-TEE releases. |
| 10 | |
| 11 | .. note:: |
| 12 | |
| 13 | We **only** use and support this static/stable configuration. If you try |
Victor Chong | 731a550 | 2020-04-23 10:08:14 +0100 | [diff] [blame] | 14 | 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 Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 16 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 17 | Prerequisites |
| 18 | ************* |
| 19 | |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 20 | - 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 Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 30 | |
| 31 | - In addition, you will need the pre-requisites necessary to build |
| 32 | optee-os. |
| 33 | |
| 34 | After following the AOSP setup instructions, the following additional packages |
Victor Chong | 04dd2d0 | 2020-05-18 07:06:15 +0100 | [diff] [blame] | 35 | from main :ref:`prerequisites` page are needed. Please install them. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 36 | |
| 37 | Build instructions |
| 38 | ****************** |
| 39 | |
| 40 | .. code-block:: bash |
| 41 | |
Victor Chong | c03db89 | 2019-10-08 07:10:38 +0100 | [diff] [blame] | 42 | $ git clone https://github.com/linaro-swg/optee_android_manifest [-b <release_tag>] |
Victor Chong | 731a550 | 2020-04-23 10:08:14 +0100 | [diff] [blame] | 43 | # release tags come in the form of X.Y.Z, e.g. 3.8.0 |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 44 | $ cd optee_android_manifest |
| 45 | |
| 46 | |
| 47 | HiKey620 - LeMaker 8GB |
| 48 | .. code-block:: bash |
| 49 | |
| 50 | $ ./sync-p.sh |
| 51 | $ ./build-p.sh |
| 52 | |
| 53 | HiKey620 - CircuitCo 4GB |
| 54 | .. code-block:: bash |
| 55 | |
| 56 | $ ./sync-p.sh |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 57 | $ ./build-p.sh -4g |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 58 | |
| 59 | HiKey960 |
| 60 | .. code-block:: bash |
| 61 | |
| 62 | $ ./sync-p-hikey960.sh |
| 63 | $ ./build-p-hikey960.sh |
| 64 | |
Victor Chong | 731a550 | 2020-04-23 10:08:14 +0100 | [diff] [blame] | 65 | These steps **MUST** finish with **no errors**. For ``sync*.sh`` scripts, that |
| 66 | means 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 |
| 68 | successfully (MM:SS (mm:ss)) ####`` console output! If there are errors, then |
| 69 | there is no point in trying to flash the device. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 70 | |
| 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 Chong | 731a550 | 2020-04-23 10:08:14 +0100 | [diff] [blame] | 87 | Currently, only version P is supported. Other existing files are for internal |
| 88 | development purposes ONLY and **NOT SUPPORTED**! |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 89 | |
| 90 | Flashing the image |
| 91 | ****************** |
| 92 | The 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 | |
| 98 | HiKey620 |
| 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 | |
| 104 | HiKey960 |
| 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 | |
| 110 | where the ``/dev/ttyUSBn`` device is the one that appears after rebooting with |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 111 | the 3-4 jumper set. Note that the device only remains in this recovery mode for |
| 112 | about 90 seconds. If you take too long to run the flash commands, it will need |
| 113 | to be reset again. After flashing, unset the 3-4 jumper again to boot normally. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 114 | |
| 115 | Partial flashing |
| 116 | **************** |
| 117 | The last handful of lines in the ``flash-all.sh`` script flash various images. |
| 118 | After 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 | |
| 122 | Experimental prebuilts |
| 123 | ********************** |
| 124 | Available at http://snapshots.linaro.org/android under ``android-hikey*`` |
Victor Chong | 731a550 | 2020-04-23 10:08:14 +0100 | [diff] [blame] | 125 | directories. Note that these images do not always work and are **NOT |
| 126 | SUPPORTED** as well! |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 127 | |
| 128 | Running xtest |
| 129 | ************* |
| 130 | Do NOT try to run ``tee-supplicant`` as it has already been started |
| 131 | automatically as a service! Once booted to the command prompt, ``xtest`` can be |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 132 | run immediately from the console or an ``adb`` shell. For more details about |
| 133 | running OP-TEE, please see :ref:`optee_test_run_xtest` at :ref:`optee_test`. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 134 | |
| 135 | Running VTS Gtest unit for Gatekeeper and Keymaster (Optional) |
| 136 | ************************************************************** |
| 137 | On the device after going into the command prompt, run: |
| 138 | |
| 139 | .. code-block:: bash |
| 140 | |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 141 | $ su |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 142 | $ ./data/nativetest64/VtsHalGatekeeperV1_0TargetTest/VtsHalGatekeeperV1_0TargetTest |
| 143 | $ ./data/nativetest64/VtsHalKeymasterV3_0TargetTest/VtsHalKeymasterV3_0TargetTest |
| 144 | |
| 145 | .. note:: |
| 146 | |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 147 | These tests need to be run as root. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 148 | |
| 149 | Enable adb over USB |
| 150 | ******************* |
| 151 | |
| 152 | Boot 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 | |
| 160 | Known issues |
| 161 | ************ |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 162 | - 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 Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 167 | |
Victor Chong | 20441fe | 2019-02-13 08:37:23 +0000 | [diff] [blame] | 168 | - 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 |