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

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

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"			\
	"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(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_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_CMD_UBI=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_PCI=y
CONFIG_PCIE_MEDIATEK_GEN3=y
CONFIG_CMD_PCI=y
CONFIG_NVME_PCI=y
CONFIG_NVME=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 and nand-ubifs are scanned for an extlinux.conf file. For emmc/nvme 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

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

  FDTOVERLAYS /boot/dtbs/xxxxxxx.dtbo

Requires `CONFIG_OF_LIBFDT_OVERLAY=y and setting fdtoverlay_addr_r variable (not tested yet)

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

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

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

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

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

This post may be corrected/amended later.

1 Like