Build the android-mainline kernel for Hikey960

Since the ACK (Android Common Kernel) android-mainline branch in AOSP does not officially support the Hikey960 dev board, Linaro does some work to keep this combination working on a best-effort basis. Here are some instructions on how to build the ACK android-mainline kernel for this dev board for people interested in it.

The instruction is based on the Android Building Kernels document.

Repo sync the android-mainline source

$ mkdir android-kernel && cd android-kernel
$ repo init -u \
        -b common-android-mainline
$ repo sync -j$(nproc)

Git clone the external module repository

$ git clone -b android-mainline-linaro \ \

Apply out of tree patches

Since there are some out of tree patches used as temporary workaround, they should be applied before start building the kernel.

$ cd common && \
        ../hikey-modules-linaro/hikey960/android-mainline/patchsets/ && \
        cd -

Build the kernel

$ tools/bazel run \
        --config=release \

Artifacts path

The kernel/dtb/ko files could be found under the directory of out/android-mainline/dist:

$ ls -1 out/android-mainline/dist/Image* out/android-mainline/dist/*.dtb

Build AOSP with the android-mainline kernel files

For the instructions on how to build the userspace images with the AOSP tree, the instructions on Android Open Source Project for Hikey960 boards could be referred to.

Download the AOSP tree:

$ repo init -u -b master
$ repo sync -j$(nproc)

Delete all files under ${AOSP_TOPDIR}/device/linaro/hikey-kernel/hikey960/mainline/ , then copy all the artifact files from the kernel build dist directory to ${AOSP_TOPDIR}/device/linaro/hikey-kernel/hikey960/mainline/

$ cp ${KERNEL_TOPDIR}/out/android-mainline/* \

Build the Android Userspace:

$ ./device/linaro/hikey/
$ . ./build/
$ lunch hikey960-userdebug
$ make TARGET_KERNEL_USE=mainline -j$(nproc)

To test with the android-mainline GKI kernel, please check the latest android-mainline kernel_aarch64 build, In artifacts, download the Image.gz file and copy it to ${AOSP_TOPDIR}/device/linaro/hikey-kernel/hikey960/mainline/, concatenate the DTB:

$ cat ${AOSP_TOPDIR}/device/linaro/hikey-kernel/hikey960/mainline/Image.gz \
        ${AOSP_TOPDIR}/device/linaro/hikey-kernel/hikey960/mainline/hi3660-hikey960.dtb > \

Build again with the new kernel using the instructions above.

Flash and deploy to the board

Please flash with the ./device/linaro/hikey/installer/hikey960/ script to deploy the new images.

One may refer to the Installing local images document for details.

$ ./device/linaro/hikey/installer/hikey960/