January 24, 2022

Orange Pi 4 (Rockchip 3399) building U-Boot with bl31

I have other notes already about building U-Boot from the Denx sources on github. They always give a warning about me needing to go find bl31 somewhere, and I have never known where.

Some searching led me to this post on the pine64 forums for building U-Boot for their rock64 board. I don't use their defconfig file, but this is a RK3399 board and bl31 ought to be the same.

The "where" seems to be to git clone something called "rkbin". Then go into the bin/rk33 directory and look for a bl31 that has been built for the rk3399, and lo and behold I find this:

rk3399_bl31_v1.35.elf
What I do to aid and abet myself in the future is:
cd u-boot
mkdir rkbin
cd rkbin
cp xyz/rk3399_bl31_v1.35.elf .
cp rk3399_bl31_v1.35.elf ../bl31.elf
I am pretty sure if I do a "make clean" it will delete my bl31.elf file and I will wonder where to go find it. (At this time it would be in /u1/Projects/Rockchip/rkbin/bin/rk33)

I keep telling myself I will only be building U-boot this one last time, but that is never true, so I add this line near the top of the makefile.

CROSS_COMPILE=aarch64-linux-gnu-
And I type "make" and it takes less than 2 minutes to do a full build.

Put it on an SD card

This is the recommended scheme:
dd if=./idbloader.img of=/dev/sdcard seek=64
dd if=./u-boot.itb of=/dev/sdcard seek=16384
For my convenience, I add this entry to the Makefile, down near the end or it preempts the "all" target:
# Added by tjt
sdcard:
        dd if=/dev/zero of=/dev/sdh count=40000
        dd if=./idbloader.img of=/dev/sdh seek=64
        #dd if=./u-boot.itb of=/dev/sdh seek=16384
        sync
Much to my surprise, idbloader.img has appeared in the U-Boot directory.

I try it, and get this:

U-Boot TPL 2022.01-00450-g25711b07ca-dirty (Jan 24 2022 - 22:07:22)
sdram_init: DDR3 - 666MHz failed!
rk3399_dmc_init DRAM init failed -22
Missing DTB
I repeat the experiment, putting only the idbloader.img file on the card and get the same error messages, so I need to figure out how the DTB should be added to that file.

The lines that generate idbloader.img are these:

./tools/mkimage -E -B 0x8 -f u-boot.its -p 0x0 u-boot.itb >/dev/null  && cat /dev/null
./tools/mkimage -n "rk3399" -T rksd -d tpl/u-boot-tpl.bin tpl/u-boot-tpl-rockchip.bin
cat tpl/u-boot-tpl-rockchip.bin spl/u-boot-spl.bin > idbloader.img


Have any comments? Questions? Drop me a line!

Tom's electronics pages / [email protected]