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