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