blob: 027e14c7cb336b0ca796a0fd67ddfe3bff8ffaaf [file] [log] [blame]
Douglas Raillardd7c21b72017-06-28 15:23:03 +01001Description
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://github.com/96boards-hikey/uefi-tools/tree/testing/hikey960_v1>`__
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 ${EDK2_OUTPUT_DIR}/FV/fip.bin
78 ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin
79 python gen_loader.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd
80 arm-linux-gnueabihf-gcc -c -o start.o start.S
81 arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader
82 arm-linux-gnueabihf-objcopy -O binary loader temp
83 python gen_loader_hikey.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin --img_ns_bl1u=fastboot.bin
84
85- Generate partition table for aosp. The eMMC capacity is either 4GB or 8GB. Just change "aosp-4g" to "linux-4g" for debian.
86
87 .. code:: shell
88
89 $PTABLE=aosp-4g SECTOR_SIZE=512 bash -x generate_ptable.sh
90
91Setup Console
92-------------
93
94- 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.**
95
96 .. code:: shell
97
98 $sudo apt-get install ser2net
99
100- Configure ser2net.
101
102 .. code:: shell
103
104 $sudo vi /etc/ser2net.conf
105
106 Append one line for serial-over-USB in below.
107 *#ser2net.conf*
108
109 .. code:: shell
110
111 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
112
113- Open the console.
114
115 .. code:: shell
116
117 $telnet localhost 2004
118
119 And you could open the console remotely, too.
120
121Flush images in recovery mode
122-----------------------------
123
124- Make sure Pin3-Pin4 on J15 are connected for recovery mode. Then power on HiKey.
125
126- Remove the modemmanager package. This package may cause the idt tool failure.
127
128 .. code:: shell
129
130 $sudo apt-get purge modemmanager
131
132- Run the command to download l-loader.bin into HiKey.
133
134 .. code:: shell
135
136 $sudo python hisi-idt.py -d /dev/ttyUSB1 --img1 l-loader.bin
137
138- Update images. All aosp or debian images could be fetched from `link <https://builds.96boards.org/>`__.
139
140 .. code:: shell
141
142 $sudo fastboot flash ptable prm_ptable.img
143 $sudo fastboot flash fastboot fip.bin
144 $sudo fastboot flash boot boot.img
145 $sudo fastboot flash cache cache.img
146 $sudo fastboot flash system system.img
147 $sudo fastboot flash userdata userdata.img
148
149Boot UEFI in normal mode
150------------------------
151
152- Make sure Pin3-Pin4 on J15 are open for normal boot mode. Then power on HiKey.
153
154- Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__
155
156.. _link: https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/Quickstart/README.md