1*f1e0f152SPaul BeesleyHiKey 2*f1e0f152SPaul Beesley===== 36f625747SDouglas Raillard 46f625747SDouglas RaillardHiKey is one of 96boards. Hisilicon Kirin6220 processor is installed on HiKey. 56f625747SDouglas Raillard 66f625747SDouglas RaillardMore information are listed in `link`_. 76f625747SDouglas Raillard 86f625747SDouglas RaillardHow to build 9*f1e0f152SPaul Beesley------------ 106f625747SDouglas Raillard 116f625747SDouglas RaillardCode Locations 12*f1e0f152SPaul Beesley~~~~~~~~~~~~~~ 136f625747SDouglas Raillard 144def07d5SDan Handley- Trusted Firmware-A: 156f625747SDouglas Raillard `link <https://github.com/ARM-software/arm-trusted-firmware>`__ 166f625747SDouglas Raillard 173b6e88a2SVictor Chong- OP-TEE 183b6e88a2SVictor Chong `link <https://github.com/OP-TEE/optee_os>`__ 193b6e88a2SVictor 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: 30367456dfSVictor Chong `link <https://git.linaro.org/uefi/uefi-tools.git>`__ 316f625747SDouglas Raillard 326f625747SDouglas Raillard- atf-fastboot: 336f625747SDouglas Raillard `link <https://github.com/96boards-hikey/atf-fastboot/tree/master>`__ 346f625747SDouglas Raillard 356f625747SDouglas RaillardBuild Procedure 36*f1e0f152SPaul Beesley~~~~~~~~~~~~~~~ 376f625747SDouglas Raillard 386f625747SDouglas Raillard- Fetch all the above repositories into local host. 396f625747SDouglas Raillard Make all the repositories in the same ${BUILD\_PATH}. 406f625747SDouglas Raillard 4137c21657SVictor Chong .. code:: shell 4237c21657SVictor Chong 4337c21657SVictor Chong git clone https://github.com/ARM-software/arm-trusted-firmware -b integration 4437c21657SVictor Chong git clone https://github.com/OP-TEE/optee_os 4537c21657SVictor Chong git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5 4637c21657SVictor Chong git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4 4737c21657SVictor Chong git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2 4837c21657SVictor Chong git clone https://git.linaro.org/uefi/uefi-tools 4937c21657SVictor Chong git clone https://github.com/96boards-hikey/atf-fastboot 5037c21657SVictor Chong 516f625747SDouglas Raillard- Create the symbol link to OpenPlatformPkg in edk2. 526f625747SDouglas Raillard 536f625747SDouglas Raillard .. code:: shell 546f625747SDouglas Raillard 556f625747SDouglas Raillard $cd ${BUILD_PATH}/edk2 566f625747SDouglas Raillard $ln -sf ../OpenPlatformPkg 576f625747SDouglas Raillard 586f625747SDouglas Raillard- Prepare AARCH64 && AARCH32 toolchain. Prepare python. 596f625747SDouglas Raillard 606f625747SDouglas Raillard- If your hikey hardware is built by CircuitCo, update *uefi-tools/platform.config* first. *(optional)* 616f625747SDouglas Raillard **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial 626f625747SDouglas Raillard console on hikey.** 636f625747SDouglas Raillard 646f625747SDouglas Raillard .. code:: shell 656f625747SDouglas Raillard 666f625747SDouglas Raillard BUILDFLAGS=-DSERIAL_BASE=0xF8015000 676f625747SDouglas Raillard 681b9e79e8SAndreas Färber If your hikey hardware is built by LeMaker, nothing to do. 696f625747SDouglas Raillard 706f625747SDouglas Raillard- Build it as debug mode. Create your own build script file or you could refer to **build\_uefi.sh** in l-loader git repository. 716f625747SDouglas Raillard 726f625747SDouglas Raillard .. code:: shell 736f625747SDouglas Raillard 746f625747SDouglas Raillard BUILD_OPTION=DEBUG 756f625747SDouglas Raillard export AARCH64_TOOLCHAIN=GCC5 766f625747SDouglas Raillard export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools 776f625747SDouglas Raillard export EDK2_DIR=${BUILD_PATH}/edk2 786f625747SDouglas Raillard EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey/${BUILD_OPTION}_${AARCH64_TOOLCHAIN} 794def07d5SDan Handley # Build fastboot for Trusted Firmware-A. It's used for recovery mode. 806f625747SDouglas Raillard cd ${BUILD_PATH}/atf-fastboot 816f625747SDouglas Raillard CROSS_COMPILE=aarch64-linux-gnu- make PLAT=hikey DEBUG=1 826f625747SDouglas Raillard # Convert DEBUG/RELEASE to debug/release 836f625747SDouglas Raillard FASTBOOT_BUILD_OPTION=$(echo ${BUILD_OPTION} | tr '[A-Z]' '[a-z]') 846f625747SDouglas Raillard cd ${EDK2_DIR} 854def07d5SDan Handley # Build UEFI & Trusted Firmware-A 863b6e88a2SVictor Chong ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey 876f625747SDouglas Raillard 8837c21657SVictor Chong- Generate l-loader.bin and partition table for aosp. The eMMC capacity is either 8GB or 4GB. Just change "aosp-8g" to "linux-8g" for debian. 896f625747SDouglas Raillard 906f625747SDouglas Raillard .. code:: shell 916f625747SDouglas Raillard 9237c21657SVictor Chong cd ${BUILD_PATH}/l-loader 9337c21657SVictor Chong ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin 94a628b1abSHaojian Zhuang ln -sf ${EDK2_OUTPUT_DIR}/FV/bl2.bin 9537c21657SVictor Chong ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin 9637c21657SVictor Chong make hikey PTABLE_LST=aosp-8g 976f625747SDouglas Raillard 986f625747SDouglas RaillardSetup Console 996f625747SDouglas Raillard------------- 1006f625747SDouglas Raillard 1016f625747SDouglas Raillard- Install ser2net. Use telnet as the console since UEFI fails to display Boot Manager GUI in minicom. **If you don't need Boot Manager GUI, just ignore this section.** 1026f625747SDouglas Raillard 1036f625747SDouglas Raillard .. code:: shell 1046f625747SDouglas Raillard 1056f625747SDouglas Raillard $sudo apt-get install ser2net 1066f625747SDouglas Raillard 1076f625747SDouglas Raillard- Configure ser2net. 1086f625747SDouglas Raillard 1096f625747SDouglas Raillard .. code:: shell 1106f625747SDouglas Raillard 1116f625747SDouglas Raillard $sudo vi /etc/ser2net.conf 1126f625747SDouglas Raillard 1136f625747SDouglas Raillard Append one line for serial-over-USB in below. 1146f625747SDouglas Raillard *#ser2net.conf* 1156f625747SDouglas Raillard 1166f625747SDouglas Raillard .. code:: shell 1176f625747SDouglas Raillard 1186f625747SDouglas Raillard 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner 1196f625747SDouglas Raillard 120367456dfSVictor Chong- Start ser2net 121367456dfSVictor Chong 122367456dfSVictor Chong .. code:: shell 123367456dfSVictor Chong 124367456dfSVictor Chong $sudo killall ser2net 125367456dfSVictor Chong $sudo ser2net -u 126367456dfSVictor Chong 1276f625747SDouglas Raillard- Open the console. 1286f625747SDouglas Raillard 1296f625747SDouglas Raillard .. code:: shell 1306f625747SDouglas Raillard 1316f625747SDouglas Raillard $telnet localhost 2004 1326f625747SDouglas Raillard 1336f625747SDouglas Raillard And you could open the console remotely, too. 1346f625747SDouglas Raillard 135a87a1fb3SVictor ChongFlash images in recovery mode 1366f625747SDouglas Raillard----------------------------- 1376f625747SDouglas Raillard 1386f625747SDouglas Raillard- Make sure Pin3-Pin4 on J15 are connected for recovery mode. Then power on HiKey. 1396f625747SDouglas Raillard 1406f625747SDouglas Raillard- Remove the modemmanager package. This package may cause the idt tool failure. 1416f625747SDouglas Raillard 1426f625747SDouglas Raillard .. code:: shell 1436f625747SDouglas Raillard 1446f625747SDouglas Raillard $sudo apt-get purge modemmanager 1456f625747SDouglas Raillard 146a628b1abSHaojian Zhuang- Run the command to download recovery.bin into HiKey. 1476f625747SDouglas Raillard 1486f625747SDouglas Raillard .. code:: shell 1496f625747SDouglas Raillard 150a628b1abSHaojian Zhuang $sudo python hisi-idt.py -d /dev/ttyUSB1 --img1 recovery.bin 1516f625747SDouglas Raillard 152dd4e9a7dSPaul Beesley- Update images. All aosp or debian images could be fetched from `link <http://releases.linaro.org/96boards/>`__. 1536f625747SDouglas Raillard 1546f625747SDouglas Raillard .. code:: shell 1556f625747SDouglas Raillard 1566f625747SDouglas Raillard $sudo fastboot flash ptable prm_ptable.img 157a628b1abSHaojian Zhuang $sudo fastboot flash loader l-loader.bin 1586f625747SDouglas Raillard $sudo fastboot flash fastboot fip.bin 1596f625747SDouglas Raillard $sudo fastboot flash boot boot.img 1606f625747SDouglas Raillard $sudo fastboot flash cache cache.img 1616f625747SDouglas Raillard $sudo fastboot flash system system.img 1626f625747SDouglas Raillard $sudo fastboot flash userdata userdata.img 1636f625747SDouglas Raillard 1646f625747SDouglas RaillardBoot UEFI in normal mode 1656f625747SDouglas Raillard------------------------ 1666f625747SDouglas Raillard 1676f625747SDouglas Raillard- Make sure Pin3-Pin4 on J15 are open for normal boot mode. Then power on HiKey. 1686f625747SDouglas Raillard 1696f625747SDouglas Raillard- Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__ 1706f625747SDouglas Raillard 171dd4e9a7dSPaul Beesley.. _link: https://www.96boards.org/documentation/consumer/hikey/ 172