xref: /rk3399_ARM-atf/docs/plat/hikey960.rst (revision 5e3325e73c0aca2934982cb10b881064d9b657f1)
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
17*5e3325e7SVictor Chong-  OP-TEE:
18*5e3325e7SVictor Chong   `link <https://github.com/OP-TEE/optee_os>`__
19*5e3325e7SVictor 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
386f625747SDouglas Raillard-  Create the symbol link to OpenPlatformPkg in edk2.
396f625747SDouglas Raillard
406f625747SDouglas Raillard   .. code:: shell
416f625747SDouglas Raillard
426f625747SDouglas Raillard       $cd ${BUILD_PATH}/edk2
436f625747SDouglas Raillard       $ln -sf ../OpenPlatformPkg
446f625747SDouglas Raillard
456f625747SDouglas Raillard-  Prepare AARCH64 toolchain.
466f625747SDouglas Raillard
476f625747SDouglas Raillard-  If your hikey960 hardware is v1, update *uefi-tools/platform.config* first. *(optional)*
486f625747SDouglas Raillard   **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial
496f625747SDouglas Raillard   console on hikey960 v1.**
506f625747SDouglas Raillard
516f625747SDouglas Raillard   .. code:: shell
526f625747SDouglas Raillard
536f625747SDouglas Raillard       BUILDFLAGS=-DSERIAL_BASE=0xFDF05000
546f625747SDouglas Raillard
556f625747SDouglas Raillard   If your hikey960 hardware is v2 or newer, nothing to do.
566f625747SDouglas Raillard
576f625747SDouglas Raillard-  Build it as debug mode. Create script file for build.
586f625747SDouglas Raillard
596f625747SDouglas Raillard   .. code:: shell
606f625747SDouglas Raillard
616f625747SDouglas Raillard       BUILD_OPTION=DEBUG
6242ba9f29SVictor Chong       export AARCH64_TOOLCHAIN=GCC5
636f625747SDouglas Raillard       export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools
646f625747SDouglas Raillard       export EDK2_DIR=${BUILD_PATH}/edk2
656f625747SDouglas Raillard       EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey960/${BUILD_OPTION}_${AARCH64_TOOLCHAIN}
666f625747SDouglas Raillard       cd ${EDK2_DIR}
676f625747SDouglas Raillard       # Build UEFI & ARM Trust Firmware
68*5e3325e7SVictor Chong       ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey960
696f625747SDouglas Raillard       # Generate l-loader.bin
706f625747SDouglas Raillard       cd ${BUILD_PATH}/l-loader
716f625747SDouglas Raillard       ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
726f625747SDouglas Raillard       ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin
736f625747SDouglas Raillard       ln -sf ${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd
7442ba9f29SVictor Chong       python gen_loader_hikey960.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd
756f625747SDouglas Raillard
766f625747SDouglas Raillard-  Generate partition table.
776f625747SDouglas Raillard   *Make sure that you're using the sgdisk in the l-loader directory.*
786f625747SDouglas Raillard
796f625747SDouglas Raillard   .. code:: shell
806f625747SDouglas Raillard
8142ba9f29SVictor Chong       PTABLE=aosp-32g SECTOR_SIZE=4096 SGDISK=./sgdisk bash -x generate_ptable.sh
826f625747SDouglas Raillard
836f625747SDouglas RaillardSetup Console
846f625747SDouglas Raillard-------------
856f625747SDouglas Raillard
866f625747SDouglas Raillard-  Install ser2net. Use telnet as the console since UEFI will output window
876f625747SDouglas Raillard   that fails to display in minicom.
886f625747SDouglas Raillard
896f625747SDouglas Raillard   .. code:: shell
906f625747SDouglas Raillard
916f625747SDouglas Raillard       $sudo apt-get install ser2net
926f625747SDouglas Raillard
936f625747SDouglas Raillard-  Configure ser2net.
946f625747SDouglas Raillard
956f625747SDouglas Raillard   .. code:: shell
966f625747SDouglas Raillard
976f625747SDouglas Raillard       $sudo vi /etc/ser2net.conf
986f625747SDouglas Raillard
996f625747SDouglas Raillard   Append one line for serial-over-USB in *#ser2net.conf*
1006f625747SDouglas Raillard
1016f625747SDouglas Raillard   ::
1026f625747SDouglas Raillard
1036f625747SDouglas Raillard       2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
1046f625747SDouglas Raillard
10542ba9f29SVictor Chong-  Start ser2net
10642ba9f29SVictor Chong
10742ba9f29SVictor Chong   .. code:: shell
10842ba9f29SVictor Chong
10942ba9f29SVictor Chong       $sudo killall ser2net
11042ba9f29SVictor Chong       $sudo ser2net -u
11142ba9f29SVictor Chong
1126f625747SDouglas Raillard-  Open the console.
1136f625747SDouglas Raillard
1146f625747SDouglas Raillard   .. code:: shell
1156f625747SDouglas Raillard
1166f625747SDouglas Raillard       $telnet localhost 2004
1176f625747SDouglas Raillard
1186f625747SDouglas Raillard   And you could open the console remotely, too.
1196f625747SDouglas Raillard
1206f625747SDouglas RaillardBoot UEFI in recovery mode
1216f625747SDouglas Raillard--------------------------
1226f625747SDouglas Raillard
1236f625747SDouglas Raillard-  Fetch that are used in recovery mode. The code location is in below.
1246f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/tools-images-hikey960>`__
1256f625747SDouglas Raillard
1266f625747SDouglas Raillard-  Generate l-loader.bin.
1276f625747SDouglas Raillard
1286f625747SDouglas Raillard   .. code:: shell
1296f625747SDouglas Raillard
1306f625747SDouglas Raillard       $cd tools-images-hikey960
1316f625747SDouglas Raillard       $ln -sf ${BUILD_PATH}/l-loader/l-loader.bin
1326f625747SDouglas Raillard
1336f625747SDouglas Raillard-  Prepare config file.
1346f625747SDouglas Raillard
1356f625747SDouglas Raillard   .. code:: shell
1366f625747SDouglas Raillard
1376f625747SDouglas Raillard       $vi config
1386f625747SDouglas Raillard       # The content of config file
13942ba9f29SVictor Chong       ./sec_usb_xloader.img 0x00020000
1406f625747SDouglas Raillard       ./sec_uce_boot.img 0x6A908000
1416f625747SDouglas Raillard       ./l-loader.bin 0x1AC00000
1426f625747SDouglas Raillard
1436f625747SDouglas Raillard-  Remove the modemmanager package. This package may causes hikey\_idt tool failure.
1446f625747SDouglas Raillard
1456f625747SDouglas Raillard   .. code:: shell
1466f625747SDouglas Raillard
1476f625747SDouglas Raillard       $sudo apt-get purge modemmanager
1486f625747SDouglas Raillard
1496f625747SDouglas Raillard-  Run the command to download l-loader.bin into HiKey960.
1506f625747SDouglas Raillard
1516f625747SDouglas Raillard   .. code:: shell
1526f625747SDouglas Raillard
1536f625747SDouglas Raillard       $sudo ./hikey_idt -c config -p /dev/ttyUSB1
1546f625747SDouglas Raillard
1556f625747SDouglas Raillard-  UEFI running in recovery mode.
1566f625747SDouglas Raillard   When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running.
1576f625747SDouglas Raillard   The timeout of prompt '.' is 10 seconds.
1586f625747SDouglas Raillard
1596f625747SDouglas Raillard-  Update images.
1606f625747SDouglas Raillard
1616f625747SDouglas Raillard   .. code:: shell
1626f625747SDouglas Raillard
1636f625747SDouglas Raillard       $sudo fastboot flash ptable prm_ptable.img
1646f625747SDouglas Raillard       $sudo fastboot flash xloader sec_xloader.img
1656f625747SDouglas Raillard       $sudo fastboot flash fastboot l-loader.bin
1666f625747SDouglas Raillard       $sudo fastboot flash fip fip.bin
1676f625747SDouglas Raillard       $sudo fastboot flash boot boot.img
1686f625747SDouglas Raillard       $sudo fastboot flash cache cache.img
1696f625747SDouglas Raillard       $sudo fastboot flash system system.img
1706f625747SDouglas Raillard       $sudo fastboot flash userdata userdata.img
1716f625747SDouglas Raillard
1726f625747SDouglas Raillard-  Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in
1736f625747SDouglas Raillard   recovery mode.
1746f625747SDouglas Raillard
1756f625747SDouglas RaillardBoot UEFI in normal mode
1766f625747SDouglas Raillard------------------------
1776f625747SDouglas Raillard
1786f625747SDouglas Raillard-  Make sure "Boot Mode" switch is OFF for normal boot mode. Then power on HiKey960.
1796f625747SDouglas Raillard
1806f625747SDouglas Raillard-  Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__
1816f625747SDouglas Raillard
1826f625747SDouglas Raillard.. _link: http://www.96boards.org/documentation/ConsumerEdition/HiKey960/README.md
183