PINE64
Manual: Howto cross-compile Upstream U-Boot for rock64 - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: ROCK64 (https://forum.pine64.org/forumdisplay.php?fid=85)
+--- Forum: Rock64 Tutorials (https://forum.pine64.org/forumdisplay.php?fid=90)
+--- Thread: Manual: Howto cross-compile Upstream U-Boot for rock64 (/showthread.php?tid=8174)



Manual: Howto cross-compile Upstream U-Boot for rock64 - rock7 - 11-02-2019

Step 1: Get the file bl31.elf
You can build ATF with Upstream arm-trusted-firmware repository to get the file "bl31.elf" (Way 1) or you use the rk322xh_bl31_vXXX.elf file from rockchip rkbin repository (Way 2)

Way 1 (build ATF with Upstream arm-trusted-firmware repository to get "bl31.elf")
Install the required packages (Debian / Ubuntu):
sudo apt-get install device-tree-compiler build-essential gcc make git libssl-dev

Go into your Download folder and open Terminal there, then run:
git clone https://github.com/ARM-software/arm-trusted-firmware.git

cd arm-trusted-firmware

Check the integrity of the cloned repository:
git status
git fsck
Optional: www.restic.net/blog/2015-09-16/verifying-code-archive-integrity

Open the file „platform_def.h“ (its in /plat/rockchip/rk3328/include/platform_def.h)
Change in this file the Line:
#define BL31_BASE (TZRAM_BASE + 0x40000)
to
#define BL31_BASE (TZRAM_BASE + 0x10000)

cd arm-trusted-firmware

make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3328 DEBUG=1 bl31

Go into your Download folder and open Terminal, then run:
git clone git://git.denx.de/u-boot.git
or Download U-Boot source tree from ftp://ftp.denx.de/pub/u-boot/
(How to verify downloaded file with .sig file: https://stackoverflow.com/questions/15331015/how-to-verify-downloaded-file-with-sig-file)

Search now the "bl31.elf" file  in the arm-trusted-firmware build folder and copy it in the U-Boot folder.

Way 2 (use "bl31.elf" file from rockchip rkbin repository)
Go into your Download folder and open Terminal, then run:
git clone git://git.denx.de/u-boot.git
or Download U-Boot source tree from ftp://ftp.denx.de/pub/u-boot/
(How to verify downloaded file with .sig file: https://stackoverflow.com/questions/15331015/how-to-verify-downloaded-file-with-sig-file)

Go back into your Download folder and open Terminal, then run:
git clone https://github.com/rockchip-linux/rkbin
cd rkbin

Check the integrity of the cloned repository:
git status
git fsck
Optional: www.restic.net/blog/2015-09-16/verifying-code-archive-integrity

Search the file „rk322xh_bl31_v1.42.elf“ in the rkbin folder (current version is v1.42, this file is in bin/rk33/) and change the name of this file to „bl31.elf“ and copy it in the U-Boot folder.

Step 2: Compile U-Boot
Install the required packages (Debian / Ubuntu)
sudo apt-get install bison flex bc libssl-dev make gcc gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf

cd u-boot

make CROSS_COMPILE=aarch64-linux-gnu- BL31=bl31.elf rock64-rk3328_defconfig

make CROSS_COMPILE=aarch64-linux-gnu- BL31=bl31.elf all u-boot.itb

Flash U-Boot to microSD card
Create a ext4 partition with e.g. gparted which begins at 16 mb.
Open Terminal in the U-Boot folder and flash U-Boot to microSD card with following commands (you can find the name of your microSD card with e.g. gparted, we search for example /dev/sdc (without number! not /dev/sdc1))

sudo dd if=./idbloader.img of=/dev/sdcard seek=64

sudo dd if=./u-boot.itb of=/dev/sdcard seek=16384


Good to know:
Alpine Linux on rock64: https://forum.pine64.org/showthread.php?tid=5881&page=2

This page has been archived:
www.archive.ph/kTfmj
www.web.archive.org/web/20191102210056/https://forum.pine64.org/showthread.php?tid=8174


RE: Manual: Howto cross-compile Upstream U-Boot for rock64 - kuleszdl - 03-20-2020

Thank you for sharing, the guide looks very promising!

Just one question: Does the u-boot obtained in this process also work from SPI flash or only from microsd? I tried flashing the precompiled uboot from ArchLinuxArm, but it fails with loading the ARM trusted firmware as it seems:

Code:
LoadTrustBL
LoadTrustBL error: -1



RE: Manual: Howto cross-compile Upstream U-Boot for rock64 - kuleszdl - 03-21-2020

@rock7 I followed your steps and successfully built everything using the upstream arm-trusted-firmware repository. However, it seems like my u-boot does not recognize sdcards:

Code:
Trying to boot from MMC1
Card did not respond to voltage select!
spl: mmc init failed with error: -95
Trying to boot from MMC2
...
I tried playing around with some of the config options as well as different mainline u-boot versions.
Does booting work for you?


RE: Manual: Howto cross-compile Upstream U-Boot for rock64 - rock7 - 04-15-2020

(03-20-2020, 05:41 PM)kuleszdl Wrote: Thank you for sharing, the guide looks very promising!

Just one question: Does the u-boot obtained in this process also work from SPI flash or only from microsd? I tried flashing the precompiled uboot from ArchLinuxArm, but it fails with loading the ARM trusted firmware as it seems:

Code:
LoadTrustBL
LoadTrustBL error: -1

I haven't tried it yet with SPI flash, you can follow this guide: https://github.com/ayufan-rock64/linux-build/blob/master/recipes/flash-spi.md

(03-21-2020, 12:11 PM)kuleszdl Wrote: @rock7 I followed your steps and successfully built everything using the upstream arm-trusted-firmware repository. However, it seems like my u-boot does not recognize sdcards:

Code:
Trying to boot from MMC1
Card did not respond to voltage select!
spl: mmc init failed with error: -95
Trying to boot from MMC2
...
I tried playing around with some of the config options as well as different mainline u-boot versions.
Does booting work for you?
If this problem occurs, just restart. It rarely happens, I don't know why it happens yet.