1f1e0f152SPaul BeesleyHiKey960 2f1e0f152SPaul Beesley======== 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 9f1e0f152SPaul Beesley------------ 106f625747SDouglas Raillard 116f625747SDouglas RaillardCode Locations 12f1e0f152SPaul Beesley~~~~~~~~~~~~~~ 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 RaillardBuild Procedure 30f1e0f152SPaul Beesley~~~~~~~~~~~~~~~ 316f625747SDouglas Raillard 326f625747SDouglas Raillard- Fetch all the above 5 repositories into local host. 336f625747SDouglas Raillard Make all the repositories in the same ${BUILD\_PATH}. 346f625747SDouglas Raillard 3537c21657SVictor Chong .. code:: shell 3637c21657SVictor Chong 3737c21657SVictor Chong git clone https://github.com/ARM-software/arm-trusted-firmware -b integration 3837c21657SVictor Chong git clone https://github.com/OP-TEE/optee_os 3937c21657SVictor Chong git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5 4037c21657SVictor Chong git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4 4137c21657SVictor Chong git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2 4237c21657SVictor Chong 436f625747SDouglas Raillard- Create the symbol link to OpenPlatformPkg in edk2. 446f625747SDouglas Raillard 456f625747SDouglas Raillard .. code:: shell 466f625747SDouglas Raillard 476f625747SDouglas Raillard $cd ${BUILD_PATH}/edk2 486f625747SDouglas Raillard $ln -sf ../OpenPlatformPkg 496f625747SDouglas Raillard 506f625747SDouglas Raillard- Prepare AARCH64 toolchain. 516f625747SDouglas Raillard 52*3888c2d4SHaojian Zhuang- If your hikey960 hardware is v1, update *OpenPlatformPkg/Platforms/Hisilicon/HiKey960/HiKey960.dsc* first. *(optional)* 536f625747SDouglas Raillard 546f625747SDouglas Raillard .. code:: shell 556f625747SDouglas Raillard 56*3888c2d4SHaojian Zhuang DEFINE SERIAL_BASE=0xFDF05000 576f625747SDouglas Raillard 586f625747SDouglas Raillard If your hikey960 hardware is v2 or newer, nothing to do. 596f625747SDouglas Raillard 606f625747SDouglas Raillard- Build it as debug mode. Create script file for build. 616f625747SDouglas Raillard 626f625747SDouglas Raillard .. code:: shell 636f625747SDouglas Raillard 64*3888c2d4SHaojian Zhuang cd {BUILD_PATH}/arm-trusted-firmware 65*3888c2d4SHaojian Zhuang sh ../l-loader/build_uefi.sh hikey960 666f625747SDouglas Raillard 6737c21657SVictor Chong- Generate l-loader.bin and partition table. 686f625747SDouglas Raillard *Make sure that you're using the sgdisk in the l-loader directory.* 696f625747SDouglas Raillard 706f625747SDouglas Raillard .. code:: shell 716f625747SDouglas Raillard 7237c21657SVictor Chong cd ${BUILD_PATH}/l-loader 7337c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin 74d2128731SHaojian Zhuang ln -sf ${EDK2_OUTPUT_DIR}/FV/bl2.bin 7537c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin 7637c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd 7737c21657SVictor Chong make hikey960 786f625747SDouglas Raillard 796f625747SDouglas RaillardSetup Console 806f625747SDouglas Raillard------------- 816f625747SDouglas Raillard 826f625747SDouglas Raillard- Install ser2net. Use telnet as the console since UEFI will output window 836f625747SDouglas Raillard that fails to display in minicom. 846f625747SDouglas Raillard 856f625747SDouglas Raillard .. code:: shell 866f625747SDouglas Raillard 876f625747SDouglas Raillard $sudo apt-get install ser2net 886f625747SDouglas Raillard 896f625747SDouglas Raillard- Configure ser2net. 906f625747SDouglas Raillard 916f625747SDouglas Raillard .. code:: shell 926f625747SDouglas Raillard 936f625747SDouglas Raillard $sudo vi /etc/ser2net.conf 946f625747SDouglas Raillard 956f625747SDouglas Raillard Append one line for serial-over-USB in *#ser2net.conf* 966f625747SDouglas Raillard 976f625747SDouglas Raillard :: 986f625747SDouglas Raillard 996f625747SDouglas Raillard 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner 1006f625747SDouglas Raillard 10142ba9f29SVictor Chong- Start ser2net 10242ba9f29SVictor Chong 10342ba9f29SVictor Chong .. code:: shell 10442ba9f29SVictor Chong 10542ba9f29SVictor Chong $sudo killall ser2net 10642ba9f29SVictor Chong $sudo ser2net -u 10742ba9f29SVictor Chong 1086f625747SDouglas Raillard- Open the console. 1096f625747SDouglas Raillard 1106f625747SDouglas Raillard .. code:: shell 1116f625747SDouglas Raillard 1126f625747SDouglas Raillard $telnet localhost 2004 1136f625747SDouglas Raillard 1146f625747SDouglas Raillard And you could open the console remotely, too. 1156f625747SDouglas Raillard 1166f625747SDouglas RaillardBoot UEFI in recovery mode 1176f625747SDouglas Raillard-------------------------- 1186f625747SDouglas Raillard 1196f625747SDouglas Raillard- Fetch that are used in recovery mode. The code location is in below. 1206f625747SDouglas Raillard `link <https://github.com/96boards-hikey/tools-images-hikey960>`__ 1216f625747SDouglas Raillard 122d2128731SHaojian Zhuang- Prepare recovery binary. 1236f625747SDouglas Raillard 1246f625747SDouglas Raillard .. code:: shell 1256f625747SDouglas Raillard 1266f625747SDouglas Raillard $cd tools-images-hikey960 1276f625747SDouglas Raillard $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin 12837c21657SVictor Chong $ln -sf ${BUILD_PATH}/l-loader/fip.bin 129d2128731SHaojian Zhuang $ln -sf ${BUILD_PATH}/l-loader/recovery.bin 1306f625747SDouglas Raillard 1316f625747SDouglas Raillard- Prepare config file. 1326f625747SDouglas Raillard 1336f625747SDouglas Raillard .. code:: shell 1346f625747SDouglas Raillard 1356f625747SDouglas Raillard $vi config 1366f625747SDouglas Raillard # The content of config file 13742ba9f29SVictor Chong ./sec_usb_xloader.img 0x00020000 1386f625747SDouglas Raillard ./sec_uce_boot.img 0x6A908000 139d2128731SHaojian Zhuang ./recovery.bin 0x1AC00000 1406f625747SDouglas Raillard 1416f625747SDouglas Raillard- Remove the modemmanager package. This package may causes hikey\_idt tool failure. 1426f625747SDouglas Raillard 1436f625747SDouglas Raillard .. code:: shell 1446f625747SDouglas Raillard 1456f625747SDouglas Raillard $sudo apt-get purge modemmanager 1466f625747SDouglas Raillard 147d2128731SHaojian Zhuang- Run the command to download recovery.bin into HiKey960. 1486f625747SDouglas Raillard 1496f625747SDouglas Raillard .. code:: shell 1506f625747SDouglas Raillard 1516f625747SDouglas Raillard $sudo ./hikey_idt -c config -p /dev/ttyUSB1 1526f625747SDouglas Raillard 1536f625747SDouglas Raillard- UEFI running in recovery mode. 1546f625747SDouglas Raillard When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running. 1556f625747SDouglas Raillard The timeout of prompt '.' is 10 seconds. 1566f625747SDouglas Raillard 1576f625747SDouglas Raillard- Update images. 1586f625747SDouglas Raillard 1596f625747SDouglas Raillard .. code:: shell 1606f625747SDouglas Raillard 1616f625747SDouglas Raillard $sudo fastboot flash ptable prm_ptable.img 1626f625747SDouglas Raillard $sudo fastboot flash xloader sec_xloader.img 1636f625747SDouglas Raillard $sudo fastboot flash fastboot l-loader.bin 1646f625747SDouglas Raillard $sudo fastboot flash fip fip.bin 1656f625747SDouglas Raillard $sudo fastboot flash boot boot.img 1666f625747SDouglas Raillard $sudo fastboot flash cache cache.img 1676f625747SDouglas Raillard $sudo fastboot flash system system.img 1686f625747SDouglas Raillard $sudo fastboot flash userdata userdata.img 1696f625747SDouglas Raillard 1706f625747SDouglas Raillard- Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in 1716f625747SDouglas Raillard recovery mode. 1726f625747SDouglas Raillard 1736f625747SDouglas RaillardBoot UEFI in normal mode 1746f625747SDouglas Raillard------------------------ 1756f625747SDouglas Raillard 1766f625747SDouglas Raillard- Make sure "Boot Mode" switch is OFF for normal boot mode. Then power on HiKey960. 1776f625747SDouglas Raillard 1786f625747SDouglas Raillard- Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__ 1796f625747SDouglas Raillard 180dd4e9a7dSPaul Beesley.. _link: https://www.96boards.org/documentation/consumer/hikey/hikey960 181