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