16f625747SDouglas RaillardDescription 26f625747SDouglas Raillard=========== 36f625747SDouglas Raillard 46f625747SDouglas RaillardHiKey960 is one of 96boards. Hisilicon Hi3660 processor is installed on HiKey960. 56f625747SDouglas Raillard 66f625747SDouglas RaillardMore information are listed in `link`_. 76f625747SDouglas Raillard 86f625747SDouglas RaillardHow to build 96f625747SDouglas Raillard============ 106f625747SDouglas Raillard 116f625747SDouglas RaillardCode Locations 126f625747SDouglas Raillard-------------- 136f625747SDouglas Raillard 144def07d5SDan Handley- Trusted Firmware-A: 156f625747SDouglas Raillard `link <https://github.com/ARM-software/arm-trusted-firmware>`__ 166f625747SDouglas Raillard 175e3325e7SVictor Chong- OP-TEE: 185e3325e7SVictor Chong `link <https://github.com/OP-TEE/optee_os>`__ 195e3325e7SVictor Chong 206f625747SDouglas Raillard- edk2: 216f625747SDouglas Raillard `link <https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5>`__ 226f625747SDouglas Raillard 236f625747SDouglas Raillard- OpenPlatformPkg: 246f625747SDouglas Raillard `link <https://github.com/96boards-hikey/OpenPlatformPkg/tree/testing/hikey960_v1.3.4>`__ 256f625747SDouglas Raillard 266f625747SDouglas Raillard- l-loader: 276f625747SDouglas Raillard `link <https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2>`__ 286f625747SDouglas Raillard 296f625747SDouglas Raillard- uefi-tools: 3042ba9f29SVictor Chong `link <https://git.linaro.org/uefi/uefi-tools.git>`__ 316f625747SDouglas Raillard 326f625747SDouglas RaillardBuild Procedure 336f625747SDouglas Raillard--------------- 346f625747SDouglas Raillard 356f625747SDouglas Raillard- Fetch all the above 5 repositories into local host. 366f625747SDouglas Raillard Make all the repositories in the same ${BUILD\_PATH}. 376f625747SDouglas Raillard 3837c21657SVictor Chong .. code:: shell 3937c21657SVictor Chong 4037c21657SVictor Chong git clone https://github.com/ARM-software/arm-trusted-firmware -b integration 4137c21657SVictor Chong git clone https://github.com/OP-TEE/optee_os 4237c21657SVictor Chong git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5 4337c21657SVictor Chong git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4 4437c21657SVictor Chong git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2 4537c21657SVictor Chong git clone https://git.linaro.org/uefi/uefi-tools 4637c21657SVictor Chong 476f625747SDouglas Raillard- Create the symbol link to OpenPlatformPkg in edk2. 486f625747SDouglas Raillard 496f625747SDouglas Raillard .. code:: shell 506f625747SDouglas Raillard 516f625747SDouglas Raillard $cd ${BUILD_PATH}/edk2 526f625747SDouglas Raillard $ln -sf ../OpenPlatformPkg 536f625747SDouglas Raillard 546f625747SDouglas Raillard- Prepare AARCH64 toolchain. 556f625747SDouglas Raillard 566f625747SDouglas Raillard- If your hikey960 hardware is v1, update *uefi-tools/platform.config* first. *(optional)* 576f625747SDouglas Raillard **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial 586f625747SDouglas Raillard console on hikey960 v1.** 596f625747SDouglas Raillard 606f625747SDouglas Raillard .. code:: shell 616f625747SDouglas Raillard 626f625747SDouglas Raillard BUILDFLAGS=-DSERIAL_BASE=0xFDF05000 636f625747SDouglas Raillard 646f625747SDouglas Raillard If your hikey960 hardware is v2 or newer, nothing to do. 656f625747SDouglas Raillard 666f625747SDouglas Raillard- Build it as debug mode. Create script file for build. 676f625747SDouglas Raillard 686f625747SDouglas Raillard .. code:: shell 696f625747SDouglas Raillard 706f625747SDouglas Raillard BUILD_OPTION=DEBUG 7142ba9f29SVictor Chong export AARCH64_TOOLCHAIN=GCC5 726f625747SDouglas Raillard export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools 736f625747SDouglas Raillard export EDK2_DIR=${BUILD_PATH}/edk2 746f625747SDouglas Raillard EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey960/${BUILD_OPTION}_${AARCH64_TOOLCHAIN} 756f625747SDouglas Raillard cd ${EDK2_DIR} 764def07d5SDan Handley # Build UEFI & Trusted Firmware-A 775e3325e7SVictor Chong ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey960 786f625747SDouglas Raillard 7937c21657SVictor Chong- Generate l-loader.bin and partition table. 806f625747SDouglas Raillard *Make sure that you're using the sgdisk in the l-loader directory.* 816f625747SDouglas Raillard 826f625747SDouglas Raillard .. code:: shell 836f625747SDouglas Raillard 8437c21657SVictor Chong cd ${BUILD_PATH}/l-loader 8537c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin 86d2128731SHaojian Zhuang ln -sf ${EDK2_OUTPUT_DIR}/FV/bl2.bin 8737c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin 8837c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd 8937c21657SVictor Chong make hikey960 906f625747SDouglas Raillard 916f625747SDouglas RaillardSetup Console 926f625747SDouglas Raillard------------- 936f625747SDouglas Raillard 946f625747SDouglas Raillard- Install ser2net. Use telnet as the console since UEFI will output window 956f625747SDouglas Raillard that fails to display in minicom. 966f625747SDouglas Raillard 976f625747SDouglas Raillard .. code:: shell 986f625747SDouglas Raillard 996f625747SDouglas Raillard $sudo apt-get install ser2net 1006f625747SDouglas Raillard 1016f625747SDouglas Raillard- Configure ser2net. 1026f625747SDouglas Raillard 1036f625747SDouglas Raillard .. code:: shell 1046f625747SDouglas Raillard 1056f625747SDouglas Raillard $sudo vi /etc/ser2net.conf 1066f625747SDouglas Raillard 1076f625747SDouglas Raillard Append one line for serial-over-USB in *#ser2net.conf* 1086f625747SDouglas Raillard 1096f625747SDouglas Raillard :: 1106f625747SDouglas Raillard 1116f625747SDouglas Raillard 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner 1126f625747SDouglas Raillard 11342ba9f29SVictor Chong- Start ser2net 11442ba9f29SVictor Chong 11542ba9f29SVictor Chong .. code:: shell 11642ba9f29SVictor Chong 11742ba9f29SVictor Chong $sudo killall ser2net 11842ba9f29SVictor Chong $sudo ser2net -u 11942ba9f29SVictor Chong 1206f625747SDouglas Raillard- Open the console. 1216f625747SDouglas Raillard 1226f625747SDouglas Raillard .. code:: shell 1236f625747SDouglas Raillard 1246f625747SDouglas Raillard $telnet localhost 2004 1256f625747SDouglas Raillard 1266f625747SDouglas Raillard And you could open the console remotely, too. 1276f625747SDouglas Raillard 1286f625747SDouglas RaillardBoot UEFI in recovery mode 1296f625747SDouglas Raillard-------------------------- 1306f625747SDouglas Raillard 1316f625747SDouglas Raillard- Fetch that are used in recovery mode. The code location is in below. 1326f625747SDouglas Raillard `link <https://github.com/96boards-hikey/tools-images-hikey960>`__ 1336f625747SDouglas Raillard 134d2128731SHaojian Zhuang- Prepare recovery binary. 1356f625747SDouglas Raillard 1366f625747SDouglas Raillard .. code:: shell 1376f625747SDouglas Raillard 1386f625747SDouglas Raillard $cd tools-images-hikey960 1396f625747SDouglas Raillard $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin 14037c21657SVictor Chong $ln -sf ${BUILD_PATH}/l-loader/fip.bin 141d2128731SHaojian Zhuang $ln -sf ${BUILD_PATH}/l-loader/recovery.bin 1426f625747SDouglas Raillard 1436f625747SDouglas Raillard- Prepare config file. 1446f625747SDouglas Raillard 1456f625747SDouglas Raillard .. code:: shell 1466f625747SDouglas Raillard 1476f625747SDouglas Raillard $vi config 1486f625747SDouglas Raillard # The content of config file 14942ba9f29SVictor Chong ./sec_usb_xloader.img 0x00020000 1506f625747SDouglas Raillard ./sec_uce_boot.img 0x6A908000 151d2128731SHaojian Zhuang ./recovery.bin 0x1AC00000 1526f625747SDouglas Raillard 1536f625747SDouglas Raillard- Remove the modemmanager package. This package may causes hikey\_idt tool failure. 1546f625747SDouglas Raillard 1556f625747SDouglas Raillard .. code:: shell 1566f625747SDouglas Raillard 1576f625747SDouglas Raillard $sudo apt-get purge modemmanager 1586f625747SDouglas Raillard 159d2128731SHaojian Zhuang- Run the command to download recovery.bin into HiKey960. 1606f625747SDouglas Raillard 1616f625747SDouglas Raillard .. code:: shell 1626f625747SDouglas Raillard 1636f625747SDouglas Raillard $sudo ./hikey_idt -c config -p /dev/ttyUSB1 1646f625747SDouglas Raillard 1656f625747SDouglas Raillard- UEFI running in recovery mode. 1666f625747SDouglas Raillard When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running. 1676f625747SDouglas Raillard The timeout of prompt '.' is 10 seconds. 1686f625747SDouglas Raillard 1696f625747SDouglas Raillard- Update images. 1706f625747SDouglas Raillard 1716f625747SDouglas Raillard .. code:: shell 1726f625747SDouglas Raillard 1736f625747SDouglas Raillard $sudo fastboot flash ptable prm_ptable.img 1746f625747SDouglas Raillard $sudo fastboot flash xloader sec_xloader.img 1756f625747SDouglas Raillard $sudo fastboot flash fastboot l-loader.bin 1766f625747SDouglas Raillard $sudo fastboot flash fip fip.bin 1776f625747SDouglas Raillard $sudo fastboot flash boot boot.img 1786f625747SDouglas Raillard $sudo fastboot flash cache cache.img 1796f625747SDouglas Raillard $sudo fastboot flash system system.img 1806f625747SDouglas Raillard $sudo fastboot flash userdata userdata.img 1816f625747SDouglas Raillard 1826f625747SDouglas Raillard- Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in 1836f625747SDouglas Raillard recovery mode. 1846f625747SDouglas Raillard 1856f625747SDouglas RaillardBoot UEFI in normal mode 1866f625747SDouglas Raillard------------------------ 1876f625747SDouglas Raillard 1886f625747SDouglas Raillard- Make sure "Boot Mode" switch is OFF for normal boot mode. Then power on HiKey960. 1896f625747SDouglas Raillard 1906f625747SDouglas Raillard- Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__ 1916f625747SDouglas Raillard 192*dd4e9a7dSPaul Beesley.. _link: https://www.96boards.org/documentation/consumer/hikey/hikey960 193