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