1*6f625747SDouglas RaillardDescription 2*6f625747SDouglas Raillard=========== 3*6f625747SDouglas Raillard 4*6f625747SDouglas RaillardHiKey is one of 96boards. Hisilicon Kirin6220 processor is installed on HiKey. 5*6f625747SDouglas Raillard 6*6f625747SDouglas RaillardMore information are listed in `link`_. 7*6f625747SDouglas Raillard 8*6f625747SDouglas RaillardHow to build 9*6f625747SDouglas Raillard============ 10*6f625747SDouglas Raillard 11*6f625747SDouglas RaillardCode Locations 12*6f625747SDouglas Raillard-------------- 13*6f625747SDouglas Raillard 14*6f625747SDouglas Raillard- ARM Trusted Firmware: 15*6f625747SDouglas Raillard `link <https://github.com/ARM-software/arm-trusted-firmware>`__ 16*6f625747SDouglas Raillard 17*6f625747SDouglas Raillard- edk2: 18*6f625747SDouglas Raillard `link <https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5>`__ 19*6f625747SDouglas Raillard 20*6f625747SDouglas Raillard- OpenPlatformPkg: 21*6f625747SDouglas Raillard `link <https://github.com/96boards-hikey/OpenPlatformPkg/tree/testing/hikey960_v1.3.4>`__ 22*6f625747SDouglas Raillard 23*6f625747SDouglas Raillard- l-loader: 24*6f625747SDouglas Raillard `link <https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2>`__ 25*6f625747SDouglas Raillard 26*6f625747SDouglas Raillard- uefi-tools: 27*6f625747SDouglas Raillard `link <https://github.com/96boards-hikey/uefi-tools/tree/testing/hikey960_v1>`__ 28*6f625747SDouglas Raillard 29*6f625747SDouglas Raillard- atf-fastboot: 30*6f625747SDouglas Raillard `link <https://github.com/96boards-hikey/atf-fastboot/tree/master>`__ 31*6f625747SDouglas Raillard 32*6f625747SDouglas RaillardBuild Procedure 33*6f625747SDouglas Raillard--------------- 34*6f625747SDouglas Raillard 35*6f625747SDouglas Raillard- Fetch all the above repositories into local host. 36*6f625747SDouglas Raillard Make all the repositories in the same ${BUILD\_PATH}. 37*6f625747SDouglas Raillard 38*6f625747SDouglas Raillard- Create the symbol link to OpenPlatformPkg in edk2. 39*6f625747SDouglas Raillard 40*6f625747SDouglas Raillard .. code:: shell 41*6f625747SDouglas Raillard 42*6f625747SDouglas Raillard $cd ${BUILD_PATH}/edk2 43*6f625747SDouglas Raillard $ln -sf ../OpenPlatformPkg 44*6f625747SDouglas Raillard 45*6f625747SDouglas Raillard- Prepare AARCH64 && AARCH32 toolchain. Prepare python. 46*6f625747SDouglas Raillard 47*6f625747SDouglas Raillard- If your hikey hardware is built by CircuitCo, update *uefi-tools/platform.config* first. *(optional)* 48*6f625747SDouglas Raillard **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial 49*6f625747SDouglas Raillard console on hikey.** 50*6f625747SDouglas Raillard 51*6f625747SDouglas Raillard .. code:: shell 52*6f625747SDouglas Raillard 53*6f625747SDouglas Raillard BUILDFLAGS=-DSERIAL_BASE=0xF8015000 54*6f625747SDouglas Raillard 55*6f625747SDouglas Raillard If your hikey hardware is built by LeMarker, nothing to do. 56*6f625747SDouglas Raillard 57*6f625747SDouglas 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. 58*6f625747SDouglas Raillard 59*6f625747SDouglas Raillard .. code:: shell 60*6f625747SDouglas Raillard 61*6f625747SDouglas Raillard BUILD_OPTION=DEBUG 62*6f625747SDouglas Raillard export AARCH64_TOOLCHAIN=GCC5 63*6f625747SDouglas Raillard export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools 64*6f625747SDouglas Raillard export EDK2_DIR=${BUILD_PATH}/edk2 65*6f625747SDouglas Raillard EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey/${BUILD_OPTION}_${AARCH64_TOOLCHAIN} 66*6f625747SDouglas Raillard # Build fastboot for ARM Trust Firmware. It's used for recovery mode. 67*6f625747SDouglas Raillard cd ${BUILD_PATH}/atf-fastboot 68*6f625747SDouglas Raillard CROSS_COMPILE=aarch64-linux-gnu- make PLAT=hikey DEBUG=1 69*6f625747SDouglas Raillard # Convert DEBUG/RELEASE to debug/release 70*6f625747SDouglas Raillard FASTBOOT_BUILD_OPTION=$(echo ${BUILD_OPTION} | tr '[A-Z]' '[a-z]') 71*6f625747SDouglas Raillard cd ${EDK2_DIR} 72*6f625747SDouglas Raillard # Build UEFI & ARM Trust Firmware 73*6f625747SDouglas Raillard ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware hikey 74*6f625747SDouglas Raillard # Generate l-loader.bin 75*6f625747SDouglas Raillard cd ${BUILD_PATH}/l-loader 76*6f625747SDouglas Raillard ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin 77*6f625747SDouglas Raillard ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin 78*6f625747SDouglas Raillard ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin 79*6f625747SDouglas Raillard python gen_loader.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd 80*6f625747SDouglas Raillard arm-linux-gnueabihf-gcc -c -o start.o start.S 81*6f625747SDouglas Raillard arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader 82*6f625747SDouglas Raillard arm-linux-gnueabihf-objcopy -O binary loader temp 83*6f625747SDouglas Raillard python gen_loader_hikey.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin --img_ns_bl1u=fastboot.bin 84*6f625747SDouglas Raillard 85*6f625747SDouglas Raillard- Generate partition table for aosp. The eMMC capacity is either 4GB or 8GB. Just change "aosp-4g" to "linux-4g" for debian. 86*6f625747SDouglas Raillard 87*6f625747SDouglas Raillard .. code:: shell 88*6f625747SDouglas Raillard 89*6f625747SDouglas Raillard $PTABLE=aosp-4g SECTOR_SIZE=512 bash -x generate_ptable.sh 90*6f625747SDouglas Raillard 91*6f625747SDouglas RaillardSetup Console 92*6f625747SDouglas Raillard------------- 93*6f625747SDouglas Raillard 94*6f625747SDouglas 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.** 95*6f625747SDouglas Raillard 96*6f625747SDouglas Raillard .. code:: shell 97*6f625747SDouglas Raillard 98*6f625747SDouglas Raillard $sudo apt-get install ser2net 99*6f625747SDouglas Raillard 100*6f625747SDouglas Raillard- Configure ser2net. 101*6f625747SDouglas Raillard 102*6f625747SDouglas Raillard .. code:: shell 103*6f625747SDouglas Raillard 104*6f625747SDouglas Raillard $sudo vi /etc/ser2net.conf 105*6f625747SDouglas Raillard 106*6f625747SDouglas Raillard Append one line for serial-over-USB in below. 107*6f625747SDouglas Raillard *#ser2net.conf* 108*6f625747SDouglas Raillard 109*6f625747SDouglas Raillard .. code:: shell 110*6f625747SDouglas Raillard 111*6f625747SDouglas Raillard 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner 112*6f625747SDouglas Raillard 113*6f625747SDouglas Raillard- Open the console. 114*6f625747SDouglas Raillard 115*6f625747SDouglas Raillard .. code:: shell 116*6f625747SDouglas Raillard 117*6f625747SDouglas Raillard $telnet localhost 2004 118*6f625747SDouglas Raillard 119*6f625747SDouglas Raillard And you could open the console remotely, too. 120*6f625747SDouglas Raillard 121*6f625747SDouglas RaillardFlush images in recovery mode 122*6f625747SDouglas Raillard----------------------------- 123*6f625747SDouglas Raillard 124*6f625747SDouglas Raillard- Make sure Pin3-Pin4 on J15 are connected for recovery mode. Then power on HiKey. 125*6f625747SDouglas Raillard 126*6f625747SDouglas Raillard- Remove the modemmanager package. This package may cause the idt tool failure. 127*6f625747SDouglas Raillard 128*6f625747SDouglas Raillard .. code:: shell 129*6f625747SDouglas Raillard 130*6f625747SDouglas Raillard $sudo apt-get purge modemmanager 131*6f625747SDouglas Raillard 132*6f625747SDouglas Raillard- Run the command to download l-loader.bin into HiKey. 133*6f625747SDouglas Raillard 134*6f625747SDouglas Raillard .. code:: shell 135*6f625747SDouglas Raillard 136*6f625747SDouglas Raillard $sudo python hisi-idt.py -d /dev/ttyUSB1 --img1 l-loader.bin 137*6f625747SDouglas Raillard 138*6f625747SDouglas Raillard- Update images. All aosp or debian images could be fetched from `link <https://builds.96boards.org/>`__. 139*6f625747SDouglas Raillard 140*6f625747SDouglas Raillard .. code:: shell 141*6f625747SDouglas Raillard 142*6f625747SDouglas Raillard $sudo fastboot flash ptable prm_ptable.img 143*6f625747SDouglas Raillard $sudo fastboot flash fastboot fip.bin 144*6f625747SDouglas Raillard $sudo fastboot flash boot boot.img 145*6f625747SDouglas Raillard $sudo fastboot flash cache cache.img 146*6f625747SDouglas Raillard $sudo fastboot flash system system.img 147*6f625747SDouglas Raillard $sudo fastboot flash userdata userdata.img 148*6f625747SDouglas Raillard 149*6f625747SDouglas RaillardBoot UEFI in normal mode 150*6f625747SDouglas Raillard------------------------ 151*6f625747SDouglas Raillard 152*6f625747SDouglas Raillard- Make sure Pin3-Pin4 on J15 are open for normal boot mode. Then power on HiKey. 153*6f625747SDouglas Raillard 154*6f625747SDouglas Raillard- Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__ 155*6f625747SDouglas Raillard 156*6f625747SDouglas Raillard.. _link: https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/Quickstart/README.md 157