xref: /rk3399_ARM-atf/docs/plat/hikey.rst (revision 367456df1697326ff7085381debf7b811c5b8cb7)
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
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*367456dfSVictor Chong   `link <https://git.linaro.org/uefi/uefi-tools.git>`__
286f625747SDouglas Raillard
296f625747SDouglas Raillard-  atf-fastboot:
306f625747SDouglas Raillard   `link <https://github.com/96boards-hikey/atf-fastboot/tree/master>`__
316f625747SDouglas Raillard
326f625747SDouglas RaillardBuild Procedure
336f625747SDouglas Raillard---------------
346f625747SDouglas Raillard
356f625747SDouglas Raillard-  Fetch all the above 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 && AARCH32 toolchain. Prepare python.
466f625747SDouglas Raillard
476f625747SDouglas Raillard-  If your hikey hardware is built by CircuitCo, 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 hikey.**
506f625747SDouglas Raillard
516f625747SDouglas Raillard   .. code:: shell
526f625747SDouglas Raillard
536f625747SDouglas Raillard       BUILDFLAGS=-DSERIAL_BASE=0xF8015000
546f625747SDouglas Raillard
556f625747SDouglas Raillard   If your hikey hardware is built by LeMarker, nothing to do.
566f625747SDouglas Raillard
576f625747SDouglas 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.
586f625747SDouglas Raillard
596f625747SDouglas Raillard   .. code:: shell
606f625747SDouglas Raillard
616f625747SDouglas Raillard       BUILD_OPTION=DEBUG
626f625747SDouglas Raillard       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/HiKey/${BUILD_OPTION}_${AARCH64_TOOLCHAIN}
666f625747SDouglas Raillard       # Build fastboot for ARM Trust Firmware. It's used for recovery mode.
676f625747SDouglas Raillard       cd ${BUILD_PATH}/atf-fastboot
686f625747SDouglas Raillard       CROSS_COMPILE=aarch64-linux-gnu- make PLAT=hikey DEBUG=1
696f625747SDouglas Raillard       # Convert DEBUG/RELEASE to debug/release
706f625747SDouglas Raillard       FASTBOOT_BUILD_OPTION=$(echo ${BUILD_OPTION} | tr '[A-Z]' '[a-z]')
716f625747SDouglas Raillard       cd ${EDK2_DIR}
726f625747SDouglas Raillard       # Build UEFI & ARM Trust Firmware
736f625747SDouglas Raillard       ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware hikey
746f625747SDouglas Raillard       # Generate l-loader.bin
756f625747SDouglas Raillard       cd ${BUILD_PATH}/l-loader
766f625747SDouglas Raillard       ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
776f625747SDouglas Raillard       ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin
786f625747SDouglas Raillard       arm-linux-gnueabihf-gcc -c -o start.o start.S
796f625747SDouglas Raillard       arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader
806f625747SDouglas Raillard       arm-linux-gnueabihf-objcopy -O binary loader temp
816f625747SDouglas Raillard       python gen_loader_hikey.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin --img_ns_bl1u=fastboot.bin
826f625747SDouglas Raillard
836f625747SDouglas Raillard-  Generate partition table for aosp. The eMMC capacity is either 4GB or 8GB. Just change "aosp-4g" to "linux-4g" for debian.
846f625747SDouglas Raillard
856f625747SDouglas Raillard   .. code:: shell
866f625747SDouglas Raillard
87*367456dfSVictor Chong       PTABLE=aosp-4g SECTOR_SIZE=512 bash -x generate_ptable.sh
886f625747SDouglas Raillard
896f625747SDouglas RaillardSetup Console
906f625747SDouglas Raillard-------------
916f625747SDouglas Raillard
926f625747SDouglas 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.**
936f625747SDouglas Raillard
946f625747SDouglas Raillard   .. code:: shell
956f625747SDouglas Raillard
966f625747SDouglas Raillard       $sudo apt-get install ser2net
976f625747SDouglas Raillard
986f625747SDouglas Raillard-  Configure ser2net.
996f625747SDouglas Raillard
1006f625747SDouglas Raillard   .. code:: shell
1016f625747SDouglas Raillard
1026f625747SDouglas Raillard       $sudo vi /etc/ser2net.conf
1036f625747SDouglas Raillard
1046f625747SDouglas Raillard   Append one line for serial-over-USB in below.
1056f625747SDouglas Raillard   *#ser2net.conf*
1066f625747SDouglas Raillard
1076f625747SDouglas Raillard   .. code:: shell
1086f625747SDouglas Raillard
1096f625747SDouglas Raillard       2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
1106f625747SDouglas Raillard
111*367456dfSVictor Chong-  Start ser2net
112*367456dfSVictor Chong
113*367456dfSVictor Chong   .. code:: shell
114*367456dfSVictor Chong
115*367456dfSVictor Chong       $sudo killall ser2net
116*367456dfSVictor Chong       $sudo ser2net -u
117*367456dfSVictor Chong
1186f625747SDouglas Raillard-  Open the console.
1196f625747SDouglas Raillard
1206f625747SDouglas Raillard   .. code:: shell
1216f625747SDouglas Raillard
1226f625747SDouglas Raillard       $telnet localhost 2004
1236f625747SDouglas Raillard
1246f625747SDouglas Raillard   And you could open the console remotely, too.
1256f625747SDouglas Raillard
1266f625747SDouglas RaillardFlush images in recovery mode
1276f625747SDouglas Raillard-----------------------------
1286f625747SDouglas Raillard
1296f625747SDouglas Raillard-  Make sure Pin3-Pin4 on J15 are connected for recovery mode. Then power on HiKey.
1306f625747SDouglas Raillard
1316f625747SDouglas Raillard-  Remove the modemmanager package. This package may cause the idt tool failure.
1326f625747SDouglas Raillard
1336f625747SDouglas Raillard   .. code:: shell
1346f625747SDouglas Raillard
1356f625747SDouglas Raillard       $sudo apt-get purge modemmanager
1366f625747SDouglas Raillard
1376f625747SDouglas Raillard-  Run the command to download l-loader.bin into HiKey.
1386f625747SDouglas Raillard
1396f625747SDouglas Raillard   .. code:: shell
1406f625747SDouglas Raillard
1416f625747SDouglas Raillard       $sudo python hisi-idt.py -d /dev/ttyUSB1 --img1 l-loader.bin
1426f625747SDouglas Raillard
1436f625747SDouglas Raillard-  Update images. All aosp or debian images could be fetched from `link <https://builds.96boards.org/>`__.
1446f625747SDouglas Raillard
1456f625747SDouglas Raillard   .. code:: shell
1466f625747SDouglas Raillard
1476f625747SDouglas Raillard       $sudo fastboot flash ptable prm_ptable.img
1486f625747SDouglas Raillard       $sudo fastboot flash fastboot fip.bin
1496f625747SDouglas Raillard       $sudo fastboot flash boot boot.img
1506f625747SDouglas Raillard       $sudo fastboot flash cache cache.img
1516f625747SDouglas Raillard       $sudo fastboot flash system system.img
1526f625747SDouglas Raillard       $sudo  fastboot flash userdata userdata.img
1536f625747SDouglas Raillard
1546f625747SDouglas RaillardBoot UEFI in normal mode
1556f625747SDouglas Raillard------------------------
1566f625747SDouglas Raillard
1576f625747SDouglas Raillard-  Make sure Pin3-Pin4 on J15 are open for normal boot mode. Then power on HiKey.
1586f625747SDouglas Raillard
1596f625747SDouglas Raillard-  Reference `link <https://github.com/96boards-hikey/tools-images-hikey960/blob/master/build-from-source/README-ATF-UEFI-build-from-source.md>`__
1606f625747SDouglas Raillard
1616f625747SDouglas Raillard.. _link: https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/Quickstart/README.md
162