xref: /rk3399_ARM-atf/docs/plat/hikey960.rst (revision 37c21657ed290a694d3fcb4de2809c33f2b9cf5d)
16f625747SDouglas RaillardDescription
26f625747SDouglas Raillard===========
36f625747SDouglas Raillard
46f625747SDouglas RaillardHiKey960 is one of 96boards. Hisilicon Hi3660 processor is installed on HiKey960.
56f625747SDouglas Raillard
66f625747SDouglas RaillardMore information are listed in `link`_.
76f625747SDouglas Raillard
86f625747SDouglas RaillardHow to build
96f625747SDouglas Raillard============
106f625747SDouglas Raillard
116f625747SDouglas RaillardCode Locations
126f625747SDouglas Raillard--------------
136f625747SDouglas Raillard
146f625747SDouglas Raillard-  ARM Trusted Firmware:
156f625747SDouglas Raillard   `link <https://github.com/ARM-software/arm-trusted-firmware>`__
166f625747SDouglas Raillard
175e3325e7SVictor Chong-  OP-TEE:
185e3325e7SVictor Chong   `link <https://github.com/OP-TEE/optee_os>`__
195e3325e7SVictor Chong
206f625747SDouglas Raillard-  edk2:
216f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5>`__
226f625747SDouglas Raillard
236f625747SDouglas Raillard-  OpenPlatformPkg:
246f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/OpenPlatformPkg/tree/testing/hikey960_v1.3.4>`__
256f625747SDouglas Raillard
266f625747SDouglas Raillard-  l-loader:
276f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2>`__
286f625747SDouglas Raillard
296f625747SDouglas Raillard-  uefi-tools:
3042ba9f29SVictor Chong   `link <https://git.linaro.org/uefi/uefi-tools.git>`__
316f625747SDouglas Raillard
326f625747SDouglas RaillardBuild Procedure
336f625747SDouglas Raillard---------------
346f625747SDouglas Raillard
356f625747SDouglas Raillard-  Fetch all the above 5 repositories into local host.
366f625747SDouglas Raillard   Make all the repositories in the same ${BUILD\_PATH}.
376f625747SDouglas Raillard
38*37c21657SVictor Chong  .. code:: shell
39*37c21657SVictor Chong
40*37c21657SVictor Chong       git clone https://github.com/ARM-software/arm-trusted-firmware -b integration
41*37c21657SVictor Chong       git clone https://github.com/OP-TEE/optee_os
42*37c21657SVictor Chong       git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5
43*37c21657SVictor Chong       git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4
44*37c21657SVictor Chong       git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2
45*37c21657SVictor Chong       git clone https://git.linaro.org/uefi/uefi-tools
46*37c21657SVictor Chong
476f625747SDouglas Raillard-  Create the symbol link to OpenPlatformPkg in edk2.
486f625747SDouglas Raillard
496f625747SDouglas Raillard   .. code:: shell
506f625747SDouglas Raillard
516f625747SDouglas Raillard       $cd ${BUILD_PATH}/edk2
526f625747SDouglas Raillard       $ln -sf ../OpenPlatformPkg
536f625747SDouglas Raillard
546f625747SDouglas Raillard-  Prepare AARCH64 toolchain.
556f625747SDouglas Raillard
566f625747SDouglas Raillard-  If your hikey960 hardware is v1, update *uefi-tools/platform.config* first. *(optional)*
576f625747SDouglas Raillard   **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial
586f625747SDouglas Raillard   console on hikey960 v1.**
596f625747SDouglas Raillard
606f625747SDouglas Raillard   .. code:: shell
616f625747SDouglas Raillard
626f625747SDouglas Raillard       BUILDFLAGS=-DSERIAL_BASE=0xFDF05000
636f625747SDouglas Raillard
646f625747SDouglas Raillard   If your hikey960 hardware is v2 or newer, nothing to do.
656f625747SDouglas Raillard
666f625747SDouglas Raillard-  Build it as debug mode. Create script file for build.
676f625747SDouglas Raillard
686f625747SDouglas Raillard   .. code:: shell
696f625747SDouglas Raillard
706f625747SDouglas Raillard       BUILD_OPTION=DEBUG
7142ba9f29SVictor Chong       export AARCH64_TOOLCHAIN=GCC5
726f625747SDouglas Raillard       export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools
736f625747SDouglas Raillard       export EDK2_DIR=${BUILD_PATH}/edk2
746f625747SDouglas Raillard       EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey960/${BUILD_OPTION}_${AARCH64_TOOLCHAIN}
756f625747SDouglas Raillard       cd ${EDK2_DIR}
766f625747SDouglas Raillard       # Build UEFI & ARM Trust Firmware
775e3325e7SVictor Chong       ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey960
786f625747SDouglas Raillard
79*37c21657SVictor Chong-  Generate l-loader.bin and partition table.
806f625747SDouglas Raillard   *Make sure that you're using the sgdisk in the l-loader directory.*
816f625747SDouglas Raillard
826f625747SDouglas Raillard   .. code:: shell
836f625747SDouglas Raillard
84*37c21657SVictor Chong       cd ${BUILD_PATH}/l-loader
85*37c21657SVictor Chong       ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
86*37c21657SVictor Chong       ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin
87*37c21657SVictor Chong       ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd
88*37c21657SVictor Chong       make hikey960
896f625747SDouglas Raillard
906f625747SDouglas RaillardSetup Console
916f625747SDouglas Raillard-------------
926f625747SDouglas Raillard
936f625747SDouglas Raillard-  Install ser2net. Use telnet as the console since UEFI will output window
946f625747SDouglas Raillard   that fails to display in minicom.
956f625747SDouglas Raillard
966f625747SDouglas Raillard   .. code:: shell
976f625747SDouglas Raillard
986f625747SDouglas Raillard       $sudo apt-get install ser2net
996f625747SDouglas Raillard
1006f625747SDouglas Raillard-  Configure ser2net.
1016f625747SDouglas Raillard
1026f625747SDouglas Raillard   .. code:: shell
1036f625747SDouglas Raillard
1046f625747SDouglas Raillard       $sudo vi /etc/ser2net.conf
1056f625747SDouglas Raillard
1066f625747SDouglas Raillard   Append one line for serial-over-USB in *#ser2net.conf*
1076f625747SDouglas Raillard
1086f625747SDouglas Raillard   ::
1096f625747SDouglas Raillard
1106f625747SDouglas Raillard       2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
1116f625747SDouglas Raillard
11242ba9f29SVictor Chong-  Start ser2net
11342ba9f29SVictor Chong
11442ba9f29SVictor Chong   .. code:: shell
11542ba9f29SVictor Chong
11642ba9f29SVictor Chong       $sudo killall ser2net
11742ba9f29SVictor Chong       $sudo ser2net -u
11842ba9f29SVictor Chong
1196f625747SDouglas Raillard-  Open the console.
1206f625747SDouglas Raillard
1216f625747SDouglas Raillard   .. code:: shell
1226f625747SDouglas Raillard
1236f625747SDouglas Raillard       $telnet localhost 2004
1246f625747SDouglas Raillard
1256f625747SDouglas Raillard   And you could open the console remotely, too.
1266f625747SDouglas Raillard
1276f625747SDouglas RaillardBoot UEFI in recovery mode
1286f625747SDouglas Raillard--------------------------
1296f625747SDouglas Raillard
1306f625747SDouglas Raillard-  Fetch that are used in recovery mode. The code location is in below.
1316f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/tools-images-hikey960>`__
1326f625747SDouglas Raillard
1336f625747SDouglas Raillard-  Generate l-loader.bin.
1346f625747SDouglas Raillard
1356f625747SDouglas Raillard   .. code:: shell
1366f625747SDouglas Raillard
1376f625747SDouglas Raillard       $cd tools-images-hikey960
1386f625747SDouglas Raillard       $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin
139*37c21657SVictor Chong       $ln -sf ${BUILD_PATH}/l-loader/fip.bin
1406f625747SDouglas Raillard
1416f625747SDouglas Raillard-  Prepare config file.
1426f625747SDouglas Raillard
1436f625747SDouglas Raillard   .. code:: shell
1446f625747SDouglas Raillard
1456f625747SDouglas Raillard       $vi config
1466f625747SDouglas Raillard       # The content of config file
14742ba9f29SVictor Chong       ./sec_usb_xloader.img 0x00020000
1486f625747SDouglas Raillard       ./sec_uce_boot.img 0x6A908000
1496f625747SDouglas Raillard       ./l-loader.bin 0x1AC00000
1506f625747SDouglas Raillard
1516f625747SDouglas Raillard-  Remove the modemmanager package. This package may causes hikey\_idt tool failure.
1526f625747SDouglas Raillard
1536f625747SDouglas Raillard   .. code:: shell
1546f625747SDouglas Raillard
1556f625747SDouglas Raillard       $sudo apt-get purge modemmanager
1566f625747SDouglas Raillard
1576f625747SDouglas Raillard-  Run the command to download l-loader.bin into HiKey960.
1586f625747SDouglas Raillard
1596f625747SDouglas Raillard   .. code:: shell
1606f625747SDouglas Raillard
1616f625747SDouglas Raillard       $sudo ./hikey_idt -c config -p /dev/ttyUSB1
1626f625747SDouglas Raillard
1636f625747SDouglas Raillard-  UEFI running in recovery mode.
1646f625747SDouglas Raillard   When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running.
1656f625747SDouglas Raillard   The timeout of prompt '.' is 10 seconds.
1666f625747SDouglas Raillard
1676f625747SDouglas Raillard-  Update images.
1686f625747SDouglas Raillard
1696f625747SDouglas Raillard   .. code:: shell
1706f625747SDouglas Raillard
1716f625747SDouglas Raillard       $sudo fastboot flash ptable prm_ptable.img
1726f625747SDouglas Raillard       $sudo fastboot flash xloader sec_xloader.img
1736f625747SDouglas Raillard       $sudo fastboot flash fastboot l-loader.bin
1746f625747SDouglas Raillard       $sudo fastboot flash fip fip.bin
1756f625747SDouglas Raillard       $sudo fastboot flash boot boot.img
1766f625747SDouglas Raillard       $sudo fastboot flash cache cache.img
1776f625747SDouglas Raillard       $sudo fastboot flash system system.img
1786f625747SDouglas Raillard       $sudo fastboot flash userdata userdata.img
1796f625747SDouglas Raillard
1806f625747SDouglas Raillard-  Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in
1816f625747SDouglas Raillard   recovery mode.
1826f625747SDouglas Raillard
1836f625747SDouglas RaillardBoot UEFI in normal mode
1846f625747SDouglas Raillard------------------------
1856f625747SDouglas Raillard
1866f625747SDouglas Raillard-  Make sure "Boot Mode" switch is OFF for normal boot mode. Then power on HiKey960.
1876f625747SDouglas Raillard
1886f625747SDouglas Raillard-  Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__
1896f625747SDouglas Raillard
1906f625747SDouglas Raillard.. _link: http://www.96boards.org/documentation/ConsumerEdition/HiKey960/README.md
191