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