Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame^] | 1 | .. 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 | #### |
| 9 | AOSP |
| 10 | #### |
| 11 | This page contains information that tells how to get OP-TEE up and running on |
| 12 | HiKey devices (see :ref:`hikey`, :ref:`hikey960`) together with AOSP. The build |
| 13 | is based on the latest OP-TEE release and updated every quarter together with |
| 14 | the 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 | |
| 22 | As a reference, there are official instructions for HiKey builds at Google |
| 23 | pages, see `AOSP Hikey build instructions`_. |
| 24 | |
| 25 | Prerequisites |
| 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 | |
| 37 | After following the AOSP setup instructions, the following additional packages |
| 38 | are 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 | |
| 57 | Build 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 | |
| 66 | HiKey620 - LeMaker 8GB |
| 67 | .. code-block:: bash |
| 68 | |
| 69 | $ ./sync-p.sh |
| 70 | $ ./build-p.sh |
| 71 | |
| 72 | HiKey620 - CircuitCo 4GB |
| 73 | .. code-block:: bash |
| 74 | |
| 75 | $ ./sync-p.sh |
| 76 | $ ./build.sh -v p -4g |
| 77 | |
| 78 | HiKey960 |
| 79 | .. code-block:: bash |
| 80 | |
| 81 | $ ./sync-p-hikey960.sh |
| 82 | $ ./build-p-hikey960.sh |
| 83 | |
| 84 | These steps should (must) finish with no errors. In case there are errors, then |
| 85 | there 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 | |
| 103 | For older releases (other versions of relatively stable builds), use |
| 104 | below 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 | |
| 112 | E.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 | |
| 119 | Other existing files are for internal development purposes ONLY and |
| 120 | **NOT SUPPORTED**! |
| 121 | |
| 122 | Flashing the image |
| 123 | ****************** |
| 124 | The 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 | |
| 130 | HiKey620 |
| 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 | |
| 136 | HiKey960 |
| 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 | |
| 142 | where the ``/dev/ttyUSBn`` device is the one that appears after rebooting with |
| 143 | the 3-4 jumper installed. Note that the device only remains in this recovery |
| 144 | mode for about 90 seconds. If you take too long to run the flash commands, it |
| 145 | will need to be reset again. |
| 146 | |
| 147 | Partial flashing |
| 148 | **************** |
| 149 | The last handful of lines in the ``flash-all.sh`` script flash various images. |
| 150 | After 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 | |
| 154 | Experimental prebuilts |
| 155 | ********************** |
| 156 | Available at http://snapshots.linaro.org/android under ``android-hikey*`` |
| 157 | directories. |
| 158 | |
| 159 | Running xtest |
| 160 | ************* |
| 161 | Do NOT try to run ``tee-supplicant`` as it has already been started |
| 162 | automatically as a service! Once booted to the command prompt, ``xtest`` can be |
| 163 | run immediately from an ``adb`` shell. For more details about running OP-TEE, |
| 164 | please 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 | |
| 173 | Running VTS Gtest unit for Gatekeeper and Keymaster (Optional) |
| 174 | ************************************************************** |
| 175 | On 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 | |
| 187 | Enable adb over USB |
| 188 | ******************* |
| 189 | |
| 190 | Boot 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 | |
| 198 | Known issues |
| 199 | ************ |
| 200 | Adb over USB currently doesn't work on HiKey960. As a workaround, use adb over |
| 201 | tcpip. See https://bugs.96boards.org/show_bug.cgi?id=502 for details on how to |
| 202 | connect. There are still some limitations however. E.g. running ``adb shell`` or |
| 203 | a second ``adb`` instance will break the current adb tcpip connection. This |
| 204 | might be due to unstable WiFi (there are periodic error messages like ``wlcore: |
| 205 | WARNING corrupted packet in RX: status: 0x1 len: 76``) or just incompleteness of |
| 206 | the generic HiKey960 builds under P. |
| 207 | |
| 208 | .. _AOSP Hikey build instructions: https://source.android.com/source/devices.html |