Attempt for supporting uboot on hikey960


#1

Hi,

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.


#2

@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: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/hikey960.rst

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.


#3

Thanks Sumit for your reply.

I have tried to build bootloader from source, referring, [https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/hikey960.rst].

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

build.py…
: error 7000: Failed to execute command
make tbuild [/home/sreenad/hikey960_bootloader/edk2/Build/HiKey960/DEBUG_GCC5/AARCH64/ArmPlatformPkg/PrePi/PeiUniCore]

build.py…
: 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?

Regards,
Sreenad.


#4

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
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


#5

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


#6

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
[https://www.96boards.org/documentation/consumer/hikey960/downloads/Debian.md.html]
Base firmware flashing in recovery mode is done using
[https://github.com/96boards-hikey/tools-images-hikey960]

sudo ./recovery-flash.sh /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
1244M
1866M
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
iomcu_subsys_init
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?


#7

Hi @sreenad,

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

Thanks,
Mani


#8

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 recovery-flash.sh 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

Regards,
Sreenad.


#9

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.


#10

Hi,

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.

Regards,
Sreenad.


#11

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 https://www.op-tee.org/index.html.