xref: /rk3399_ARM-atf/docs/plat/hikey.rst (revision a87a1fb3ede3fa2361ae4efd08d6daa30dc8c00b)
16f625747SDouglas RaillardDescription
26f625747SDouglas Raillard===========
36f625747SDouglas Raillard
46f625747SDouglas RaillardHiKey is one of 96boards. Hisilicon Kirin6220 processor is installed on HiKey.
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
173b6e88a2SVictor Chong-  OP-TEE
183b6e88a2SVictor Chong   `link <https://github.com/OP-TEE/optee_os>`__
193b6e88a2SVictor 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:
30367456dfSVictor Chong   `link <https://git.linaro.org/uefi/uefi-tools.git>`__
316f625747SDouglas Raillard
326f625747SDouglas Raillard-  atf-fastboot:
336f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/atf-fastboot/tree/master>`__
346f625747SDouglas Raillard
356f625747SDouglas RaillardBuild Procedure
366f625747SDouglas Raillard---------------
376f625747SDouglas Raillard
386f625747SDouglas Raillard-  Fetch all the above repositories into local host.
396f625747SDouglas Raillard   Make all the repositories in the same ${BUILD\_PATH}.
406f625747SDouglas Raillard
416f625747SDouglas Raillard-  Create the symbol link to OpenPlatformPkg in edk2.
426f625747SDouglas Raillard
436f625747SDouglas Raillard   .. code:: shell
446f625747SDouglas Raillard
456f625747SDouglas Raillard       $cd ${BUILD_PATH}/edk2
466f625747SDouglas Raillard       $ln -sf ../OpenPlatformPkg
476f625747SDouglas Raillard
486f625747SDouglas Raillard-  Prepare AARCH64 && AARCH32 toolchain. Prepare python.
496f625747SDouglas Raillard
506f625747SDouglas Raillard-  If your hikey hardware is built by CircuitCo, update *uefi-tools/platform.config* first. *(optional)*
516f625747SDouglas Raillard   **Uncomment the below sentence. Otherwise, UEFI can't output messages on serial
526f625747SDouglas Raillard   console on hikey.**
536f625747SDouglas Raillard
546f625747SDouglas Raillard   .. code:: shell
556f625747SDouglas Raillard
566f625747SDouglas Raillard       BUILDFLAGS=-DSERIAL_BASE=0xF8015000
576f625747SDouglas Raillard
586f625747SDouglas Raillard   If your hikey hardware is built by LeMarker, nothing to do.
596f625747SDouglas Raillard
606f625747SDouglas Raillard-  Build it as debug mode. Create your own build script file or you could refer to **build\_uefi.sh** in l-loader git repository.
616f625747SDouglas Raillard
626f625747SDouglas Raillard   .. code:: shell
636f625747SDouglas Raillard
646f625747SDouglas Raillard       BUILD_OPTION=DEBUG
656f625747SDouglas Raillard       export AARCH64_TOOLCHAIN=GCC5
666f625747SDouglas Raillard       export UEFI_TOOLS_DIR=${BUILD_PATH}/uefi-tools
676f625747SDouglas Raillard       export EDK2_DIR=${BUILD_PATH}/edk2
686f625747SDouglas Raillard       EDK2_OUTPUT_DIR=${EDK2_DIR}/Build/HiKey/${BUILD_OPTION}_${AARCH64_TOOLCHAIN}
696f625747SDouglas Raillard       # Build fastboot for ARM Trust Firmware. It's used for recovery mode.
706f625747SDouglas Raillard       cd ${BUILD_PATH}/atf-fastboot
716f625747SDouglas Raillard       CROSS_COMPILE=aarch64-linux-gnu- make PLAT=hikey DEBUG=1
726f625747SDouglas Raillard       # Convert DEBUG/RELEASE to debug/release
736f625747SDouglas Raillard       FASTBOOT_BUILD_OPTION=$(echo ${BUILD_OPTION} | tr '[A-Z]' '[a-z]')
746f625747SDouglas Raillard       cd ${EDK2_DIR}
756f625747SDouglas Raillard       # Build UEFI & ARM Trust Firmware
763b6e88a2SVictor Chong       ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey
776f625747SDouglas Raillard       # Generate l-loader.bin
786f625747SDouglas Raillard       cd ${BUILD_PATH}/l-loader
796f625747SDouglas Raillard       ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
806f625747SDouglas Raillard       ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin
816f625747SDouglas Raillard       arm-linux-gnueabihf-gcc -c -o start.o start.S
826f625747SDouglas Raillard       arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader
836f625747SDouglas Raillard       arm-linux-gnueabihf-objcopy -O binary loader temp
846f625747SDouglas Raillard       python gen_loader_hikey.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin --img_ns_bl1u=fastboot.bin
856f625747SDouglas Raillard
866f625747SDouglas Raillard-  Generate partition table for aosp. The eMMC capacity is either 4GB or 8GB. Just change "aosp-4g" to "linux-4g" for debian.
876f625747SDouglas Raillard
886f625747SDouglas Raillard   .. code:: shell
896f625747SDouglas Raillard
90367456dfSVictor Chong       PTABLE=aosp-4g SECTOR_SIZE=512 bash -x generate_ptable.sh
916f625747SDouglas Raillard
926f625747SDouglas RaillardSetup Console
936f625747SDouglas Raillard-------------
946f625747SDouglas Raillard
956f625747SDouglas Raillard-  Install ser2net. Use telnet as the console since UEFI fails to display Boot Manager GUI in minicom. **If you don't need Boot Manager GUI, just ignore this section.**
966f625747SDouglas Raillard
976f625747SDouglas Raillard   .. code:: shell
986f625747SDouglas Raillard
996f625747SDouglas Raillard       $sudo apt-get install ser2net
1006f625747SDouglas Raillard
1016f625747SDouglas Raillard-  Configure ser2net.
1026f625747SDouglas Raillard
1036f625747SDouglas Raillard   .. code:: shell
1046f625747SDouglas Raillard
1056f625747SDouglas Raillard       $sudo vi /etc/ser2net.conf
1066f625747SDouglas Raillard
1076f625747SDouglas Raillard   Append one line for serial-over-USB in below.
1086f625747SDouglas Raillard   *#ser2net.conf*
1096f625747SDouglas Raillard
1106f625747SDouglas Raillard   .. code:: shell
1116f625747SDouglas Raillard
1126f625747SDouglas Raillard       2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
1136f625747SDouglas Raillard
114367456dfSVictor Chong-  Start ser2net
115367456dfSVictor Chong
116367456dfSVictor Chong   .. code:: shell
117367456dfSVictor Chong
118367456dfSVictor Chong       $sudo killall ser2net
119367456dfSVictor Chong       $sudo ser2net -u
120367456dfSVictor Chong
1216f625747SDouglas Raillard-  Open the console.
1226f625747SDouglas Raillard
1236f625747SDouglas Raillard   .. code:: shell
1246f625747SDouglas Raillard
1256f625747SDouglas Raillard       $telnet localhost 2004
1266f625747SDouglas Raillard
1276f625747SDouglas Raillard   And you could open the console remotely, too.
1286f625747SDouglas Raillard
129*a87a1fb3SVictor ChongFlash images in recovery mode
1306f625747SDouglas Raillard-----------------------------
1316f625747SDouglas Raillard
1326f625747SDouglas Raillard-  Make sure Pin3-Pin4 on J15 are connected for recovery mode. Then power on HiKey.
1336f625747SDouglas Raillard
1346f625747SDouglas Raillard-  Remove the modemmanager package. This package may cause the idt tool failure.
1356f625747SDouglas Raillard
1366f625747SDouglas Raillard   .. code:: shell
1376f625747SDouglas Raillard
1386f625747SDouglas Raillard       $sudo apt-get purge modemmanager
1396f625747SDouglas Raillard
1406f625747SDouglas Raillard-  Run the command to download l-loader.bin into HiKey.
1416f625747SDouglas Raillard
1426f625747SDouglas Raillard   .. code:: shell
1436f625747SDouglas Raillard
1446f625747SDouglas Raillard       $sudo python hisi-idt.py -d /dev/ttyUSB1 --img1 l-loader.bin
1456f625747SDouglas Raillard
1466f625747SDouglas Raillard-  Update images. All aosp or debian images could be fetched from `link <https://builds.96boards.org/>`__.
1476f625747SDouglas Raillard
1486f625747SDouglas Raillard   .. code:: shell
1496f625747SDouglas Raillard
1506f625747SDouglas Raillard       $sudo fastboot flash ptable prm_ptable.img
1516f625747SDouglas Raillard       $sudo fastboot flash fastboot fip.bin
1526f625747SDouglas Raillard       $sudo fastboot flash boot boot.img
1536f625747SDouglas Raillard       $sudo fastboot flash cache cache.img
1546f625747SDouglas Raillard       $sudo fastboot flash system system.img
1556f625747SDouglas Raillard       $sudo  fastboot flash userdata userdata.img
1566f625747SDouglas Raillard
1576f625747SDouglas RaillardBoot UEFI in normal mode
1586f625747SDouglas Raillard------------------------
1596f625747SDouglas Raillard
1606f625747SDouglas Raillard-  Make sure Pin3-Pin4 on J15 are open for normal boot mode. Then power on HiKey.
1616f625747SDouglas Raillard
1626f625747SDouglas Raillard-  Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__
1636f625747SDouglas Raillard
1646f625747SDouglas Raillard.. _link: https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/Quickstart/README.md
165