Attempt for supporting uboot on hikey960

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.

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.

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.

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 Open Portable Trusted Execution Environment - OP-TEE.

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

@wizofe,

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_uefi.sh

    # Build ARM Trusted Firmware
    cd ${BUILD_PATH}/arm-trusted-firmware
    BL32=../optee_os/out/arm-plat-hikey/core/tee-pager.bin
    BL33=${EDK2_OUTPUT_DIR}/FV/BL33_AP_UEFI.fd
    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 ($?)"
            exit
    fi

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

BL33=/home/sreenad/u-boot-hikey/u-boot.bin
BUILD_DEBUG=1
SCP_BL2=…/OpenPlatformPkg/Platforms/Hisilicon/HiKey960/Binary/lpm3.img

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.

Regards,
Sreenad.

1 Like

Hi,

Followed all the @sreenad steps. Able to compile ATF and create fip.bin
Not getting how to calculate entry point for u-boot.

Any ideas ?

Thanks in advance !

Thanks,
Ramappa

AFAIK, u-boot is compiled with fixed base address defined by CONFIG_SYS_TEXT_BASE which should be the starting point of u-boot. You need to build ATF with PRELOADED_BL33_BASE=CONFIG_SYS_TEXT_BASE of u-boot.

Hi @Ramappa @sreenad

In addition to what @sumit.garg said, you can use the address 0x1AC98000 as the base address of U-Boot (CONFIG_SYS_TEXT_BASE). This comes from NS_BL1U_BASE defined in ATF [1].

Hope this helps! Let us know how the porting goes :slight_smile:

Thanks,
Mani

[1] https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/hisilicon/hikey960/hikey960_bl2_mem_params_desc.c#L156

Hi @Mani @sumit.garg

Thanks for yor reply.
I can verify these changes only after initializing UART0.

To initialize UART, following below steps

  • Need to configure master cpu (providing vin and clk).
  • Initialize the LDO for 40 pin connector
  • PinMux for UART and initialize

I assume, main CPU will be A53, need to give input voltage with BUCKs similar to Hikey620. We can use same driver 'pmic_hi6553.c" for initialization. Is it right ?

I didn’t got any proper pointers/tutors for Pinmux, please provide me if you have any docs and links.

Thanks in advance.

Thanks,
Ramappa

@Ramappa,

I think, debug console UART is already initialized by the previous boot loader stages.
May be u have to find the UART TX register address for hi3660 from the linux kernel source and set it appropriately in uboot code.

Also u can verify whether jumping happens to uboot startup code by printascii kind of debugging.

At uboot entry point, in assembly, write a simple loop to send an ascii character to uart TX register.
if you are able to jump to uboot entry code u will get some prints in console.

Once you are sure that u are in uboot u can now play with it.

If you find some progress, don’t hesitate to share in community.

Regards,
Sreenad.

For UART initialisation (base address), you can refer to ATF source code specific to hikey960 [1].

[1] https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/hisilicon/hikey960/hikey960_bl31_setup.c#L81

@Ramappa You can have something like below for early debug print:

inline void printme(char *str)
{
    while(*str) {
        writel(*str, 0xFFF32000 + 0x00);
        str++;
    }  
}

Thanks,
Mani

Hi All,

Finally good news for us.
As @sreenad suggested, wrote small assembly code for printing some debug message.

Yes, It is entering into bootloader and printing my debug message on console/UART.

Held up with other task, not able concetrate on this work much.

Thanks,
Ramappa

Hi All,

I’m trying to do pinmuxing in u-boot for uart6 and other peripherals.
could you please help me to get IO pin number(IOMG) for correcponding pin ?

Like hikey620 :

                    uart2_pmx_func: uart2_pmx_func {
                            pinctrl-single,pins = <
                                    0xd8   MUX_M0   /* UART2_CTS_N  (IOMG054) */   <-- here IOMG value is 54
                                    0xdc   MUX_M0   /* UART2_RTS_N  (IOMG055) */
                                    0xe0   MUX_M0   /* UART2_RXD    (IOMG056) */
                                    0xe4   MUX_M0   /* UART2_TXD    (IOMG057) */

But for hikey960:

                    uart0_pmx_func: uart0_pmx_func {
                            pinctrl-single,pins = <
                                    0x0cc MUX_M2 /* UART0_RXD */      <-- Not mentioned IOMG number 
                                    0x0d0 MUX_M2 /* UART0_TXD */

If you have any pointers, then please let me know.

Thanks,
Ramappa

@Ramappa

One question, how long in the code flow the current boot flow can reach?

Some system hangs are expected, but I am curious to know how long the current code flow can reach.

Regards,
Sreenad.

@sreenad,

Assembly code it is entering that I verified by priting in assmbly.

When it tried to set MMU page tables, getting unhandled external abort error

INFO: SPSR = 0x3c9
UBERROR: Unhandled External Abort received on 0x80000000 at EL3!
PANIC in EL3 at x30 = 0x000000001ac5d518bf000002

Thanks,
Ramappa

@Ramappa

You are able to solve this abort issue ?

Am trying to port zircon on kirin970, in my case as well during mmu enabling, system hangs.
Am still debugging this, in mean while if you have any info, can u please share ?

Regards
Murali