With a recently posted (not yet merged) patch series from Jagan Teki adding rank detection, LPDDR4 timings and so on, mainline U-Boot boots Khadas Edge.
The Rockchip miniloader (idbloader.img) is no longer needed and the ARM Trusted Firmware bl31 component is built into U-Boot itself. This results in a less ugly and noisy boot process, and is 100% mainline free software. (The entire system can be blob-free apart from the firmware for the Broadcom wifi module.)
Until all the changes are merged upstream, I have a pre-prepared tree of U-Boot mainline (as of this morning) with the patch series (99 patches), a suitable defconfig and device tree. This can be cloned with
git clone https://github.com/arachsys/u-boot-edge.git
cd u-boot-edge
Alternatively, you can reconstruct this tree yourself like this:
git clone https://gitlab.denx.de/u-boot/u-boot.git
cd u-boot
git fetch https://github.com/openedev/u-boot-amarula.git \
rk3399-lpddr4:amarula-lpddr4 rk3399-build-target:amarula-parent
git cherry-pick amarula-parent..amarula-lpddr4
# There's a merge conflict to resolve; after fixing, remember to git add
# the resolved file before resuming with git cherry-pick --continue.
sed 's/rock-pi-4/khadas-edge/g' configs/rock-pi-4-rk3399_defconfig \
>configs/khadas-edge-rk3399_defconfig
cp arch/arm/dts/rk3399-{rock-pi-4,khadas-edge}-u-boot.dtsi
# Put Edge device tree from Linux at arch/arm/dts/rk3399-khadas-edge.dts
# and add rk3399-khadas-edge.dtb to dtb-$(CONFIG_ROCKCHIP_RK3399) in
# arch/arm/dts/Makefile.
git add configs/khadas-edge-rk3399_defconfig
git add arch/arm/dts/{Makefile,rk3399-khadas-edge*.dts*}
git commit -m 'rockchip: rk3399: Add Khadas Edge board support'
Prerequisites to build U-Boot:
- cross-compiling needs aarch64-linux-gnu (or -musl) gcc and binutils;
- the Trusted Firmware Cortex-M0 code needs an arm-none-eabi toolchain;
- python and pyelftools are used to generate a FIT image from bl31.elf.
Fetch and build ARM Trusted Firmware to get bl31 component:
git clone https://github.com/ARM-software/arm-trusted-firmware.git atf
make -C atf CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
cp atf/build/rk3399/release/bl31/bl31.elf bl31.elf
Build U-Boot:
make khadas-edge-rk3399_defconfig
make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu-
TPL is needed with the default config as the built SPL is too large for the RK3399 boot ROM to load. Write TPL + SPL + U-Boot to the SD card:
tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl-dtb.bin tpl-spl.img
cat spl/u-boot-spl-dtb.bin >>tpl-spl.img
dd if=tpl-spl.img of=/dev/mmcblkN seek=64 conv=fsync
dd if=u-boot.itb of=/dev/mmcblkN seek=16384 conv=fsync
Assuming the SD card already has a suitable partition table, boot partition with extlinux.conf, kernel and dtb, e.g. by starting with an existing image, U-Boot will happily now boot it.