Hikey R-LCR + OP-TEE manifest

This page describe instructions on how to build a Hikey R-LCR based build that includes OP-TEE feature with AOSP 4.4 kernel.

To enable OP-TEE with AOSP master for Hikey, please check instructions HERE


AOSP Hikey build instructions


Should already be able to build aosp. Distro should have necessary packages installed, and the repo tool should be installed.

Please note that the mtools and python-crypto package are installed.

  • mtools is needed to make the hikey boot image.
  • python-crypto is necessary for optee-os project compiling

Build steps

In an empty directory, clone the tree

$ repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.1_r46

Add the OP-TEE overlay

$ cd .repo
$ git clone https://github.com/liuyq/optee_android_manifest -b hikey-marshmallow local_manifests
$ cd ..


$ repo sync

Download the HiKey vendor binary

$ wget https://dl.google.com/dl/android/aosp/linaro-hikey-20160226-67c37b1a.tgz
$ tar xzf linaro-hikey-20160226-67c37b1a.tgz
$ ./extract-linaro-hikey.sh

Apply patches for optee on hikey device config

$ ./android-patchsets/hikey-optee

Apply patches for optee driver on Hikey AOSP 4.4 kernel

$ ./android-patchsets/hikey-optee-kernel-4.4

Configure the environment for Android

$ source ./build/envsetup.sh
$ lunch hikey-userdebug

With setting TARGET_BUILD_KERNEL to true, we will compiling the Hikey kernel with OP-TEE driver patches during the Android build.

Run the rest of the android build

  • For an 8GB board

$ make -j32
  • For an 4GB board


Flashing the image

The instructions for flashing the image can be found in detail under device/linaro/hikey/install/README in the tree.

  1. Jumper links 1-2 and 3-4, leaving 5-6 open, and reset the board.
  2. Invoke

./device/linaro/hikey/installer/flash-all.sh /dev/ttyUSBn

where the ttyUSBn device is the one that appears after rebooting with the 3-4 jumper installed. Note that the device only remains in this recovery mode for about 90 seconds. If you take too long to run the flash commands, it will need to be reset again.

Partial flashing

The last handful of lines in the flash-all.sh script flash various images. After modifying and rebuilding Android, it is only necessary to flash boot, system, cache, and userdata. If you aren't modifying the kernel, boot is not necessary, either.

This directory contains a prebuilt trusted firmware image fip.bin. If you wish to build the trusted os from source, follow the HiKey instructions in the OP-TEE OS README. After running the build, the fip.bin file will be under


Known issues

There are some known issues at the moment this document is written.

  1. xtest 1008.x failure is under investigation.
  2. master version optee projects are used, will changed to stable version when released

Any bugs and comments are welcome to linaro-android@lists.linaro.org.

LMG/Engineering/IntegrateOptee (last modified 2016-06-24 12:46:08)