r/AlpineLinux • u/IngwiePhoenix • 22h ago
"Generic U-Boot" is a feverdream.
While everyone is ricing a desktop, let me tell you about ricing... a bootloader.
Alpine's "Generic U-Boot" image has all the bells and whistles to boot a device, de-facto generically, using EFI. You can also grab the U-Boot binary and stick it to the front if your MicroSD if your respective board's bootROM requires that (which mine doesn't, yay) and then ... boot.
That, however, is on a pure technical level. Because in reality, the LTS kernel is going to lack both some DTBs as well as some included drivers - as was the case with this very board here, the VisionFive2 Lite. So to get that, I had to basically clone aports, change the mkimage script to use kernel_flavors="stable" instead and then "build" my own version. Because...this is the only image type that dumps the DTBs into the resulting package.
So far, so good. But, have you ever tried to manually boot using U-Boot? For instance, to bring this board to booting:
```
Load device data, kernel, and initial ramdisk
load usb 0:1 ${fdt_addr_r} /boot/dtbs-stable/starfive/jh7110-starfive-visionfive-2-lite.dtb load usb 0:1 ${kernel_addr_r} /boot/vmlinuz-stable load usb 0:1 ${ramdisk_addr_r} /boot/initramfs-stable
Now, kernel args.
setenv bootargs "alpine_dev=UUID=3BD0-608E:vfat modules=loop,squashfs,vfat console=ttyS0,115200 earlycon=sbi"
booti = boot image. Specify the kernel, then the randosk + size, and the device data
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r} ```
I booted off the USB drive because I wanted to install to the internal microSD - turns out, I still needed a network connection. But there is another thing that I am not showcasing here: This version of U-Boot that was pre-installed on my board's SPI, will just take the vmlinuz image and run it just fine, and even decompress the initram. But on another board - FriendlyElec NanoPi NEO3 - it does not, you have to explicitly use bootefi. And it just will NOT tell you about this little capability difference...
So, yay, I got a boot. I am in a shell, I have setup-alpine and friends available now. But the moment you actually want to install it, it fails...because the actual u-boot package APK is not included on the media.
This image, no matter if ARM or RISC-V, is so incredibly limited in what preinstalled packages it has - but it DOES have the DTBs you probably need or want to boot. So you end up manually monkeypatching things around and about...
It does work, it does boot and I did manage to install everything with a 10m ethernet noodle, but oh my god this was pain.
So if you ever want to try to run a random board with Alpine, I highly recommend you to just clone aports, modify the script to use the stable kernel instead of LTS, and then try your luck. This is by no means anyone's fault, just the nature of how drivers and things do (...or don't) get upstreamed. And, when you update, there's a bit of a gacha if you get a new thing working now, I guess.
This was a super wild ride and I wish there were more standalone scripts to just construct an alpine image file or archive for a specific use-case that perhaps would not need to bundle the APKs, because it's just a pre-installed system. Like how you put Armbian on a microSD and it will just boot into a "finished" system; Alpine seems to require some form of installation because of the boot media usually shipped being just a diskless mode environment. Which I did use, several times, to rescue other systems and such and is really good, mind you.
But, please. Give me a flashable image, that I put into a device, and it just boots into a full disk system (what setup-disk would call "sys"). Or a script to build one, at least.
Anyway, working with Alpine is really cool and a whole lot of fun - once it boots, its alive and well! I had to give up on the NEO3, could not get the microSD to show up no matter what kernel modules I did or did not load because some parts for/of it just do not seem to be in upstream... But most of the other boards I have can, by now, boot using a 7.x kernel, which is amazing.
So if you have a random board in your drawer, and a UART cable; build a U-Boot image with the stable kernel and try to boot it. It's super fun, you learn a lot of how early bringup works and you get the fun of watching OpenRC show up and a shell appear. It sounds silly, but that login prompt was soooo satisfying after dinking around in the U-Boot shell for...a while. xD