xref: /arm-trusted-firmware/docs/plat/hikey960.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluHiKey960
2*91f16700Schasinglulu========
3*91f16700Schasinglulu
4*91f16700SchasingluluHiKey960 is one of 96boards. Hisilicon Hi3660 processor is installed on HiKey960.
5*91f16700Schasinglulu
6*91f16700SchasingluluMore information are listed in `link`_.
7*91f16700Schasinglulu
8*91f16700SchasingluluHow to build
9*91f16700Schasinglulu------------
10*91f16700Schasinglulu
11*91f16700SchasingluluCode Locations
12*91f16700Schasinglulu~~~~~~~~~~~~~~
13*91f16700Schasinglulu
14*91f16700Schasinglulu-  Trusted Firmware-A:
15*91f16700Schasinglulu   `link <https://github.com/ARM-software/arm-trusted-firmware>`__
16*91f16700Schasinglulu
17*91f16700Schasinglulu-  OP-TEE:
18*91f16700Schasinglulu   `link <https://github.com/OP-TEE/optee_os>`__
19*91f16700Schasinglulu
20*91f16700Schasinglulu-  edk2:
21*91f16700Schasinglulu   `link <https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5>`__
22*91f16700Schasinglulu
23*91f16700Schasinglulu-  OpenPlatformPkg:
24*91f16700Schasinglulu   `link <https://github.com/96boards-hikey/OpenPlatformPkg/tree/testing/hikey960_v1.3.4>`__
25*91f16700Schasinglulu
26*91f16700Schasinglulu-  l-loader:
27*91f16700Schasinglulu   `link <https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2>`__
28*91f16700Schasinglulu
29*91f16700SchasingluluBuild Procedure
30*91f16700Schasinglulu~~~~~~~~~~~~~~~
31*91f16700Schasinglulu
32*91f16700Schasinglulu-  Fetch all the above 5 repositories into local host.
33*91f16700Schasinglulu   Make all the repositories in the same ${BUILD\_PATH}.
34*91f16700Schasinglulu
35*91f16700Schasinglulu  .. code:: shell
36*91f16700Schasinglulu
37*91f16700Schasinglulu       git clone https://github.com/ARM-software/arm-trusted-firmware -b integration
38*91f16700Schasinglulu       git clone https://github.com/OP-TEE/optee_os
39*91f16700Schasinglulu       git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5
40*91f16700Schasinglulu       git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4
41*91f16700Schasinglulu       git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2
42*91f16700Schasinglulu
43*91f16700Schasinglulu-  Create the symbol link to OpenPlatformPkg in edk2.
44*91f16700Schasinglulu
45*91f16700Schasinglulu   .. code:: shell
46*91f16700Schasinglulu
47*91f16700Schasinglulu       $cd ${BUILD_PATH}/edk2
48*91f16700Schasinglulu       $ln -sf ../OpenPlatformPkg
49*91f16700Schasinglulu
50*91f16700Schasinglulu-  Prepare AARCH64 toolchain.
51*91f16700Schasinglulu
52*91f16700Schasinglulu-  If your hikey960 hardware is v1, update *OpenPlatformPkg/Platforms/Hisilicon/HiKey960/HiKey960.dsc* first. *(optional)*
53*91f16700Schasinglulu
54*91f16700Schasinglulu   .. code:: shell
55*91f16700Schasinglulu
56*91f16700Schasinglulu       DEFINE SERIAL_BASE=0xFDF05000
57*91f16700Schasinglulu
58*91f16700Schasinglulu   If your hikey960 hardware is v2 or newer, nothing to do.
59*91f16700Schasinglulu
60*91f16700Schasinglulu-  Build it as debug mode. Create script file for build.
61*91f16700Schasinglulu
62*91f16700Schasinglulu   .. code:: shell
63*91f16700Schasinglulu
64*91f16700Schasinglulu       cd {BUILD_PATH}/arm-trusted-firmware
65*91f16700Schasinglulu       sh ../l-loader/build_uefi.sh hikey960
66*91f16700Schasinglulu
67*91f16700Schasinglulu-  Generate l-loader.bin and partition table.
68*91f16700Schasinglulu   *Make sure that you're using the sgdisk in the l-loader directory.*
69*91f16700Schasinglulu
70*91f16700Schasinglulu   .. code:: shell
71*91f16700Schasinglulu
72*91f16700Schasinglulu       cd ${BUILD_PATH}/l-loader
73*91f16700Schasinglulu       ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
74*91f16700Schasinglulu       ln -sf ${EDK2_OUTPUT_DIR}/FV/bl2.bin
75*91f16700Schasinglulu       ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin
76*91f16700Schasinglulu       ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd
77*91f16700Schasinglulu       make hikey960
78*91f16700Schasinglulu
79*91f16700SchasingluluSetup Console
80*91f16700Schasinglulu-------------
81*91f16700Schasinglulu
82*91f16700Schasinglulu-  Install ser2net. Use telnet as the console since UEFI will output window
83*91f16700Schasinglulu   that fails to display in minicom.
84*91f16700Schasinglulu
85*91f16700Schasinglulu   .. code:: shell
86*91f16700Schasinglulu
87*91f16700Schasinglulu       $sudo apt-get install ser2net
88*91f16700Schasinglulu
89*91f16700Schasinglulu-  Configure ser2net.
90*91f16700Schasinglulu
91*91f16700Schasinglulu   .. code:: shell
92*91f16700Schasinglulu
93*91f16700Schasinglulu       $sudo vi /etc/ser2net.conf
94*91f16700Schasinglulu
95*91f16700Schasinglulu   Append one line for serial-over-USB in *#ser2net.conf*
96*91f16700Schasinglulu
97*91f16700Schasinglulu   ::
98*91f16700Schasinglulu
99*91f16700Schasinglulu       2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
100*91f16700Schasinglulu
101*91f16700Schasinglulu-  Start ser2net
102*91f16700Schasinglulu
103*91f16700Schasinglulu   .. code:: shell
104*91f16700Schasinglulu
105*91f16700Schasinglulu       $sudo killall ser2net
106*91f16700Schasinglulu       $sudo ser2net -u
107*91f16700Schasinglulu
108*91f16700Schasinglulu-  Open the console.
109*91f16700Schasinglulu
110*91f16700Schasinglulu   .. code:: shell
111*91f16700Schasinglulu
112*91f16700Schasinglulu       $telnet localhost 2004
113*91f16700Schasinglulu
114*91f16700Schasinglulu   And you could open the console remotely, too.
115*91f16700Schasinglulu
116*91f16700SchasingluluBoot UEFI in recovery mode
117*91f16700Schasinglulu--------------------------
118*91f16700Schasinglulu
119*91f16700Schasinglulu-  Fetch that are used in recovery mode. The code location is in below.
120*91f16700Schasinglulu   `link <https://github.com/96boards-hikey/tools-images-hikey960>`__
121*91f16700Schasinglulu
122*91f16700Schasinglulu-  Prepare recovery binary.
123*91f16700Schasinglulu
124*91f16700Schasinglulu   .. code:: shell
125*91f16700Schasinglulu
126*91f16700Schasinglulu       $cd tools-images-hikey960
127*91f16700Schasinglulu       $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin
128*91f16700Schasinglulu       $ln -sf ${BUILD_PATH}/l-loader/fip.bin
129*91f16700Schasinglulu       $ln -sf ${BUILD_PATH}/l-loader/recovery.bin
130*91f16700Schasinglulu
131*91f16700Schasinglulu-  Prepare config file.
132*91f16700Schasinglulu
133*91f16700Schasinglulu   .. code:: shell
134*91f16700Schasinglulu
135*91f16700Schasinglulu       $vi config
136*91f16700Schasinglulu       # The content of config file
137*91f16700Schasinglulu       ./sec_usb_xloader.img 0x00020000
138*91f16700Schasinglulu       ./sec_uce_boot.img 0x6A908000
139*91f16700Schasinglulu       ./recovery.bin 0x1AC00000
140*91f16700Schasinglulu
141*91f16700Schasinglulu-  Remove the modemmanager package. This package may causes hikey\_idt tool failure.
142*91f16700Schasinglulu
143*91f16700Schasinglulu   .. code:: shell
144*91f16700Schasinglulu
145*91f16700Schasinglulu       $sudo apt-get purge modemmanager
146*91f16700Schasinglulu
147*91f16700Schasinglulu-  Run the command to download recovery.bin into HiKey960.
148*91f16700Schasinglulu
149*91f16700Schasinglulu   .. code:: shell
150*91f16700Schasinglulu
151*91f16700Schasinglulu       $sudo ./hikey_idt -c config -p /dev/ttyUSB1
152*91f16700Schasinglulu
153*91f16700Schasinglulu-  UEFI running in recovery mode.
154*91f16700Schasinglulu   When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running.
155*91f16700Schasinglulu   The timeout of prompt '.' is 10 seconds.
156*91f16700Schasinglulu
157*91f16700Schasinglulu-  Update images.
158*91f16700Schasinglulu
159*91f16700Schasinglulu   .. code:: shell
160*91f16700Schasinglulu
161*91f16700Schasinglulu       $sudo fastboot flash ptable prm_ptable.img
162*91f16700Schasinglulu       $sudo fastboot flash xloader sec_xloader.img
163*91f16700Schasinglulu       $sudo fastboot flash fastboot l-loader.bin
164*91f16700Schasinglulu       $sudo fastboot flash fip fip.bin
165*91f16700Schasinglulu       $sudo fastboot flash boot boot.img
166*91f16700Schasinglulu       $sudo fastboot flash cache cache.img
167*91f16700Schasinglulu       $sudo fastboot flash system system.img
168*91f16700Schasinglulu       $sudo fastboot flash userdata userdata.img
169*91f16700Schasinglulu
170*91f16700Schasinglulu-  Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in
171*91f16700Schasinglulu   recovery mode.
172*91f16700Schasinglulu
173*91f16700SchasingluluBoot UEFI in normal mode
174*91f16700Schasinglulu------------------------
175*91f16700Schasinglulu
176*91f16700Schasinglulu-  Make sure "Boot Mode" switch is OFF for normal boot mode. Then power on HiKey960.
177*91f16700Schasinglulu
178*91f16700Schasinglulu-  Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__
179*91f16700Schasinglulu
180*91f16700Schasinglulu.. _link: https://www.96boards.org/documentation/consumer/hikey/hikey960
181