Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 1 | Description |
| 2 | =========== |
| 3 | |
| 4 | HiKey960 is one of 96boards. Hisilicon Hi3660 processor is installed on HiKey960. |
| 5 | |
| 6 | More information are listed in `link`_. |
| 7 | |
| 8 | How to build |
| 9 | ============ |
| 10 | |
| 11 | Code Locations |
| 12 | -------------- |
| 13 | |
Dan Handley | 610e7e1 | 2018-03-01 18:44:00 +0000 | [diff] [blame] | 14 | - Trusted Firmware-A: |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 15 | `link <https://github.com/ARM-software/arm-trusted-firmware>`__ |
| 16 | |
Victor Chong | 9128768 | 2017-05-28 00:14:37 +0900 | [diff] [blame] | 17 | - OP-TEE: |
| 18 | `link <https://github.com/OP-TEE/optee_os>`__ |
| 19 | |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 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: |
Victor Chong | 1acb3e1 | 2017-07-11 23:48:39 +0900 | [diff] [blame] | 30 | `link <https://git.linaro.org/uefi/uefi-tools.git>`__ |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 31 | |
| 32 | Build Procedure |
| 33 | --------------- |
| 34 | |
| 35 | - Fetch all the above 5 repositories into local host. |
| 36 | Make all the repositories in the same ${BUILD\_PATH}. |
| 37 | |
Victor Chong | 7f47e74 | 2017-09-29 19:56:39 +0100 | [diff] [blame] | 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 | |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 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 |
Victor Chong | 1acb3e1 | 2017-07-11 23:48:39 +0900 | [diff] [blame] | 71 | export AARCH64_TOOLCHAIN=GCC5 |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 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} |
Dan Handley | 610e7e1 | 2018-03-01 18:44:00 +0000 | [diff] [blame] | 76 | # Build UEFI & Trusted Firmware-A |
Victor Chong | 9128768 | 2017-05-28 00:14:37 +0900 | [diff] [blame] | 77 | ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey960 |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 78 | |
Victor Chong | 7f47e74 | 2017-09-29 19:56:39 +0100 | [diff] [blame] | 79 | - Generate l-loader.bin and partition table. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 80 | *Make sure that you're using the sgdisk in the l-loader directory.* |
| 81 | |
| 82 | .. code:: shell |
| 83 | |
Victor Chong | 7f47e74 | 2017-09-29 19:56:39 +0100 | [diff] [blame] | 84 | cd ${BUILD_PATH}/l-loader |
| 85 | ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 86 | ln -sf ${EDK2_OUTPUT_DIR}/FV/bl2.bin |
Victor Chong | 7f47e74 | 2017-09-29 19:56:39 +0100 | [diff] [blame] | 87 | ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin |
| 88 | ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd |
| 89 | make hikey960 |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 90 | |
| 91 | Setup 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 | |
Victor Chong | 1acb3e1 | 2017-07-11 23:48:39 +0900 | [diff] [blame] | 113 | - Start ser2net |
| 114 | |
| 115 | .. code:: shell |
| 116 | |
| 117 | $sudo killall ser2net |
| 118 | $sudo ser2net -u |
| 119 | |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 120 | - Open the console. |
| 121 | |
| 122 | .. code:: shell |
| 123 | |
| 124 | $telnet localhost 2004 |
| 125 | |
| 126 | And you could open the console remotely, too. |
| 127 | |
| 128 | Boot 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 | |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 134 | - Prepare recovery binary. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 135 | |
| 136 | .. code:: shell |
| 137 | |
| 138 | $cd tools-images-hikey960 |
| 139 | $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin |
Victor Chong | 7f47e74 | 2017-09-29 19:56:39 +0100 | [diff] [blame] | 140 | $ln -sf ${BUILD_PATH}/l-loader/fip.bin |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 141 | $ln -sf ${BUILD_PATH}/l-loader/recovery.bin |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 142 | |
| 143 | - Prepare config file. |
| 144 | |
| 145 | .. code:: shell |
| 146 | |
| 147 | $vi config |
| 148 | # The content of config file |
Victor Chong | 1acb3e1 | 2017-07-11 23:48:39 +0900 | [diff] [blame] | 149 | ./sec_usb_xloader.img 0x00020000 |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 150 | ./sec_uce_boot.img 0x6A908000 |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 151 | ./recovery.bin 0x1AC00000 |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 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 | |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 159 | - Run the command to download recovery.bin into HiKey960. |
Douglas Raillard | d7c21b7 | 2017-06-28 15:23:03 +0100 | [diff] [blame] | 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 | |
| 185 | Boot 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: http://www.96boards.org/documentation/ConsumerEdition/HiKey960/README.md |