Merge "hikey: Optimize for cortex-a53"
diff --git a/AndroidProducts.mk b/AndroidProducts.mk
index 0df5afe..4ae9e53 100644
--- a/AndroidProducts.mk
+++ b/AndroidProducts.mk
@@ -10,4 +10,5 @@
#
PRODUCT_MAKEFILES := \
-$(LOCAL_DIR)/hikey.mk
+$(LOCAL_DIR)/hikey.mk \
+$(LOCAL_DIR)/hikey960.mk
diff --git a/audio/Android.mk b/audio/Android.mk
index e909f2f..fe091a8 100644
--- a/audio/Android.mk
+++ b/audio/Android.mk
@@ -22,7 +22,7 @@
# required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc.
include $(CLEAR_VARS)
-LOCAL_MODULE := audio.primary.hikey
+LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := audio_hw.c
LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa
diff --git a/bt-wifi-firmware-util/Android.mk b/bt-wifi-firmware-util/Android.mk
index 525d903..cdfefe4 100644
--- a/bt-wifi-firmware-util/Android.mk
+++ b/bt-wifi-firmware-util/Android.mk
@@ -18,7 +18,11 @@
include $(CLEAR_VARS)
LOCAL_MODULE := TIInit_11.8.32.bts
-LOCAL_SRC_FILES := $(FW_WLAN_FULL_PATH)/TIInit_11.8.32.bts
+ifeq ($(TARGET_PRODUCT),hikey960)
+LOCAL_SRC_FILES := TIInit_11.8.32-pcm-960.bts
+else
+LOCAL_SRC_FILES := TIInit_11.8.32.bts
+endif
LOCAL_MODULE_CLASS := FIRMWARE
LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
LOCAL_MODULE_TAGS := optional
@@ -27,7 +31,7 @@
include $(CLEAR_VARS)
LOCAL_MODULE := wl18xx-fw-4.bin
-LOCAL_SRC_FILES := $(FW_WLAN_FULL_PATH)/wl18xx-fw-4.bin
+LOCAL_SRC_FILES := wl18xx-fw-4.bin
LOCAL_MODULE_CLASS := FIRMWARE
LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
LOCAL_MODULE_TAGS := optional
@@ -36,7 +40,11 @@
include $(CLEAR_VARS)
LOCAL_MODULE := wl18xx-conf.bin
-LOCAL_SRC_FILES := $(FW_WLAN_FULL_PATH)/wl18xx-conf.bin
+ifeq ($(TARGET_PRODUCT),hikey960)
+LOCAL_SRC_FILES := wl18xx-conf-wl1837mod.bin
+else
+LOCAL_SRC_FILES := wl18xx-conf.bin
+endif
LOCAL_MODULE_CLASS := FIRMWARE
LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
LOCAL_MODULE_TAGS := optional
diff --git a/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts b/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts
new file mode 100644
index 0000000..ff56d1c
--- /dev/null
+++ b/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts
Binary files differ
diff --git a/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin b/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin
new file mode 100644
index 0000000..5dd913c
--- /dev/null
+++ b/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin
Binary files differ
diff --git a/bt-wifi-firmware-util/wl18xx-fw-4.bin b/bt-wifi-firmware-util/wl18xx-fw-4.bin
index 5e65dbc..71c160a 100755
--- a/bt-wifi-firmware-util/wl18xx-fw-4.bin
+++ b/bt-wifi-firmware-util/wl18xx-fw-4.bin
Binary files differ
diff --git a/build/tasks/dtimage.mk b/build/tasks/dtimage.mk
new file mode 100644
index 0000000..9dc6668
--- /dev/null
+++ b/build/tasks/dtimage.mk
@@ -0,0 +1,12 @@
+ifneq ($(filter hikey%, $(TARGET_DEVICE)),)
+ifneq ($(TARGET_NO_DTIMAGE), true)
+
+MKDTIMG := device/linaro/hikey/installer/hikey960/mkdtimg
+DTB := $(PRODUCT_OUT)/hi3660-hikey960.dtb
+
+$(PRODUCT_OUT)/dt.img: $(DTB)
+ $(MKDTIMG) -c -d $(DTB) -o $@
+
+droidcore: $(PRODUCT_OUT)/dt.img
+endif
+endif
diff --git a/factory-images/generate-factory-images-hikey960.sh b/factory-images/generate-factory-images-hikey960.sh
new file mode 100755
index 0000000..9d2b02b
--- /dev/null
+++ b/factory-images/generate-factory-images-hikey960.sh
@@ -0,0 +1,98 @@
+# Copyright 2011, 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+DEVICE_DIR=device/linaro/hikey/
+DEVICE=hikey960
+PRODUCT=hikey960
+
+BUILD=eng.`whoami`
+BUILDNAME=`ls ${ANDROID_BUILD_TOP}/${PRODUCT}-img-${BUILD}.zip 2> /dev/null`
+if [ $? -ne 0 ]; then
+ VERSION=linaro-`date +"%Y.%m.%d"`
+else
+ BUILDNAME=`ls ${ANDROID_BUILD_TOP}/${PRODUCT}-img-*.zip 2> /dev/null`
+ BUILD=`basename ${BUILDNAME} | cut -f3 -d'-' | cut -f1 -d'.'`
+ VERSION=$BUILD
+fi
+
+# Prepare the staging directory
+rm -rf tmp
+mkdir -p tmp/$PRODUCT-$VERSION
+
+# copy over bootloader binaries
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/bl31.bin tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/fastboot.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/lpm3.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/nvme.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/ptable.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/README tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/$DEVICE_DIR/installer/hikey960/sec_xloader.img tmp/$PRODUCT-$VERSION/
+
+# copy over dts.img
+cp $ANDROID_BUILD_TOP/out/target/product/hikey960/dt.img tmp/$PRODUCT-$VERSION/
+
+# copy over the update image
+cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip
+
+# XXX hikey960's fastboot update currently doesn't format cache/userdata, so do it manually
+# XXX Remove this when the bug is fixed.
+cp $ANDROID_BUILD_TOP/out/target/product/hikey960/cache.img tmp/$PRODUCT-$VERSION/
+cp $ANDROID_BUILD_TOP/out/target/product/hikey960/userdata.img tmp/$PRODUCT-$VERSION/
+
+
+# Write flash-all.sh
+cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
+#!/bin/bash
+
+# Copyright 2012, 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+
+fastboot flash ptable ptable.img
+fastboot flash xloader sec_xloader.img
+fastboot flash fastboot fastboot.img
+fastboot flash nvme nvme.img
+fastboot flash fw_lpm3 lpm3.img
+fastboot flash trustfirmware bl31.bin
+fastboot flash dts dt.img
+
+# XXX fastboot update doesn't format cache and userdata
+# XXX so flash those manually. Remove this later.
+fastboot flash cache cache.img
+fastboot flash userdata userdata.img
+
+fastboot update image-$PRODUCT-$VERSION.zip
+EOF
+
+chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh
+
+# Create the distributable package
+(cd tmp ; zip -r ../$PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION)
+mv $PRODUCT-$VERSION-factory.zip $PRODUCT-$VERSION-factory-$(sha256sum < $PRODUCT-$VERSION-factory.zip | cut -b -8).zip
+
+# Clean up
+rm -rf tmp
diff --git a/factory-images/generate-factory-images-package.sh b/factory-images/generate-factory-images-package.sh
index 67715ee..7a51f7f 100755
--- a/factory-images/generate-factory-images-package.sh
+++ b/factory-images/generate-factory-images-package.sh
@@ -16,4 +16,4 @@
source $ANDROID_BUILD_TOP/device/common/clear-factory-images-variables.sh
# HiKey unfortunately can't use the ./generate-factory-images-common.sh script
-source $ANDROID_BUILD_TOP/device/linaro/hikey/factory-images/generate-factory-images-hikey.sh
+source $ANDROID_BUILD_TOP/device/linaro/hikey/factory-images/generate-factory-images-$TARGET_PRODUCT.sh
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index 82c6f8f..d843436 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
+ifeq ($(TARGET_PRODUCT),hikey)
LOCAL_PATH := $(call my-dir)
# HAL module implemenation, not prelinked and stored in
@@ -34,3 +34,4 @@
LOCAL_MODULE_RELATIVE_PATH := hw
include $(BUILD_SHARED_LIBRARY)
+endif
diff --git a/gralloc/framebuffer_device.cpp b/gralloc/framebuffer_device.cpp
index cfc480f..3004778 100644
--- a/gralloc/framebuffer_device.cpp
+++ b/gralloc/framebuffer_device.cpp
@@ -469,6 +469,12 @@
/* initialize our state here */
framebuffer_device_t *dev = (framebuffer_device_t *)malloc(sizeof(framebuffer_device_t));
+ if (dev == NULL)
+ {
+ AERR("Error to malloc the framebuffer (%s)", strerror(errno));
+ gralloc_close(gralloc_device);
+ return -ENOMEM;
+ }
memset(dev, 0, sizeof(*dev));
/* initialize the procs */
diff --git a/hikey.mk b/hikey.mk
index 40e1f8b..3174ba4 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -3,7 +3,7 @@
endif
TARGET_PREBUILT_KERNEL := device/linaro/hikey-kernel/Image-dtb-$(TARGET_KERNEL_USE)
TARGET_PREBUILT_DTB := device/linaro/hikey-kernel/hi6220-hikey.dtb-$(TARGET_KERNEL_USE)
-ifeq ($(TARGET_KERNEL_USE), 4.1)
+ifeq ($(TARGET_KERNEL_USE), 3.18)
TARGET_FSTAB := fstab.hikey-$(TARGET_KERNEL_USE)
else
TARGET_FSTAB := fstab.hikey
diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index f452990..df97048 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -1,16 +1,18 @@
include device/linaro/hikey/BoardConfigCommon.mk
TARGET_BOARD_PLATFORM := hikey
-ifeq ($(TARGET_KERNEL_USE), 4.1)
+ifeq ($(TARGET_KERNEL_USE), 3.18)
BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
else
BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
endif
## printk.devkmsg only has meaning for kernel 4.9 and later
-## it would be ignored by kernel 4.1 and kernel 4.4
+## it would be ignored by kernel 3.18 and kernel 4.4
BOARD_KERNEL_CMDLINE += printk.devkmsg=on
+TARGET_NO_DTIMAGE := true
+
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
ifeq ($(TARGET_USERDATAIMAGE_4GB), true)
BOARD_USERDATAIMAGE_PARTITION_SIZE := 1595915776
diff --git a/hikey/fstab.hikey-4.1 b/hikey/fstab.hikey-3.18
similarity index 100%
rename from hikey/fstab.hikey-4.1
rename to hikey/fstab.hikey-3.18
diff --git a/hikey960.mk b/hikey960.mk
new file mode 100644
index 0000000..90d8784
--- /dev/null
+++ b/hikey960.mk
@@ -0,0 +1,12 @@
+#
+# Inherit the full_base and device configurations
+$(call inherit-product, device/linaro/hikey/hikey960/device-hikey960.mk)
+$(call inherit-product, device/linaro/hikey/device-common.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+
+#
+# Overrides
+PRODUCT_NAME := hikey960
+PRODUCT_DEVICE := hikey960
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on hikey960
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
new file mode 100644
index 0000000..94631c2
--- /dev/null
+++ b/hikey960/BoardConfig.mk
@@ -0,0 +1,14 @@
+include device/linaro/hikey/BoardConfigCommon.mk
+
+TARGET_BOARD_PLATFORM := hikey960
+
+TARGET_NO_DTIMAGE := false
+
+BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960 androidboot.selinux=permissive
+BOARD_KERNEL_CMDLINE += firmware_class.path=/system/etc/firmware loglevel=15
+BOARD_MKBOOTIMG_ARGS := --base 0x0 --tags_offset 0x07a00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000
+
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2768240640 # 2640MB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 25769803776 # 24GB
+BOARD_CACHEIMAGE_PARTITION_SIZE := 8388608 # 8MB
+BOARD_FLASH_BLOCK_SIZE := 512
diff --git a/hikey960/board-info.txt b/hikey960/board-info.txt
new file mode 100644
index 0000000..3bd6c04
--- /dev/null
+++ b/hikey960/board-info.txt
@@ -0,0 +1 @@
+require board=hikey960
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
new file mode 100644
index 0000000..95d8750
--- /dev/null
+++ b/hikey960/device-hikey960.mk
@@ -0,0 +1,32 @@
+#
+# Copyright (C) 2011 The Android Open-Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+PRODUCT_COPY_FILES += device/linaro/hikey-kernel/Image.gz-hikey960:kernel \
+ device/linaro/hikey-kernel/hi3660-hikey960.dtb:hi3660-hikey960.dtb
+
+PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.hikey960:root/fstab.hikey960 \
+ device/linaro/hikey/init.common.rc:root/init.hikey960.rc \
+ device/linaro/hikey/init.common.usb.rc:root/init.hikey960.usb.rc \
+ device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey960.rc \
+ device/linaro/hikey/common.kl:system/usr/keylayout/hikey960.kl
+
+# Build HiKey960 HDMI audio HAL. Experimental only may not work. FIXME
+PRODUCT_PACKAGES += audio.primary.hikey960
+
+PRODUCT_PACKAGES += power.hikey960
+
+# Include vendor binaries
+$(call inherit-product-if-exists, vendor/linaro/hikey960/device-vendor.mk)
diff --git a/hikey960/fstab.hikey960 b/hikey960/fstab.hikey960
new file mode 100644
index 0000000..bb78c3e
--- /dev/null
+++ b/hikey960/fstab.hikey960
@@ -0,0 +1,13 @@
+# Android fstab file.
+#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
+# The filesystem that contains the filesystem checker binary (typically /system) cannot
+# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
+
+#/dev/block/platform/soc/ff3b0000.ufs/by-name/system_a /system ext4 ro wait
+/dev/block/sdd10 /system ext4 ro wait
+#/dev/block/platform/soc/ff3b0000.ufs/by-name/cache /cache ext4 discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1 wait
+/dev/block/sdd5 /cache ext4 discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1 wait
+#/dev/block/platform/soc/ff3b0000.ufs/by-name/userdata /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1 wait
+/dev/block/sdd13 /data ext4 discard,noauto_da_alloc,data=ordered,user_xattr,discard,barrier=1 wait
+/devices/platform/soc/ff37f000.dwmmc1/mmc_host/mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
+/devices/platform/soc/ff200000.hisi_usb/ff100000.dwc3/xhci-hcd.1.auto/usb* auto auto defaults voldmanaged=usbdisk:auto,encryptable=userdata
diff --git a/init.common.rc b/init.common.rc
index 11bc675..8d7a35d 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -15,12 +15,6 @@
mount_all /fstab.${ro.hardware}
setprop ro.crypto.fuse_sdcard false
-on post-fs-data
- mkdir /data/media 0770 media_rw media_rw
- mkdir /data/misc/gatord 0700 root root
- # Set SELinux security contexts for files used by lava.
- restorecon_recursive /data/local/tmp/lava
-
on post-fs
# For legacy support
@@ -47,22 +41,6 @@
# Set supported opengles version
setprop ro.opengles.version 196608
- # update cpuset now that processors are up
- # Foreground should contain most cores (7 is reserved for top-app)
- write /dev/cpuset/foreground/cpus 0-6
-
- # top-app gets all cpus (including reserved #7)
- write /dev/cpuset/top-app/cpus 0-7
-
- #background contains a small subset (generally one little core)
- write /dev/cpuset/background/cpus 0
-
- # add system-background cpuset, a new cpuset for system services
- # that should not run on larger cores
- # system-background is for system tasks that should only run on
- # little cores, not on bigs to be used only by init
- write /dev/cpuset/system-background/cpus 0-3
-
#
# EAS stune boosting interfaces
#
@@ -86,6 +64,29 @@
# enable test harness
setprop ro.test_harness true
+on post-fs-data
+ mkdir /data/media 0770 media_rw media_rw
+ mkdir /data/misc/gatord 0700 root root
+ # Set SELinux security contexts for files used by lava.
+ restorecon_recursive /data/local/tmp/lava
+
+on property:sys.boot_completed=1
+ # update cpuset now that processors are up
+ # Foreground should contain most cores (7 is reserved for top-app)
+ write /dev/cpuset/foreground/cpus 0-6
+
+ # top-app gets all cpus (including reserved #7)
+ write /dev/cpuset/top-app/cpus 0-7
+
+ #background contains a small subset (generally one little core)
+ write /dev/cpuset/background/cpus 0
+
+ # add system-background cpuset, a new cpuset for system services
+ # that should not run on larger cores
+ # system-background is for system tasks that should only run on
+ # little cores, not on bigs to be used only by init
+ write /dev/cpuset/system-background/cpus 0-3
+
on property:usb_speed.switch=high
write /sys/kernel/debug/f72c0000.usb/config "0"
diff --git a/installer/hikey960/README b/installer/hikey960/README
new file mode 100644
index 0000000..6ef3074
--- /dev/null
+++ b/installer/hikey960/README
@@ -0,0 +1,41 @@
+These instructions will help you in flashing the prebuilt bootloader
+images and AOSP images (built from sources) on hikey960.
+
+There are two versions of HiKey960: v1 and v2.
+* v1 is using Jumper (J2001)
+* v2 is using DIP switch (SW2201).
+Both are located at the bottom side of the board.
+
+Jumper Pin 1-2 = DIP switch 1 (AutoBoot)
+Jumper Pin 3-4 = DIP switch 2 (Recovery Mode)
+JUmper Pin 5-6 = DIP switch 3 (Fastboot Mode)
+
+* Always power off the board before changing the switches or
+ jumpers.
+* To boot into fastboot mode set switch 1 & 3 to ON state and
+ switch 2 to OFF state.
+* To boot into normal mode set switch 1 to ON and switch 2 & 3 to
+ OFF state.
+
+To flash the OS to the board, set the jumpers to fastboot mode, and
+power on the device. Connect a USB-C cable to the OTG port and your
+host device.
+
+On your host device, run the flash-all.sh script to update boot files
+using fastboot. It assumes that you have already build hikey960 AOSP
+images locally, or are flashing a factory image.
+$ ./flash-all.sh
+
+After that completes, power the board off, and set the switches back
+to normal mode and boot the device.
+
+Trouble shooting:
+-----------------
+If you have any trouble booting the device after running ./flash-all.sh
+you may need to do a board recovery. This is hopefully uncommon, but
+may be necessary in some cases (like if your board has pre-release
+firmware on it). In this case clone the git project here:
+ https://github.com/96boards-hikey/tools-images-hikey960/
+
+And follow the instructions in the README.md
+ https://github.com/96boards-hikey/tools-images-hikey960/blob/master/README.md
diff --git a/installer/hikey960/bl31.bin b/installer/hikey960/bl31.bin
new file mode 100644
index 0000000..abebea6
--- /dev/null
+++ b/installer/hikey960/bl31.bin
Binary files differ
diff --git a/installer/hikey960/fastboot.img b/installer/hikey960/fastboot.img
new file mode 100644
index 0000000..18e53fd
--- /dev/null
+++ b/installer/hikey960/fastboot.img
Binary files differ
diff --git a/installer/hikey960/flash-all.sh b/installer/hikey960/flash-all.sh
new file mode 100755
index 0000000..7b7db51
--- /dev/null
+++ b/installer/hikey960/flash-all.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+INSTALLER_DIR="`dirname ${0}`"
+
+# for cases that don't run "lunch hikey960-userdebug"
+if [ -z "${ANDROID_BUILD_TOP}" ]; then
+ ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../
+ ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey960"
+fi
+
+if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then
+ echo "error in locating out directory, check if it exist"
+ exit
+fi
+
+echo "android out dir:${ANDROID_PRODUCT_OUT}"
+
+fastboot flash ptable "${INSTALLER_DIR}"/ptable.img
+fastboot flash xloader "${INSTALLER_DIR}"/sec_xloader.img
+fastboot flash fastboot "${INSTALLER_DIR}"/fastboot.img
+fastboot flash nvme "${INSTALLER_DIR}"/nvme.img
+fastboot flash fw_lpm3 "${INSTALLER_DIR}"/lpm3.img
+fastboot flash trustfirmware "${INSTALLER_DIR}"/bl31.bin
+fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
+fastboot flash dts "${ANDROID_PRODUCT_OUT}"/dt.img
+fastboot flash system "${ANDROID_PRODUCT_OUT}"/system.img
+fastboot flash cache "${ANDROID_PRODUCT_OUT}"/cache.img
+fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
diff --git a/installer/hikey960/lpm3.img b/installer/hikey960/lpm3.img
new file mode 100644
index 0000000..92f590d
--- /dev/null
+++ b/installer/hikey960/lpm3.img
Binary files differ
diff --git a/installer/hikey960/mkdtimg b/installer/hikey960/mkdtimg
new file mode 100755
index 0000000..6572204
--- /dev/null
+++ b/installer/hikey960/mkdtimg
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+# Copyright 2017, The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from __future__ import print_function
+try:
+ from os import fstat, stat, remove
+ from sys import exit
+ from argparse import ArgumentParser, FileType
+ from ctypes import sizeof, Structure, c_char, c_int
+ from struct import pack, calcsize
+ import zlib
+except Exception as e:
+ print("some module is needed:" + str(e))
+ exit(-1)
+
+dt_head_info_fmt = '4sII'
+dt_entry_fmt = 'Q4I2Q'
+dtimg_version = 1
+dtb_count = 1
+
+def write32(output, value):
+ output.write(chr(value & 255)) ; value=value // 256
+ output.write(chr(value & 255)) ; value=value // 256
+ output.write(chr(value & 255)) ; value=value // 256
+ output.write(chr(value & 255))
+
+def compress(filename, input, output):
+ output.write('\037\213\010')
+ output.write(chr(0))
+
+ statval = stat(filename)
+ write32(output, 0)
+ output.write('\002')
+ output.write('\003')
+
+ crcval = zlib.crc32("")
+ compobj = zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS,
+ zlib.DEF_MEM_LEVEL, 0)
+ while True:
+ data = input.read(1024)
+ if data == "":
+ break
+ crcval = zlib.crc32(data, crcval)
+ output.write(compobj.compress(data))
+ output.write(compobj.flush())
+ write32(output, crcval)
+ write32(output, statval.st_size)
+
+def dtb_compress(dtb_file):
+ try:
+ outputname = dtb_file + '.gz'
+ input = open(dtb_file, 'rb')
+ output = open(outputname, 'wb')
+ compress(dtb_file, input, output)
+ input.close()
+ output.close()
+ except Exception as e:
+ print('dtb_compress error:' + str(e))
+ exit(-1)
+ return outputname
+
+class dt_head_info(Structure):
+ _fields_ = [('magic', c_char * 4),
+ ('version', c_int),
+ ('dt_count', c_int)]
+
+class dt_entry_t(Structure):
+ _fields_ = [('dtb_size', c_int),
+ ('dtb_offset', c_int)]
+
+def align_page_size(offset, pagesize):
+ return (pagesize - (offset % pagesize))
+
+def write_head_info(head_info, args):
+ args.output.write(pack(dt_head_info_fmt,
+ head_info.magic,
+ head_info.version,
+ head_info.dt_count))
+
+def write_dtb_entry_t(dt_entry, args):
+ args.output.write(pack(dt_entry_fmt,
+ 0, # reserved
+ dt_entry.dtb_size,
+ 0, # reserved
+ dt_entry.dtb_offset,
+ 0, # reserved
+ 0, # reserved
+ 0)) # reserved
+
+def write_padding(args, padding):
+ for i in range(0, padding):
+ args.output.write('\x00')
+
+def write_dtb(args):
+ dtb_file = args.dtb
+ out_dtb = dtb_file
+ if args.compress == True:
+ out_dtb = dtb_compress(dtb_file)
+ try:
+ dtb_offset = calcsize(dt_head_info_fmt) + \
+ calcsize(dt_entry_fmt) + \
+ 4
+ padding = align_page_size(dtb_offset, args.pagesize)
+ dtb_size = stat(out_dtb).st_size
+ dtb_size_padding = align_page_size(dtb_size, args.pagesize)
+ dt_entry = dt_entry_t(dtb_size + dtb_size_padding,
+ dtb_offset + padding)
+ write_dtb_entry_t(dt_entry, args)
+ args.output.write(pack('I', 0)) # SUCCESS code number
+ write_padding(args, padding)
+ with open(out_dtb, 'rb') as dtb_fd:
+ args.output.write(dtb_fd.read(dtb_size))
+ write_padding(args, dtb_size_padding)
+ except Exception as e:
+ print('write dtb error:' + str(e))
+ exit(-1)
+
+def clean_gz_file(args):
+ try:
+ if args.compress != True:
+ return
+ remove(args.dtb + '.gz')
+ except Exception as e:
+ print('clean gz file error:' + str(e))
+ exit(-1)
+
+def parse_cmdline():
+ parser = ArgumentParser()
+ parser.add_argument('-c', '--compress', help='compress dtb or not',
+ action='store_true')
+ parser.add_argument('-d', '--dtb', help='path to the dtb', type=str,
+ required=True)
+ parser.add_argument('-s', '--pagesize', help='align page size',
+ type=int, choices=[2**i for i in range(11,15)],
+ default=2048)
+ parser.add_argument('-o', '--output', help='output file name',
+ type=FileType('wb'), required=True)
+ return parser.parse_args()
+
+def main():
+ args = parse_cmdline()
+ dtimg_head_info = dt_head_info('HSDT', dtimg_version, dtb_count)
+ write_head_info(dtimg_head_info, args)
+ write_dtb(args)
+ clean_gz_file(args)
+
+if __name__ == '__main__':
+ main()
diff --git a/installer/hikey960/nvme.img b/installer/hikey960/nvme.img
new file mode 100644
index 0000000..ca5bc7c
--- /dev/null
+++ b/installer/hikey960/nvme.img
Binary files differ
diff --git a/installer/hikey960/ptable.img b/installer/hikey960/ptable.img
new file mode 100644
index 0000000..7c9e36e
--- /dev/null
+++ b/installer/hikey960/ptable.img
Binary files differ
diff --git a/installer/hikey960/sec_xloader.img b/installer/hikey960/sec_xloader.img
new file mode 100644
index 0000000..b44b6a1
--- /dev/null
+++ b/installer/hikey960/sec_xloader.img
Binary files differ
diff --git a/self-extractors_hikey960/Android.mk b/self-extractors_hikey960/Android.mk
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/self-extractors_hikey960/Android.mk
diff --git a/self-extractors_hikey960/PART1 b/self-extractors_hikey960/PART1
new file mode 100644
index 0000000..935267e
--- /dev/null
+++ b/self-extractors_hikey960/PART1
@@ -0,0 +1,12 @@
+#
+# Usage is subject to the enclosed license agreement
+
+echo
+echo The license for this software will now be displayed.
+echo You must agree to this license before using this software.
+echo
+echo -n Press Enter to view the license
+read dummy
+echo
+
+more << __EOF__
diff --git a/self-extractors_hikey960/PART2 b/self-extractors_hikey960/PART2
new file mode 100644
index 0000000..30e8d43
--- /dev/null
+++ b/self-extractors_hikey960/PART2
@@ -0,0 +1,22 @@
+__EOF__
+
+if test $? != 0
+then
+ echo ERROR: Couldn\'t display license file 1>&2
+ exit 1
+fi
+
+echo
+
+echo -n Type \"I ACCEPT\" if you agree to the terms of the license:\
+read typed
+
+if test "$typed" != I\ ACCEPT
+then
+ echo
+ echo You didn\'t accept the license. Extraction aborted.
+ exit 2
+fi
+
+echo
+
diff --git a/self-extractors_hikey960/PART3 b/self-extractors_hikey960/PART3
new file mode 100644
index 0000000..6847be5
--- /dev/null
+++ b/self-extractors_hikey960/PART3
@@ -0,0 +1,12 @@
+
+if test $? != 0
+then
+ echo
+ echo ERROR: Couldn\'t extract files. 1>&2
+ exit 3
+else
+ echo
+ echo Files extracted successfully.
+fi
+exit 0
+
diff --git a/self-extractors_hikey960/PROLOGUE b/self-extractors_hikey960/PROLOGUE
new file mode 100644
index 0000000..c856ef1
--- /dev/null
+++ b/self-extractors_hikey960/PROLOGUE
@@ -0,0 +1,2 @@
+#!/bin/bash
+#
diff --git a/self-extractors_hikey960/arm/COPYRIGHT b/self-extractors_hikey960/arm/COPYRIGHT
new file mode 100644
index 0000000..4e017c2
--- /dev/null
+++ b/self-extractors_hikey960/arm/COPYRIGHT
@@ -0,0 +1 @@
+# (C) HiSilicon Co. Ltd.
diff --git a/self-extractors_hikey960/arm/LICENSE b/self-extractors_hikey960/arm/LICENSE
new file mode 100644
index 0000000..4a8cdd5
--- /dev/null
+++ b/self-extractors_hikey960/arm/LICENSE
@@ -0,0 +1,177 @@
+THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
+BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
+ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
+LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
+CLICKING "I AGREE" OR BY INSTALLING OR OTHERWISE USING OR COPYING THE
+SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS
+OF THIS LICENCE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM
+IS UNWILLING TO LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL,
+USE OR COPY THE SOFTWARE, AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE
+TO YOUR SUPPLIER.
+
+"Software" means any software, firmware and data accompanying this
+Licence, any printed, electronic or online documentation supplied with
+it under the terms of this Licence for the MALI GPU Driver.
+
+ 1. LICENCE GRANTS TO YOU.
+
+ 1.1 ARM hereby grants to you, subject to the terms and conditions of
+ this Licence, a non-exclusive, non-transferable, revocable, worldwide
+ licence to: (i) use the Software or certain components or optional
+ functionality in the Software, as applicable, solely for the purposes
+ of designing or developing applications for use in conjunction with
+ MALI GPU based products manufactured under licence from ARM; and (ii)
+ modify the Software or certain components or optional functionality in
+ the Software for the purposes of porting the Software to your target;
+
+ 2. RESTRICTIONS ON USE OF THE SOFTWARE.
+
+ COPYING: You shall not use or copy the Software except as expressly
+ authorised in this Licence. You may make one additional copy of the
+ delivered Software for backup or archival purposes.
+
+ BENCHMARKING: This Licence does not prevent you from using the
+ Software for internal benchmarking purposes. However, you shall treat
+ any and all benchmarking data relating to the Software, and any other
+ results of your use or testing of the Software which are indicative of
+ its performance, efficacy, reliability or quality, as confidential
+ information and you shall not disclose such information to any third
+ party without the express written permission of ARM.
+
+ COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
+ its licensors and is protected by copyright and other intellectual
+ property laws and international treaties. The Software is licensed not
+ sold. You acquire no rights to the Software other than as expressly
+ provided by this Licence. You shall not remove from the Software any
+ copyright notice or other notice and shall ensure that any such notice
+ is reproduced in any copies of the whole or any part of the Software
+ made by you or other permitted users.
+
+ REVERSE ENGINEERING: Except to the extent that such activity is
+ permitted by applicable law you shall not reverse engineer, decompile
+ or disassemble any of the Software. If the Software was provided to
+ you in Europe you shall not reverse engineer, decompile or disassemble
+ any of the Software for the purposes of error correction.
+
+ 3. SUPPORT.
+
+ ARM is not under an obligation to provide support, but it may do so at
+ its own discretion, and if it does, it will only be in respect of the
+ Software as delivered and not any modifications thereto.
+
+ 4. NO WARRANTIES.
+
+ YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
+ EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
+ OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
+ LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
+ QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
+ OF SOFTWARE APPLICATIONS, INCLUDING WITHOUT LIMITATION, SOFTWARE
+ APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS,
+ SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL
+ SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE
+ ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 5. LIMITATION OF LIABILITY.
+
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
+ ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
+ INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
+ TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
+ OF SUCH DAMAGES.
+
+ ARM does not seek to limit or exclude liability for death or personal
+ injury arising from ARM's negligence or ARM's fraud and because some
+ jurisdictions do not permit the exclusion or limitation of liability
+ for consequential or incidental damages the above limitation relating
+ to liability for consequential damages may not apply to you.
+
+ NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
+ THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
+ AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
+ THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
+ (I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
+ AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
+ ENLARGE OR EXTEND THE LIMIT.
+
+ 6. CONFIDENTIALITY.
+
+ You acknowledge that the Software and any benchmarking data and
+ related information mentioned in Clause 2 may contain trade secrets
+ and confidential material and you agree to maintain all such
+ information in confidence and apply security measures no less
+ stringent than the measures which you apply to protect your own like
+ information, but not less than a reasonable degree of care, to prevent
+ their unauthorised disclosure and use. Subject to any restrictions
+ imposed by applicable law, the period of confidentiality shall be
+ indefinite. You agree not to use any such information other than in
+ normal use of the Software under the licences granted in this Licence.
+
+ 7. U.S. GOVERNMENT END USERS.
+
+ US Government Restrictions: Use, duplication, reproduction, release,
+ modification, disclosure or transfer of the Software is restricted in
+ accordance with the terms of this Licence.
+
+ 8. TERM AND TERMINATION.
+
+ This Licence shall remain in force until terminated by you or by
+ ARM. Without prejudice to any of its other rights if you are in breach
+ of any of the terms and conditions of this Licence then ARM may
+ terminate this Licence immediately upon giving written notice to you
+ or on thirty (30) days written notice without cause. You may terminate
+ this Licence at any time. Upon termination of this Licence by you or
+ by ARM , you shall stop using the Software and confidential
+ information and destroy all copies of the Software and confidential
+ information in your possession, together with all documentation and
+ related materials. The provisions of clauses 4, 5, 6, 7, 8 and 9 shall
+ survive termination of this Licence.
+
+ 9. GENERAL.
+
+ This Licence is governed by English Law. Except where ARM agrees
+ otherwise in: (i) a written contract signed by you and ARM; or (ii) a
+ written contract provided by ARM and accepted by you, this is the only
+ agreement between you and ARM relating to the Software and it may only
+ be modified by written agreement between you and ARM. Except as
+ expressly agreed in writing, this Licence may not be modified by
+ purchase orders, advertising or other representation by any person. If
+ any clause or sentence in this Licence is held by a court of law to be
+ illegal or unenforceable the remaining provisions of this Licence
+ shall not be affected thereby. The failure by ARM to enforce any of
+ the provisions of this Licence, unless waived in writing, shall not
+ constitute a waiver of ARM's rights to enforce such provision or any
+ other provision of this Licence in the future.
+
+ At ARM's request, you agree to check your computers for installations
+ of the Software and any other information requested by ARM relating to
+ Software installation and to provide this information to ARM. You
+ agree that auditors nominated by ARM may also perform such checking
+ and reporting on behalf of ARM by prior appointment during your normal
+ business hours on seven (7) days' notice. ARM shall bear the auditors'
+ costs for that audit unless it reveals unlicensed usage in which case
+ you shall promptly reimburse ARM for all reasonable costs and
+ expenses, including professional fees, relating to such audit. Any
+ information which is disclosed to ARM or such auditors during checking
+ or audit shall be treated as your confidential information and shall
+ only be used by ARM for licence management, compliance and enforcement
+ purposes.
+
+ The Software provided under this Licence is subject to U.S. export
+ control laws, including the U.S. Export Administration Act and its
+ associated regulations, and may be subject to export or import
+ regulations in other countries. You agree to comply fully with all
+ laws and regulations of the United States and other countries ("Export
+ Laws") to assure that the Software, is not (1) exported, directly or
+ indirectly, in violation of Export Laws, either to any countries that
+ are subject to U.S.A. export restrictions or to any end user who has
+ been prohibited from participating in the U.S.A. export transactions
+ by any federal agency of the U.S.A. government; or (2) intended to be
+ used for any purpose prohibited by Export Laws, including, without
+ limitation, nuclear, chemical, or biological weapons proliferation.
+
+Mali GPU Userspace LES-PRE-20376
diff --git a/self-extractors_hikey960/arm/staging/BoardConfigPartial.mk b/self-extractors_hikey960/arm/staging/BoardConfigPartial.mk
new file mode 100644
index 0000000..c0aab8b
--- /dev/null
+++ b/self-extractors_hikey960/arm/staging/BoardConfigPartial.mk
@@ -0,0 +1,13 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/self-extractors_hikey960/arm/staging/device-partial.mk b/self-extractors_hikey960/arm/staging/device-partial.mk
new file mode 100644
index 0000000..8e667d7
--- /dev/null
+++ b/self-extractors_hikey960/arm/staging/device-partial.mk
@@ -0,0 +1,18 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Linaro blob(s) necessary for Hikey hardware
+PRODUCT_COPY_FILES := \
+ vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/lib64/egl/libGLES_mali.so:linaro \
+ vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/lib/egl/libGLES_mali.so:linaro
diff --git a/self-extractors_hikey960/extract-lists.txt b/self-extractors_hikey960/extract-lists.txt
new file mode 100644
index 0000000..745d295
--- /dev/null
+++ b/self-extractors_hikey960/extract-lists.txt
@@ -0,0 +1,20 @@
+ arm)
+ TO_EXTRACT="\
+ SYSTEM/lib/egl/libGLES_mali.so \
+ SYSTEM/lib64/egl/libGLES_mali.so \
+ "
+ ;;
+ hisilicon)
+ TO_EXTRACT="\
+ SYSTEM/lib/libhilog.so \
+ SYSTEM/lib64/libhilog.so \
+ SYSTEM/lib/libion.so \
+ SYSTEM/lib64/libion.so \
+ SYSTEM/lib/hw/gralloc.hikey960.so \
+ SYSTEM/lib64/hw/gralloc.hikey960.so \
+ SYSTEM/vendor/lib/hwcomposer.hikey960.so \
+ SYSTEM/vendor/lib64/hwcomposer.hikey960.so \
+ SYSTEM/vendor/lib/libhiion.so \
+ SYSTEM/vendor/lib64/libhiion.so \
+ "
+ ;;
diff --git a/self-extractors_hikey960/hisilicon/COPYRIGHT b/self-extractors_hikey960/hisilicon/COPYRIGHT
new file mode 100644
index 0000000..4e017c2
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/COPYRIGHT
@@ -0,0 +1 @@
+# (C) HiSilicon Co. Ltd.
diff --git a/self-extractors_hikey960/hisilicon/LICENSE b/self-extractors_hikey960/hisilicon/LICENSE
new file mode 100644
index 0000000..5d0590b
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/LICENSE
@@ -0,0 +1,193 @@
+End User License Agreement for Software related to Hisilicon HiKey960 Board
+
+THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT
+BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
+HISILICON TECHNOLOGIES CO., LTD. ("HISILICON") FOR THE USE OF THE
+SOFTWARE ACCOMPANYING THIS AGREEMENT. HISILICON IS ONLY WILLING TO
+LICENSE THE SOFTWARE TO YOU ON CONDITION THAT YOU ACCEPT ALL OF THE
+TERMS IN THIS AGREEMENT. BY CLICKING “I AGREE” OR BY INSTALLING OR
+OTHERWISE USING OR COPYING THE SOFTWARE YOU INDICATE THAT YOU AGREE TO
+BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO
+THE TERMS OF THIS AGREEMENT, HISILICON IS UNWILLING TO LICENSE THE
+SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE SOFTWARE, AND
+YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO YOUR
+SUPPLIER.
+
+
+“SOFTWARE” means the software in object code provided under the terms
+of this Agreement related to Hisilicon HiKey960 Board.
+
+
+1. GRANT OF LICENSE
+
+In consideration of your agreement to abide by the following terms,
+and subject to the terms and conditions of this Agreement, HISILICON
+hereby grants YOU, a non-transferable, non-exclusive, royalty-free,
+revocable, worldwide copyright license (without the right to
+sublicense) to use and copy the SOFTWARE solely for the purpose of
+designing or developing applications for use in conjunction with
+Hisilicon HiKey960 Board.
+
+All rights to the SOFTWARE and all intellectual property rights
+contained therein shall remain the sole and exclusive property of
+HISILICON. The SOFTWARE is licensed not sold. Except as expressly
+licensed in Clause 1, in no event shall the license granted in this
+Clause 1 be construed as granting YOU expressly or by implication,
+estoppels or otherwise, licenses to any intellectual property rights,
+including but not limited to patent rights, copyrights, trademark or
+trade secret in the SOFTWARE.
+
+No right is granted to YOU under this Agreement to manufacture, have
+manufactured, or sell, supply or distribute any products which have
+taken into use or which embody any of the SOFTWARE or any of the
+intellectual property rights embodied therein.
+
+
+2. RESTRICTIONS
+
+This Agreement does not prevent YOU from using the SOFTWARE for
+internal benchmarking purposes. However, YOU shall treat any and all
+benchmarking data relating to the SOFTWARE, and any other results of
+your use or testing of the SOFTWARE which are indicative of its
+performance, efficacy, reliability or quality, as confidential
+information and YOU shall not disclose such information to any third
+party without the express written permission of HISILICON.
+
+YOU shall reproduce and not remove or obscure any notice incorporated
+by HISILICON in the SOFTWARE to protect HISILICON’s intellectual
+property rights embodied therein.
+
+YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
+
+
+3. FEEDBACK
+
+YOU may choose to provide suggestions, comments, feedback, ideas,
+modifications or know-how (whether in oral or written form) relating
+to the use of the SOFTWARE ("Feedback") to HISILICON under the terms
+of this Agreement. YOU hereby grants to HISILICON and its affiliates,
+under all of your and your affiliates’ (as applicable) intellectual
+property rights, a perpetual, irrevocable, royalty free,
+non-exclusive, worldwide license to (i) use, copy and modify the
+Feedback; (ii) sell, supply, or otherwise distribute the Feedback;
+(iii) design, have designed, manufacture, have manufactured, use,
+import, sell, and otherwise distribute and dispose of products that
+incorporate the Feedback; and (iv) sublicense (together with the
+rights to further sublicense) the rights granted in this paragraph to
+any third party.
+
+
+4. NO WARRANTY
+
+YOU AGREE THAT THE SOFTWARE IS PROVIDED BY HISILICON ON AN "AS IS"
+BASIS. HISILICON MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY,
+WITH RESPECT TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS
+FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.
+
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
+OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS
+DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS
+PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS,
+ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST
+OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+
+5. NO LIABILITY
+
+PLEASE READ THE INSTRUCTIONS COMPLETELY, AND PLEASE NOTE THAT YOU
+SHOULD USE THE SOFTWARE AT YOUR OWN RISK.
+
+IN NO EVENT SHALL HISILICON BE LIABLE FOR ANY DIRECT OR INDIRECT,
+SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT
+LIMITATION, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
+THE USE OF OR INABILITY TO USE THE SOFTWARE, HOWEVER CAUSED AND
+WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT
+LIABILITY OR OTHER LEGAL THEORY, EVEN IF HISILICON HAS BEEN ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS ANY MATERIAL,
+VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, HISILICON SHALL HAVE NO
+LIABILITY TO MODIFY SUCH ERRORS.
+
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT,
+THE MAXIMUM LIABILITY OF HISILICON TO YOU IN AGGREGATE FOR ALL CLAIMS
+MADE AGAINST HISILICON IN CONTRACT TORT OR OTHERWISE UNDER OR IN
+CONNECTION WITH THE SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED
+THE TOTAL OF SUMS RECEIVED BY HISILICON FROM YOU FOR THIS AGREEMENT.
+THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE
+LIMIT.
+
+
+6. CONFIDENTIALITY
+
+YOU acknowledge and agree that the SOFTWARE and any benchmarking data
+and related information provided under this Agreement contain trade
+secrets and confidential material of HISILICON and YOU agree to
+maintain all such information in confidence and apply security
+measures no less stringent than the measures which YOU apply to
+protect your own like information, but not less than a reasonable
+degree of care, to prevent their unauthorized disclosure and use. The
+period of confidentiality shall be indefinite. YOU agree not to use
+any such information other than in normal use of the SOFTWARE under
+the license granted in this Agreement.
+
+
+7. TERM AND TERMINATION
+
+This Agreement shall remain in force until terminated. HISILICON may
+terminate this Agreement at any time with or without any cause. Upon
+termination of this Agreement, YOU shall immediately stop using the
+SOFTWARE and confidential information and destroy all copies of the
+SOFTWARE and confidential information in your possession, together
+with all documentation and related materials. The provisions of
+clauses 3, 4, 5, 6, 7 and 8 shall survive termination of this
+Agreement.
+
+
+8. GENERAL
+
+Any provision of this Agreement which is prohibited or unenforceable
+in any jurisdiction shall be ineffective to the extent of such
+prohibition or unenforceability without affecting, impairing or
+invalidating the remaining provisions hereof.
+
+The failure by HISILICON to enforce any of the provisions of this
+Agreement, unless waived in writing, shall not constitute a waiver of
+HISILICON's rights to enforce such provision or any other provision of
+this Agreement in the future.
+
+At HISILICON’s request, YOU agree to check your computers for
+installations of the SOFTWARE and any other information requested by
+HISILICON relating to SOFTWARE installation and to provide this
+information to HISILICON. YOU agree that employees or auditors
+nominated by HISILICON may also perform such checking and reporting on
+behalf of HISILICON by prior appointment during your normal business
+hours on seven (7) days’ notice. HISILICON shall bear the auditors’
+costs for that audit unless it reveals unlicensed usage in which case
+YOU shall promptly reimburse HISILICON for all reasonable costs and
+expenses, including professional fees, relating to such audit.
+
+The SOFTWARE provided under this Agreement is subject to U.S. export
+control laws, including the U.S. Export Administration Act and its
+associated regulations, and may be subject to export or import
+regulations in other countries. YOU agree to comply fully with all
+laws and regulations of the United States and other countries ("Export
+Laws") to assure that the SOFTWARE, is not (1) exported, directly or
+indirectly, in violation of Export Laws, either to any countries that
+are subject to U.S.A. export restrictions or to any end user who has
+been prohibited from participating in the U.S.A. export transactions
+by any federal agency of the U.S.A. government; or (2) intended to be
+used for any purpose prohibited by Export Laws, including, without
+limitation, nuclear, chemical, or biological weapons proliferation.
+
+This Agreement shall be governed by and construed in accordance with
+the laws of People’s Republic of China, without reference to the
+principles of conflicts of laws. Any dispute arising out of or
+relating to this Agreement shall be submitted to Shenzhen Longgang
+District People’s court and parties waive all objections to that
+jurisdiction and venue.
+
+
+---------------------------------------------------------------------
+
+Copyright (C) 2017 Hisilicon Technologies Co., Ltd. All rights reserved.
diff --git a/self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk b/self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk
new file mode 100644
index 0000000..c0aab8b
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk
@@ -0,0 +1,13 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/self-extractors_hikey960/hisilicon/staging/device-partial.mk b/self-extractors_hikey960/hisilicon/staging/device-partial.mk
new file mode 100644
index 0000000..9bea222
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/staging/device-partial.mk
@@ -0,0 +1,26 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Linaro blob(s) necessary for Hikey hardware
+PRODUCT_COPY_FILES := \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhilog.so:system/lib64/libhilog.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libhilog.so:system/lib/libhilog.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libion.so:system/lib64/libion.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libion.so:system/lib/libion.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/gralloc.hikey960.so:system/lib64/hw/gralloc.hikey960.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/gralloc.hikey960.so:system/lib/hw/gralloc.hikey960.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/hwcomposer.hikey960.so:system/vendor/lib64/hwcomposer.hikey960.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/hwcomposer.hikey960.so:system/vendor/lib/hwcomposer.hikey960.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhiion.so:system/vendor/lib64/libhiion.so \
+ vendor/linaro/hikey960/hisilicon/proprietary/libhiion.so:system/vendor/lib/libhiion.so
diff --git a/self-extractors_hikey960/root/BoardConfigVendor.mk b/self-extractors_hikey960/root/BoardConfigVendor.mk
new file mode 100644
index 0000000..1517386
--- /dev/null
+++ b/self-extractors_hikey960/root/BoardConfigVendor.mk
@@ -0,0 +1,17 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_STEM := hikey960/BoardConfigPartial.mk
+
+-include vendor/linaro/$(LOCAL_STEM)
diff --git a/self-extractors_hikey960/root/device-vendor.mk b/self-extractors_hikey960/root/device-vendor.mk
new file mode 100644
index 0000000..35494e6
--- /dev/null
+++ b/self-extractors_hikey960/root/device-vendor.mk
@@ -0,0 +1,20 @@
+#
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_STEM := device-partial.mk
+
+$(call inherit-product-if-exists, vendor/linaro/hikey960/hisilicon/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/linaro/hikey960/arm/$(LOCAL_STEM))
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 7b692d1..6d91f79 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -1,9 +1,11 @@
/dev/ttyAMA0 u:object_r:console_device:s0
/dev/ttyAMA3 u:object_r:console_device:s0
+/dev/ttyAMA5 u:object_r:console_device:s0
/dev/ttyFIQ0 u:object_r:console_device:s0
/dev/mali u:object_r:gpu_device:s0
/dev/dri/card0 u:object_r:gpu_device:s0
/dev/hci_tty u:object_r:hci_attach_dev:s0
/dev/ttyAMA1 u:object_r:hci_attach_dev:s0
+/dev/ttyAMA4 u:object_r:hci_attach_dev:s0
/system/vendor/bin/uim u:object_r:hci_attach_exec:s0
/system/vendor/bin/hw/android\.hardware\.bluetooth@1\.0-service\.hikey u:object_r:hal_bluetooth_hikey_exec:s0
diff --git a/ueventd.common.rc b/ueventd.common.rc
index 6a21eea..c96300f 100644
--- a/ueventd.common.rc
+++ b/ueventd.common.rc
@@ -1,3 +1,5 @@
/dev/hci_tty 0666 root root
/dev/ttyAMA1 0660 bluetooth bluetooth
+/dev/ttyAMA4 0660 bluetooth bluetooth
/dev/mali 0666 system graphics
+/dev/mali0 0666 system graphics
diff --git a/vendorsetup.sh b/vendorsetup.sh
index dedfea3..6797c3a 100755
--- a/vendorsetup.sh
+++ b/vendorsetup.sh
@@ -21,3 +21,4 @@
# function: add_lunch_combo generic-eng
add_lunch_combo hikey-userdebug
+add_lunch_combo hikey960-userdebug
diff --git a/wpan/uim/uim.c b/wpan/uim/uim.c
index a9dde00..7f78f0c 100644
--- a/wpan/uim/uim.c
+++ b/wpan/uim/uim.c
@@ -42,6 +42,12 @@
char uim_bd_address[BD_ADDR_LEN];
bdaddr_t *bd_addr;
+/* kim Sysfs path */
+static char *sysfs_install_entry = INSTALL_SYSFS_ENTRY;
+static char *sysfs_dev_name = DEV_NAME_SYSFS;
+static char *sysfs_baud_rate = BAUD_RATE_SYSFS;
+static char *sysfs_flow_ctrl = FLOW_CTRL_SYSFS;
+
/*****************************************************************************/
#ifdef UIM_DEBUG
/* Function to Read the firmware version
@@ -65,6 +71,14 @@
}
#endif
+void sysfs_entry_fallback(void)
+{
+ sysfs_install_entry = INSTALL_SYSFS_ENTRY_OLD;
+ sysfs_dev_name = DEV_NAME_SYSFS_OLD;
+ sysfs_baud_rate = BAUD_RATE_SYSFS_OLD;
+ sysfs_flow_ctrl = FLOW_CTRL_SYSFS_OLD;
+}
+
/*****************************************************************************/
/* Function to read the HCI event from the given file descriptor
*
@@ -283,9 +297,9 @@
if (install == '1') {
memset(buf, 0, UART_DEV_NAME_LEN);
- fd = open(DEV_NAME_SYSFS, O_RDONLY);
+ fd = open(sysfs_dev_name, O_RDONLY);
if (fd < 0) {
- UIM_ERR("Can't open %s", DEV_NAME_SYSFS);
+ UIM_ERR("Can't open %s", sysfs_dev_name);
return -1;
}
len = read(fd, buf, UART_DEV_NAME_LEN);
@@ -298,9 +312,9 @@
close(fd);
memset(buf, 0, UART_DEV_NAME_LEN);
- fd = open(BAUD_RATE_SYSFS, O_RDONLY);
+ fd = open(sysfs_baud_rate, O_RDONLY);
if (fd < 0) {
- UIM_ERR("Can't open %s", BAUD_RATE_SYSFS);
+ UIM_ERR("Can't open %s", sysfs_baud_rate);
return -1;
}
len = read(fd, buf, UART_DEV_NAME_LEN);
@@ -313,9 +327,9 @@
sscanf((const char*)buf, "%d", &cust_baud_rate);
memset(buf, 0, UART_DEV_NAME_LEN);
- fd = open(FLOW_CTRL_SYSFS, O_RDONLY);
+ fd = open(sysfs_flow_ctrl, O_RDONLY);
if (fd < 0) {
- UIM_ERR("Can't open %s", FLOW_CTRL_SYSFS);
+ UIM_ERR("Can't open %s", sysfs_flow_ctrl);
close(fd);
return -1;
}
@@ -486,14 +500,17 @@
/* sysfs entry may get populated after service is started so we retry if it fails*/
while (trials > 0) {
- st_fd = open(INSTALL_SYSFS_ENTRY, O_RDONLY);
+ st_fd = open(sysfs_install_entry, O_RDONLY);
if(st_fd > 0)
break;
- usleep(500000);
+ if (trials == 3)
+ sysfs_entry_fallback();
+ else
+ usleep(500000);
--trials;
}
if (st_fd < 0) {
- UIM_DBG("unable to open %s(%s)", INSTALL_SYSFS_ENTRY, strerror(errno));
+ UIM_DBG("unable to open %s(%s)", sysfs_install_entry, strerror(errno));
return -1;
}
@@ -525,9 +542,9 @@
}
close(st_fd);
- st_fd = open(INSTALL_SYSFS_ENTRY, O_RDONLY);
+ st_fd = open(sysfs_install_entry, O_RDONLY);
if (st_fd < 0) {
- UIM_DBG("unable to open %s (%s)", INSTALL_SYSFS_ENTRY, strerror(errno));
+ UIM_DBG("unable to open %s (%s)", sysfs_install_entry, strerror(errno));
return -1;
}
diff --git a/wpan/uim/uim.h b/wpan/uim/uim.h
index c88d9cc..dc9c5b1 100644
--- a/wpan/uim/uim.h
+++ b/wpan/uim/uim.h
@@ -69,6 +69,10 @@
#define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate"
#define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl"
+#define INSTALL_SYSFS_ENTRY_OLD "/sys/devices/kim/install"
+#define DEV_NAME_SYSFS_OLD "/sys/devices/kim/dev_name"
+#define BAUD_RATE_SYSFS_OLD "/sys/devices/kim/baud_rate"
+#define FLOW_CTRL_SYSFS_OLD "/sys/devices/kim/flow_cntrl"
#define VERBOSE
/*Debug logs*/