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