Here is some instruction how to change U-Boot to use distroboot instead.
Currently tested on R64 , R3 and R4. On the R64 still wip.
Copy this file:
[root@bpir3 ~]# cat include/configs/mt7xxx.h
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Configuration for MediaTek MT7622/MT7986 SoC
*
*/
#ifndef __MT7XXX_H
#define __MT7XXX_H
/* Uboot definition */
#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE
/* SPL -> Uboot */
#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE
/* DRAM */
#define CFG_SYS_SDRAM_BASE 0x40000000
/* This is needed for kernel booting */
#define FDT_HIGH "0x4fd00000"
#define ENV_MEM_LAYOUT_SETTINGS \
"fdt_high=" FDT_HIGH "\0" \
"kernel_addr_r=0x44000000\0" \
"ramdisk_addr_r=0x48000000\0" \
"kernel_comp_addr_r=0x4c000000\0" \
"kernel_comp_size=0x03c00000\0" \
"scriptaddr=0x4fc00000\0" \
"fdt_addr_r=" FDT_HIGH "\0" \
"fdtoverlay_addr_r=0x4fff0000\0" \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0"
#ifdef CONFIG_DISTRO_DEFAULTS
#define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 1) \
func(MMC, mmc, 0) \
func(NVME, nvme, 0) \
func(SCSI, scsi, 0) \
func(UBIFS, ubifs, 0, ubi, rootfs)
#include <config_distro_bootcmd.h>
/* Extra environment variables */
#define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
BOOTENV
#endif /* ifdef CONFIG_DISTRO_DEFAULTS*/
#endif
Apply this patch:
diff --git a/include/configs/mt7622.h b/include/configs/mt7622.h
index 4a056954bf8..c61f7b00794 100644
--- a/include/configs/mt7622.h
+++ b/include/configs/mt7622.h
@@ -9,4 +9,6 @@
#ifndef __MT7622_H
#define __MT7622_H
+#include "mt7xxx.h"
+
#endif
diff --git a/include/configs/mt7986.h b/include/configs/mt7986.h
index 090b4c6833e..e75674f69c1 100644
--- a/include/configs/mt7986.h
+++ b/include/configs/mt7986.h
@@ -9,4 +9,6 @@
#ifndef __MT7986_H
#define __MT7986_H
+#include "mt7xxx.h"
+
#endif
diff --git a/include/configs/mt7987.h b/include/configs/mt7987.h
index 18ed3c7a55b..bd6f6d0d27a 100644
--- a/include/configs/mt7987.h
+++ b/include/configs/mt7987.h
@@ -11,4 +11,6 @@
#define CFG_MAX_MEM_MAPPED 0xC0000000
+#include "mt7xxx.h"
+
#endif
diff --git a/include/configs/mt7988.h b/include/configs/mt7988.h
index e63825a5a19..616f111aea1 100644
--- a/include/configs/mt7988.h
+++ b/include/configs/mt7988.h
@@ -11,4 +11,6 @@
#define CFG_MAX_MEM_MAPPED 0xC0000000
+#include "mt7xxx.h"
+
#endif
Append this to emmc-defconfig:
CONFIG_AUTOBOOT=y
CONFIG_BOOTDELAY=1
CONFIG_OF_LIBFDT_OVERLAY=y
CONFIG_CMD_BTRFS=y
CONFIG_CMD_EXT4=y
CONFIG_CMD_SETEXPR=y
CONFIG_HUSH_PARSER=y
CONFIG_EFI_PARTITION=y
CONFIG_ENV_IS_IN_MMC=n
CONFIG_DISTRO_DEFAULTS=y
CONFIG_CMD_PWM=y
CONFIG_DM_PWM=y
CONFIG_PWM_MTK=y
CONFIG_CMD_MTD=y
CONFIG_MTD=y
CONFIG_DM_MTD=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_FASTMAP=y
CONFIG_CMD_UBI=y
CONFIG_CMD_UBI_RENAME=y
CONFIG_CMD_UBIFS=y
CONFIG_MTD_SPI_NAND=y
CONFIG_DM_SPI_FLASH=y
CONFIG_SPI_FLASH_SFDP_SUPPORT=y
CONFIG_SPI_FLASH_EON=y
CONFIG_SPI_FLASH_GIGADEVICE=y
CONFIG_SPI_FLASH_ISSI=y
CONFIG_SPI_FLASH_MACRONIX=y
CONFIG_SPI_FLASH_SPANSION=y
CONFIG_SPI_FLASH_STMICRO=y
CONFIG_SPI_FLASH_WINBOND=y
CONFIG_SPI_FLASH_XMC=y
CONFIG_SPI_FLASH_XTX=y
CONFIG_SPI_FLASH_MTD=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_MTK_SPIM=y
CONFIG_MTK_SNFI_SPI=y
CONFIG_PCI=y
CONFIG_PCIE_MEDIATEK_GEN3=y
CONFIG_CMD_PCI=y
CONFIG_NVME_PCI=y
CONFIG_NVME=y
CONFIG_GPIO_HOG=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_SATA=y
CONFIG_AHCI=y
CONFIG_SCSI_AHCI=y
CONFIG_AHCI_PCI=y
CONFIG_DM_SCSI=y
CONFIG_AHCI=y
CONFIG_AHCI_PCI=y
CONFIG_SCSI_AHCI=y
CONFIG_SCSI=y
CONFIG_CMD_SCSI=y
CONFIG_PHY=y
CONFIG_PHY_MTK_TPHY=y
CONFIG_MTK_AHCI=y
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:
-
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.
-
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}
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:
r64-nand.patch (still to be tested)
This post may be corrected/amended later.