1Description 2=========== 3 4HiKey960 is one of 96boards. Hisilicon Hi3660 processor is installed on HiKey960. 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 29Build Procedure 30--------------- 31 32- Fetch all the above 5 repositories into local host. 33 Make all the repositories in the same ${BUILD\_PATH}. 34 35- Create the symbol link to OpenPlatformPkg in edk2. 36 37 .. code:: shell 38 39 $cd ${BUILD_PATH}/edk2 40 $ln -sf ../OpenPlatformPkg 41 42- Prepare AARCH64 toolchain. 43 44- If your hikey960 hardware is v1, update *uefi-tools/platform.config* first. *(optional)* 45 **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial 46 console on hikey960 v1.** 47 48 .. code:: shell 49 50 BUILDFLAGS=-DSERIAL_BASE=0xFDF05000 51 52 If your hikey960 hardware is v2 or newer, nothing to do. 53 54- Build it as debug mode. Create script file for build. 55 56 .. code:: shell 57 58 BUILD_OPTION=DEBUG 59 export AARCH64_TOOLCHAIN=GCC5 60 export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools 61 export EDK2_DIR=${BUILD_PATH}/edk2 62 EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey960/${BUILD_OPTION}_${AARCH64_TOOLCHAIN} 63 cd ${EDK2_DIR} 64 # Build UEFI & ARM Trust Firmware 65 ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware hikey960 66 # Generate l-loader.bin 67 cd ${BUILD_PATH}/l-loader 68 ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin 69 ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin 70 ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd 71 python gen_loader_hikey960.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd 72 73- Generate partition table. 74 *Make sure that you're using the sgdisk in the l-loader directory.* 75 76 .. code:: shell 77 78 PTABLE=aosp-32g SECTOR_SIZE=4096 SGDISK=./sgdisk bash -x generate_ptable.sh 79 80Setup Console 81------------- 82 83- Install ser2net. Use telnet as the console since UEFI will output window 84 that fails to display in minicom. 85 86 .. code:: shell 87 88 $sudo apt-get install ser2net 89 90- Configure ser2net. 91 92 .. code:: shell 93 94 $sudo vi /etc/ser2net.conf 95 96 Append one line for serial-over-USB in *#ser2net.conf* 97 98 :: 99 100 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner 101 102- Start ser2net 103 104 .. code:: shell 105 106 $sudo killall ser2net 107 $sudo ser2net -u 108 109- Open the console. 110 111 .. code:: shell 112 113 $telnet localhost 2004 114 115 And you could open the console remotely, too. 116 117Boot UEFI in recovery mode 118-------------------------- 119 120- Fetch that are used in recovery mode. The code location is in below. 121 `link <https://github.com/96boards-hikey/tools-images-hikey960>`__ 122 123- Generate l-loader.bin. 124 125 .. code:: shell 126 127 $cd tools-images-hikey960 128 $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin 129 130- Prepare config file. 131 132 .. code:: shell 133 134 $vi config 135 # The content of config file 136 ./sec_usb_xloader.img 0x00020000 137 ./sec_uce_boot.img 0x6A908000 138 ./l-loader.bin 0x1AC00000 139 140- Remove the modemmanager package. This package may causes hikey\_idt tool failure. 141 142 .. code:: shell 143 144 $sudo apt-get purge modemmanager 145 146- Run the command to download l-loader.bin into HiKey960. 147 148 .. code:: shell 149 150 $sudo ./hikey_idt -c config -p /dev/ttyUSB1 151 152- UEFI running in recovery mode. 153 When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running. 154 The timeout of prompt '.' is 10 seconds. 155 156- Update images. 157 158 .. code:: shell 159 160 $sudo fastboot flash ptable prm_ptable.img 161 $sudo fastboot flash xloader sec_xloader.img 162 $sudo fastboot flash fastboot l-loader.bin 163 $sudo fastboot flash fip fip.bin 164 $sudo fastboot flash boot boot.img 165 $sudo fastboot flash cache cache.img 166 $sudo fastboot flash system system.img 167 $sudo fastboot flash userdata userdata.img 168 169- Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in 170 recovery mode. 171 172Boot UEFI in normal mode 173------------------------ 174 175- Make sure "Boot Mode" switch is OFF for normal boot mode. Then power on HiKey960. 176 177- Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__ 178 179.. _link: http://www.96boards.org/documentation/ConsumerEdition/HiKey960/README.md 180