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