I don't just want to build from source. I want to build an image I can put on an SD card and run. There are several reasons for this. One is that I can add printf statements to help me learn things. The other is that I can get rid of the long delays while U-Boot pokes around for USB devices that I never use.
For my purposes I can just ignore the linux section.
I do a diff in his scripts directory:
cd /Projects/ARM-sources/sd-card-images/scripts diff build-boot-rk build-boot-sunxiThis indicates only two important differences:
< rk3328|rk3368|rk3399)
< build-atf "${CHIP_ID}" "${TUPLE}"
< export BL31="$PWD/arm-trusted-firmware/build/${CHIP_ID}/debug/bl31/bl31.elf"
< ;;
> *a64|*h5)
> build-atf sun50i_a64 "${TUPLE}"
> export BL31="$PWD/arm-trusted-firmware/build/sun50i_a64/debug/bl31.bin"
> export SCP=/dev/null
> ;;
And for the final image:
< # Copy U-Boot to 64 sectors from start < dd if=u-boot/u-boot-rockchip.bin of=tmp.img seek=64 conv=notrunc --- > # Copy U-Boot to 8192 bytes from start > dd if=u-boot/u-boot-sunxi-with-spl.bin of=tmp.img bs=1K seek=8 conv=notrunc
cd /Projects/ARM-sources/ cd arm-trusted-firmware make clean make PLAT="sun50i_a64" DEBUG=1 bl31I get this:
/usr/bin/aarch64-linux-gnu-ld: BL31 image has exceeded its limit. /usr/bin/aarch64-linux-gnu-ld: region `RAM' overflowed by 216 bytesI try again without the DEBUG option:
make clean make PLAT="sun50i_a64" bl31This works fine and ends like so:
LD /u2/Projects/ARM-sources/arm-trusted-firmware/build/sun50i_a64/release/bl31/bl31.elf BIN /u2/Projects/ARM-sources/arm-trusted-firmware/build/sun50i_a64/release/bl31.bin OD /u2/Projects/ARM-sources/arm-trusted-firmware/build/sun50i_a64/release/bl31/bl31.dump Built /u2/Projects/ARM-sources/arm-trusted-firmware/build/sun50i_a64/release/bl31.bin successfully
cd /Projects/ARM-sources/ cd u-boot export BL31="/Projects/ARM-sources/arm-trusted-firmware/build/sun50i_a64/release/bl31/bl31.elf" export CROSS_COMPILE=aarch64-linux-gnu- export LOCALVERSION="trebisky" export SCP=/dev/null make distclean make clean make orangepi_pc2_defconfig makeOn my machine, the build takes 3 minutes. It ends as follows:
OBJCOPY spl/u-boot-spl-nodtb.bin COPY spl/u-boot-spl.bin SYM spl/u-boot-spl.sym MKIMAGE spl/sunxi-spl.bin MKIMAGE u-boot.img COPY u-boot.dtb MKIMAGE u-boot-dtb.img BINMAN .binman_stamp Image 'u-boot-sunxi-with-spl' is missing optional external blobs but is still functional: scp /binman/u-boot-sunxi-with-spl/fit/images/scp/scp (scp.bin): SCP firmware is required for system suspend, but is otherwise optional. Please read the section on SCP firmware in board/sunxi/README.sunxi64 OFCHK .configNote the line above that exports SCP as /dev/null -- this was present in the build scripts, but I did not include it in the build I just did. Next time.
cd /Projects/ARM-sources # Copy U-Boot to 8192 bytes from start dd if=u-boot/u-boot-sunxi-with-spl.bin of=h5.img bs=1K seek=8 conv=notrunc ls -l h5.img -rw-r--r-- 1 tom tom 1153629 Jan 20 21:36 h5.imgSo the image is just a bit bigger than 1M.
su dd if=h5.img of=/dev/sdf syncI plug the card in, cycle power, and get this:
U-Boot SPL 2026.01-rc3trebisky-00026-g31bf4a1c3087 (Jan 20 2026 - 21:28:09 -0700) DRAM: 1024 MiB Trying to boot from MMC1 alloc space exhausted ptr 10fe00 limit 100000 Could not get FIT buffer of 1113088 bytes check CONFIG_SPL_SYS_MALLOC_F_LENThe messages from my ancient (but working) SD card are:
U-Boot SPL 2020.04-armbian (Jun 03 2020 - 07:47:47 +0200) DRAM: 1024 MiB Trying to boot from MMC1 NOTICE: BL31: v2.3(debug):ec29ce6-dirty NOTICE: BL31: Built : 07:47:38, Jun 3 2020I see a report where the malloc len had been reduced from 0x10000 to 0x8000 and this had caused bugs. Looking at my .config file I see:
CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000So, I add these 2 lines to configs/orangepi_pc2_defconfig
CONFIG_SYS_MALLOC_F_LEN=0x10000 CONFIG_SPL_SYS_MALLOC_F_LEN=0x10000Then I repeat the build:
cd /Projects/ARM-sources/ cd u-boot export BL31="/Projects/ARM-sources/arm-trusted-firmware/build/sun50i_a64/release/bl31/bl31.elf" export CROSS_COMPILE=aarch64-linux-gnu- export LOCALVERSION="trebisky" export SCP=/dev/null make distclean make clean make orangepi_pc2_defconfig make cd .. dd if=u-boot/u-boot-sunxi-with-spl.bin of=h5.img bs=1K seek=8 conv=notrunc su dd if=h5.img of=/dev/sdf sync exitNow I get nothing at all on the console when I try to boot the card! Maybe I was too extravagant.
CONFIG_SYS_MALLOC_F_LEN=0x4000 CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000Now I get this on the console:
U-Boot SPL 2026.01-rc3trebisky-00026-g31bf4a1c3087-dirty (Jan 20 2026 - 22:19:01 -0700) DRAM: 1024 MiB Trying to boot from MMC1 alloc space exhausted ptr 10fe00 limit 100000 Could not get FIT buffer of 1113088 bytes check CONFIG_SPL_SYS_MALLOC_F_LEN
Tom's electronics pages / tom@mmto.org