Build U-Boot that boots with menu from extlinux.conf or boot.scr

Here is some instruction how to change U-Boot to use distroboot instead.

Currently tested on R64 , R3, R3mini and R4.

Copy this file:

Apply this patch:

Append this to emmc-defconfig:

Apply patch to add pcie support if you want to use nvme and it is not part of your U-Boot version.

And build U-Boot, install it on nand or emmc.

When booting, your emmc, nvme, sata and nand-ubifs are scanned for an extlinux.conf file. For emmc/nvme/sata two options:

  1. Separate boot partition, fat32 formatted and any rootfs partition supported by your linux. Set the boot flag of the bootpartition. Edit /extlinux/extlinux.conf on the bootpartition.

  2. Only 1 partition, btrfs formatted, with a /boot/ folder. Set the boot flag of this partition. Edit /boot/extlinux/extlinux.conf on this partition.

Set the bootflag of nvme0n1p1 with:

parted /dev/nvme0n1 set 1 boot on

Example extlinux.conf:

[root@bpir3 ~]# cat /boot/extlinux/extlinux.conf 
DEFAULT linux-bpir-git
  MENU title U-Boot menu
  PROMPT 0
  TIMEOUT 50
LABEL linux-bpir-git
  MENU LABEL Archlinux ARM for BananaPi Routers
  LINUX /boot/Image
  INITRD /boot/initramfs-bpir.img
  FDT /boot/dtbs/mt7986a-bananapi-bpi-r3-plus-emmc.dtb

For option 1. remove ‘/boot’ from the path in extlinux.conf

This FDT has already overlays applied and cmdline appended, but extlinux.conf does also support:

  FDTOVERLAYS /boot/dtbs/xxxxxxx.dtbo

And support:

  APPEND root=/dev/mmcblk0p3

Or any other cmdline options you wish to add.

Then you can enter a second label (menu entry) with, for example, the same files and different cmdline options. Or perhaps an entry with a different initrd image or a different kernel image.

If you don’t want to use extlinux.conf, you can save a /boot/boot.scr file instead. It is build in for backwards compatibility. See example howto create a bootscr for distroboot how to make one for distroboot.

boot.cmd

echo "Loaded boot.scr!"
if test -z "$bootargs"; then
    setenv bootargs root=/dev/mmcblk1p2 rootdelay=2
fi
echo "Loading device tree from ${devtype} ${devnum}:${distro_bootpart}..."
load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}dtbs/mt7986a-bananapi-bpi-r3-plus-emmc.dtb
echo "Loading kernel from ${devtype} ${devnum}:${distro_bootpart}..."
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}Image.gz
echo "Booting with arguments: ${bootargs}"
booti ${kernel_addr_r} - ${fdt_addr_r}

Or:

boot.cmd

setenv ipaddr 192.168.1.8
setenv serverip 192.168.1.2
tftp ${fdt_addr_r} boot/dtbs/mt7986a-bananapi-bpi-r3-plus-emmc.dtb
tftp ${kernel_addr_r} boot/Image
tftp ${ramdisk_addr_r} boot/initramfs-bpir.img
setenv bootargs "root=/dev/mmcblk0p3"
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r} ; reset

Then create /boot/boot scr with:

mkimage -C none -A arm64 -T script -d boot.cmd /boot/boot.scr

But extlinux.conf is the preferred method, boot.scr for backward compatibility.

Finally:

Prebuild binaries can be found in bpir-uboot-git-xxxxx.tar.xz archive from:

https://ftp.woudstra.mywire.org/repo/aarch64/

This is also part of my ArchLinuxARM image, where this U-Boot, together with linux initrd bash based rescue system, are installed to nand with the command bpir-toolbox --nand-format.

Based on the process of building my bpir-uboot-git package:

https://github.com/ericwoud/archlinuxarm-repo/blob/bpir-uboot-git/PKGBUILD

Patches for U-Boot 2025.04:

mt798x-pcie.patch

r4-nand.patch

This post may be corrected/amended later.

1 Like