Attempt for supporting uboot on hikey960



I found currently u-boot is not supported for hikey960.
So I am trying to support it from a limited open hardware details available.

When I checked, Peter Griffin’s work for Hikey620, I found,
most of his work is towards, device drivers of PMIC, USB, eMMC, pinmux, etc. Not much modifications in arm64 and also for common codes.
He uses, common board_init_f() and common borad_init_r().

Now I am trying to get atleast some debug prints via serial console and see upto where it can go. By skipping the things which are creating issues, I believe I can get a uboot prompt.

Atleast If I can make the external sdcard interface up, I can load my image to RAM and execute.

Now I am trying to enter to uboot entry point. (_start)
If I can get in to the entry point, I assume, I can use the printascii kind of debug printing until I can execute some C code.

My current bootloader is UEFI-GRUB2 and I have few query as given below.
1. I could not find where is the place of ATF in booting stage?
2. Who calls entry of UEFI?
3. Who/How to enter into GRUB2 entry point?
4. Where can be the possible place of uboot in the current booting steps.?
5. Who can load and jump to u-boot entry point?
6. How to get a combined bootloader image with other bootloader components.

Any help in this topic would be really appreciated.

Thanks in advance,


@sreenad UEFI is loaded by ATF as BL33 image. You can use u-boot as BL33 image instead of UEFI. BL33 image entry-point is called from ATF.
To create combined boot-loader image (fip.bin) with UEFI as BL33 image refer to:

AFAIK u-boot is compiled with fixed base address and you need to set BL33_BASE in ATF accordingly.

Regarding GRUB2, its an “.efi” application launched by UEFI.


Thanks Sumit for your reply.

I have tried to build bootloader from source, referring, [].

But I am getting build error

/home/sreenad/hikey960_bootloader/edk2/OpenPlatformPkg/Platforms/Hisilicon/HiKey960/Library/HiKey960Lib/HiKey960Mem.c:82: undefined reference to __stack_chk_guard' /home/sreenad/hikey960_bootloader/edk2/OpenPlatformPkg/Platforms/Hisilicon/HiKey960/Library/HiKey960Lib/HiKey960Mem.c:256: undefined reference to__stack_chk_guard’
/home/sreenad/hikey960_bootloader/edk2/OpenPlatformPkg/Platforms/Hisilicon/HiKey960/Library/HiKey960Lib/HiKey960Mem.c:256: undefined reference to __stack_chk_guard' /home/sreenad/hikey960_bootloader/edk2/OpenPlatformPkg/Platforms/Hisilicon/HiKey960/Library/HiKey960Lib/HiKey960Mem.c:256: undefined reference to__stack_chk_fail’
collect2: error: ld returned 1 exit status
make: *** [/home/sreenad/hikey960_bootloader/edk2/Build/HiKey960/DEBUG_GCC5/AARCH64/ArmPlatformPkg/PrePi/PeiUniCore/DEBUG/ArmPlatformPrePiUniCore.dll] Error 1…
: error 7000: Failed to execute command
make tbuild [/home/sreenad/hikey960_bootloader/edk2/Build/HiKey960/DEBUG_GCC5/AARCH64/ArmPlatformPkg/PrePi/PeiUniCore]…
: error F002: Failed to build module
/home/sreenad/hikey960_bootloader/edk2/ArmPlatformPkg/PrePi/PeiUniCore.inf [AARCH64, GCC5, DEBUG]

  • Failed -
    Build end time: 23:03:35, Jun.05 2018
    Build total time: 00:00:06

                                     Hikey960 DEBUG fail

pass 0
fail 1

A lot of undefined reference to __stack_chk_guard

I tried installing clang package but same errors even after that.
I think I am missing some package or some environment issue here.

I have tried both aarch64 5.4 and 7.2 compiler. No difference.

Any clue on this?



I have changed my toolchain to 7.2 from linaro and did a clean build (from beginning).
After that compilation works.

aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011
Copyright © 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO


@sreenad Nice to hear that compilation worked at your end.


I just wanted to try flashing release images using recovery mode and also using fastboot mode, before flashing my own compiled binaries.
So first I erased UFS from linux using,
dd if=/dev/zero of=/dev/sdd bs=10M count=20 (first 200M MB where I believe bootloader and boot images and partition table are flashed)

Followed a full debian OS installation document from
Base firmware flashing in recovery mode is done using

sudo ./ /dev/ttyUSB1 (it is successfull)

After that, put board in to fastboot mode and did the following

$ sudo fastboot flash ptable prm_ptable.img
$ sudo fastboot flash fastboot l-loader.bin
$ sudo fastboot flash fip fip.bin
$ sudo fastboot reboot-bootloader

After reboot, it is not giving a fastboot
In serial console, I am getting,

C1R,V0x00000030 e:66
C2R,V0x00000030 e:66
C3R,V0x00000030 e:65
C0R,V0x00000016 e:66
C2R,V0x00000016 e:66
C3R,V0x00000016 e:66
C0R,V0x00000017 e:66
C1R,V0x00000017 e:66
C2R,V0x00000017 e:66
C3R,V0x00000017 e:66
boot_c0 PROFILE 4
slave0 irq0:0x00000004
slave1 irq0:0x00000004
NOTICE: BL2: v1.5(release):v1.5-149-gda9d1d59
NOTICE: BL2: Built : 13:29:43, May 14 2018
ERROR: BL2: Failed to load image (-2)

Any idea what is wrong here?


Hi @sreenad,

You should use for flashing the base firmwares. Alternatively you can take a look at the ATF doc for most up to date instructions:



Thanks, @Mani

I compiled fip, l-loader and prm_ptable from source and after that target board is recoverd fully
Started using the following binaries after building from source.

prm_ptable.img (compiled) (before I was using prebuilt found in tools-images-hikey960)
l-loader.bin (compiled) (before I was using prebuilt obtained from debian OS installation page)
recovery.bin (compiled) (no such binary before)
fip.bin (compiled) (before I was using prebuilt obtained from debian OS installation page)

hisi-sec_xloader.img (prebuilt binary found in tools-images-hikey960)
boot-linaro-stretch-developer-hikey-20180521-18.img (prebuilt debian boot image)
rootfs-linaro-stretch-developer-hikey-20180521-18.img (prebuilt debian rootfs image)

I have one question,
if is not needed, the below firmwares are no longer needed?

fastboot flash nvme ${IMG_FOLDER}/hisi-nvme.img
fastboot flash fw_lpm3 ${IMG_FOLDER}/hisi-lpm3.img
fastboot flash trustfirmware ${IMG_FOLDER}/hisi-bl31.bin



Now I am going to compile a fip image by changing BL33= path/uboot.bin while compiling ATF.
Lets see what happens.

I think now I have to consider modifying the BL33_BASE @sumit.garg had mentioned.



I am not using an optee as mentioned in hikey960.rst
Still board boots and works fine.

Some where I read it is optional.

What is it used for?
I am curious to know.



OP-TEE is Secure OS providing Trusted Execution Environment based on ARM TrustZone. Yes it is optional in boot sequence. For more info on OP-TEE please refer to


Were you able to port uboot for hikey960? I am happy to help as I have a similar ongoing project.



I was able to create a combined fip image with uboot binary and other BL binaries.

uboot binary used was same as that of hikey620’s. Atleast for a try to jump to uboot entry point i thought this was enough.

I had to switch to a high priority task in between. So now, it has been suspened from my end.

But i am very much interested to do this.
I shall also contribute if i can do something on this based on my free time.

I shall share the fip image creation steps here tomorrow, once I am in office.


That sounds very exciting @sreenad ! Let me know tomorow about the fip image if you are able to upload and let’s keep in touch!


Hi @wizofe

Current fip building script.
File: l-loader/

    # Build ARM Trusted Firmware
    cd ${BUILD_PATH}/arm-trusted-firmware
    CROSS_COMPILE=aarch64-linux-gnu- make ${TC_FLAGS} PLAT=${PLATFORM} SCP_BL2=${SCP_BL2} SPD=opteed BL32=${BL32} BL33=${BL33} DEBUG=${BUILD_DEBUG} all fip
    if [ $? != 0 ]; then
            echo "Fail to build ARM Trusted Firmware ($?)"

Taking this as reference I wrote a small script which can be executed inside ATF source directory.


make CROSS_COMPILE=aarch64-linux-gnu- PRELOADED_BL33_BASE=0x35000000 PLAT=hikey960 SCP_BL2=${SCP_BL2} BL33=${BL33} DEBUG=${BUILD_DEBUG} all fip

PRELOADED_BL33_BASE=0x35000000 is not correct.
I have not calculated the value for hikey960.
Anyways this image did not boot.

I think by properly setting the UART base address, alteast printascii wourd work.
Load uboot to memory, Jump to BL33 base is the current thing I am looking at.

Currently I am not getting time for that.
If you are getting any progress in entering to uboot startup code, please let me know.