Build u-boot for an existing distro

Hello, Due to the difficulties to buy a Raspebrry Pi 4, I bought a banana Pi M5 to increase my kubernetes cluster (based on k0s). I used to use a Archlinux distro based on a 5.17 kernel. But my img file doesn’t fit to Banana Pi M5, shame !!! So I consider building my own image

As I understand, u-boot (2nd stage) is like grub or lilo, so I “just” have to integrate u-boot to my existing img file to make it bootable on BPI-M5

Does that seem possible for you ? or I totally misunderstood ?

Regards Anthony

https://docs.armbian.com/Developer-Guide_Build-Preparation/ You can try adding board configuration this way:

5.19.y has dtb, the rest is the same / similar as from Odroid C4 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/amlogic/meson-sm1-bananapi-m5.dts?h=v5.19

Thank you for your complete answer, I will try and come back to you

This is a prebuilt u-boot.bin.sd.bin (2022.07): https://chewitt.libreelec.tv/testing/u-boot/u-boot.bin.sd.bin-bananapi-m5 … might save some time/effort. Original sources are here: https://github.com/chewitt/u-boot/commits/amlogic-2022.07 (note the path changes in the LOCAL patches).

... might save some time/effort.
Sure, I’m reading documentation on U-Boot, and trying to make my own distro
Thank you

Hello @chewitt, I read the U-Boot documentation, if I really understand, the file (u-boot.bin.sd.bin-bananapi-m5) you proposed me is the result of the build, isn’t it ?
I just have to copy the file on a SD Card through the command detailled on documentation

$ DEV=/dev/your_sd_device
$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444

I’ve done this, but the card doesn’t boot (the green LED stays on)
I’ve probably missed something, thank you for your help

Regards
Anthony

I’ve not test-booted an M5 for a while, but it was working last time I did check it worked and nothing really changed since. This is what I use: https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Amlogic/bootloader/mkimage#L8-L9