I’ve been trying unsuccessfully to get “mainline” u-boot on Rock 5B.
The repositories
In /home/foxx/src/c:
# TF-A
git clone https://github.com/ARM-software/arm-trusted-firmware.git
# mainline u-boot
git clone https://source.denx.de/u-boot/u-boot.git
# Rockchip's blobs
git clone https://github.com/rockchip-linux/rkbin.git
Building
cd arm-trusted-firmware
make PLAT=rk3588
# ./build/rk3588/release/bl31.elf will appear
export BL31=/home/foxx/src/c/arm-trusted-firmware/build/rk3588/release/bl31/bl31.elf
cd ../u-boot
export ROCKCHIP_TPL=/home/foxx/src/c/rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.21.bin
# there's also an rk3588_ddr_lp4_1848MHz_lp5_2112MHz_v1.21.bin
# and there are also _eyescan_v1.20 bin equivalent files
# didn't try
make rock5b-rk3588_defconfig
make -j4
I end up with idbloader.img, u-boot.itb and a ~2 MB u-boot-rockchip-spi.bin.
Download, here it goes wrong
Initially I was manually downloading idbloader.img and u-boot.itb at the BSP recommended offsets and it was bricking the device:
!this bricks the bootloader!
sudo dd if=idbloader.img of=/dev/mtdblock0 bs=512 seek=64 conv=fsync status=progress
sudo dd if=u-boot.itb of=/dev/mtdblock0 bs=512 seek=16384 conv=fsync status=progress
sync
Bricked afterwards, as those offsets are fine for the Radxa bootloader, not for mainline u-boot. Had to recover with an USB cable on the PC and with the Maskrom button / procedure:
Maskrom recovery on the PC
git clone https://github.com/rockchip-linux/rkdeveloptool.git
make
# it will generate ./rkdeveloptool
# keep the recovery button pressed, connect the USB-C cable, then depress the recovery button
# the PC will detect the Maskrom USB device
# double check it's there
./rkdeveloptool ld
# turn off USB sleep on the PC, otherwise flashing will error out:
sudo echo -1 > /sys/module/usbcore/parameters/autosuspend
# flash recovery, which will facilitate the SPI
# have to download this exact file, I don't know what the equivalent on HEAD from rkbin is
./rkdeveloptool db rk3588_spl_loader_v1.08.111.bin
# flash the Radxa SPI
./rkdeveloptool wl 0 rock-5b-spi-image-gd1cf491-20240523.img
# reboot the device
./rkdeveloptool rd
# can unplug and switch back to normal usage after
Correct offsets for mainline u-boot
Turns out the current u-boot offsets are 0x8000 for idbloader.img and 0x60000 for u-boot.bin.
Also failed directly with the already aligned u-boot-rockchip-spi.bin
I looked with ImHex at u-boot-rockchip-spi.bin (also generated by runing make in mainline u-boot) and it seems to already be aligned as required.
cd u-boot
# extend u-boot-rockchip-spi.bin from ~2 MB to exactly 16 MB
SPI_SIZE=$((16 * 1024 * 1024))
rm -f rock5b-mainline-spi.img
truncate -s $SPI_SIZE rock5b-mainline-spi.img
# populate the first ~2 MB out of exactly 16 MB with all the ~2 MB of the mainline built SPI
dd if=u-boot-rockchip-spi.bin of=rock5b-mainline-spi.img bs=4K conv=notrunc
# overwrite the SPI device
dd if=rock5b-mainline-spi.img of=/dev/mtdblock0 bs=4M conv=fsync status=progress
sync
Ends up still bricked, have to get back to the Maskrom on PC procedure.
What might I be doing wrong?