Welcome to the hikey960-aosp-optee wiki!
Create build environment
$ repo init -u https://android.googlesource.com/platform/manifest -b master
Copy the default.xml of this repository in ".repo/manifests/"
$ cp default.xml .repo/manifests/default.xml
$ repo sync -j24
Apply all patches:
"optee_os_patch.diff" in "optee/optee_os/core/arch/arm/plat-hikey"
"aosp_optee_patch.diff" in "device/linaro/hikey"
"atf_script_patch.diff" in "optee/ATF/tools-images-hikey960"
Go to the root of your environment
Set environment variables : $ source build/envsetup.sh
Choose the target : $ lunch hikey960-userdebug
Note : If your board has 3GB RAM change CFG_DRAM_SIZE_GB=4 in "plat-hikey/conf.mk" to CFG_DRAM_SIZE_GB=3
In "optee/ATF/tools-images-hikey960" create a directory named "toolchains"
Download and decompress the following toolchains in the previous directory :
Build ARM-Trusted-Firmware
Go to the directory "optee/ATF/tools-images-hikey960"
For the first build use :
$ source build_atf.sh or $ . build_atf.sh
Next build can be started with $ ./build_atf.sh
Build Hikey960 AOSP kernel
Go to the directory "kernel/hikey-linaro"
$ make ARCH=arm64 hikey960_defconfig
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- -j24
Then copy "arch/arm64/boot/Image.gz-dtb" in "device/linaro/hikey-kernel" with the name "Image.gz-dtb-hikey960-4.9"
Build AOSP + OP-TEE
Go to the root of your environment
For the first build comment the following line in "device/linaro/hikey/device-common.mk":
$(call inherit-product-if-exists, device/linaro/hikey/optee-packages.mk)
$ make -j32
At the end of the build, uncomment the previous line.
$ make -j32 CFG_SECTORS_TA_MGMT_PTA=y CFG_SECURE_DATA_PATH=y
Known build error :
undefined symbol: install_ta_runner_cmd_parser
solving it by changing -j32 to -j1.
Flash images
Get all the following files and move them in the same directory.
Directory "ATF/l-loader":
l-loader.bin
fip.bin
ptable-aosp-32g.img
recovery.bin
Directory "ATF/tools-images-hikey960":
hisi-sec_xloader.img
hisi-sec_usb_xloader.img
hisi-sec_uce_boot.img
hikey_idt
Directory "out/target/product/hikey960":
boot.img
dt.img
cache.img
userdata.img
vendor.img
system.img
Now create a file named "config" with the following content:
./hisi-sec_usb_xloader.img 0x00020000
./hisi-sec_uce_boot.img 0x6A908000
./recovery.bin 0x1AC00000
Boot the hikey960 in recovery mode (ON - ON - OFF)
$ sudo hikey_idt -c config -p /dev/ttyUSB1
The board is now in fastboot mode (test with $ fastboot devices).
Flash UEFI + ATF :
$ fastboot flash ptable ptable-aosp-32g.img
$ fastboot flash xloader hisi-sec_xloader.img
$ fastboot flash fastboot l-loader.bin
$ fastboot flash fip fip.bin
Flash AOSP + OPTEE :
$ fastboot flash boot boot.img
$ fastboot flash cache cache.img
$ fastboot flash dts dt.img
$ fastboot flash userdata userdata.img
$ fastboot flash vendor vendor.img
$ fastboot flash system system.img
Boot the hikey960 in normal mode (ON - OFF - OFF)
Known issues
File init.hikey960.rc isn't executed, so tee-supplicant isn't started when the hikey960 boot and directories for xtest aren't created.
Solution:
Start tee-supplicant manually
Create /data/tee with rights 0777, shell, shell
Create /data/tee/optee_armtz with rights 0777, shell, shell
USB3.0 doesn't work
Solution:
The USB-A cannot operate when the USB-C is connected. So disconnect him !
SEPolicy doesn't apply