Initial Commit
- initial default booting image
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
From 3a9d2dd2f5fb07b75a74c307d61b9b9fc5d20a62 Mon Sep 17 00:00:00 2001
|
||||
From: Yi Zhao <yi.zhao@windriver.com>
|
||||
Date: Fri, 27 Feb 2026 11:46:54 +0800
|
||||
Subject: [PATCH] Revert "configure: Check linker for --image-base support"
|
||||
|
||||
This reverts commit 1a5417f39a0ccefcdd5440f2a67f84d2d2e26960.
|
||||
|
||||
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
|
||||
Upstream: temporary revert, until upstream fixes the issue, see
|
||||
discussion at
|
||||
https://lists.gnu.org/archive/html/grub-devel/2026-02/msg00039.html
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||||
---
|
||||
acinclude.m4 | 5 -----
|
||||
configure.ac | 14 ++------------
|
||||
2 files changed, 2 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/acinclude.m4 b/acinclude.m4
|
||||
index 70c1912f8..fa7840f09 100644
|
||||
--- a/acinclude.m4
|
||||
+++ b/acinclude.m4
|
||||
@@ -79,11 +79,6 @@ AC_DEFUN([grub_PROG_OBJCOPY_ABSOLUTE],
|
||||
[AC_MSG_CHECKING([whether ${TARGET_OBJCOPY} works for absolute addresses])
|
||||
AC_CACHE_VAL(grub_cv_prog_objcopy_absolute,
|
||||
[cat > conftest.c <<\EOF
|
||||
-asm (
|
||||
- ".globl start, _start, __start\n"
|
||||
- ".ifdef cmain; .set start = _start = __start = cmain\n.endif\n"
|
||||
- ".ifdef _cmain; .set start = _start = __start = _cmain\n.endif\n"
|
||||
-);
|
||||
void cmain (void);
|
||||
void
|
||||
cmain (void)
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index d8ca1b7c1..041cfbab4 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1461,6 +1461,7 @@ elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_c
|
||||
TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/i386-cygwin-img-ld.sc"
|
||||
TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
|
||||
TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/i386-cygwin-img-ld.sc"
|
||||
+ TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||
TARGET_IMG_CFLAGS=
|
||||
else
|
||||
TARGET_APPLE_LINKER=0
|
||||
@@ -1468,6 +1469,7 @@ else
|
||||
TARGET_IMG_LDSCRIPT=
|
||||
TARGET_IMG_LDFLAGS='-Wl,-N'
|
||||
TARGET_IMG_LDFLAGS_AC='-Wl,-N'
|
||||
+ TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
|
||||
TARGET_IMG_CFLAGS=
|
||||
fi
|
||||
|
||||
@@ -1798,18 +1800,6 @@ grub_PROG_TARGET_CC
|
||||
m4_ifndef([AX_CHECK_LINK_FLAG], [m4_fatal([autoconf-archive is missing. You must install it to generate the configure script.])])
|
||||
|
||||
if test "x$TARGET_APPLE_LINKER" != x1 ; then
|
||||
-AX_CHECK_LINK_FLAG([-Wl,--image-base,0x400000],
|
||||
- [TARGET_IMG_BASE_LDOPT="-Wl,--image-base"],
|
||||
- [TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"],
|
||||
- [],
|
||||
- [AC_LANG_SOURCE([
|
||||
-asm (".globl start; start:");
|
||||
-asm (".globl _start; _start:");
|
||||
-asm (".globl __start; __start:");
|
||||
-void __main (void);
|
||||
-void __main (void) {}
|
||||
-int main (void);
|
||||
- ])])
|
||||
grub_PROG_OBJCOPY_ABSOLUTE
|
||||
fi
|
||||
grub_PROG_LD_BUILD_ID_NONE
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From d0f516385dc73e8dd92b78ce08c1df100434fe67 Mon Sep 17 00:00:00 2001
|
||||
From: Yi Zhao <yi.zhao@windriver.com>
|
||||
Date: Fri, 27 Feb 2026 13:58:44 +0800
|
||||
Subject: [PATCH] Revert "configure: Print a more helpful error if
|
||||
autoconf-archive is not installed"
|
||||
|
||||
This reverts commit ac042f3f58d33ce9cd5ff61750f06da1a1d7b0eb.
|
||||
|
||||
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
|
||||
Upstream: temporary revert, until upstream fixes the issue, see
|
||||
discussion at
|
||||
https://lists.gnu.org/archive/html/grub-devel/2026-02/msg00039.html
|
||||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||||
---
|
||||
configure.ac | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 041cfbab4..209c0fb11 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1794,11 +1794,6 @@ LIBS=""
|
||||
# Defined in acinclude.m4.
|
||||
grub_ASM_USCORE
|
||||
grub_PROG_TARGET_CC
|
||||
-
|
||||
-# The error message produced by autoconf if autoconf-archive is not installed is
|
||||
-# quite misleading and not very helpful. So, try point people in the right direction.
|
||||
-m4_ifndef([AX_CHECK_LINK_FLAG], [m4_fatal([autoconf-archive is missing. You must install it to generate the configure script.])])
|
||||
-
|
||||
if test "x$TARGET_APPLE_LINKER" != x1 ; then
|
||||
grub_PROG_OBJCOPY_ABSOLUTE
|
||||
fi
|
||||
--
|
||||
2.43.0
|
||||
|
||||
188
boot/grub2/Config.in
Normal file
188
boot/grub2/Config.in
Normal file
@@ -0,0 +1,188 @@
|
||||
config BR2_TARGET_GRUB2_ARCH_SUPPORTS
|
||||
bool
|
||||
default y if BR2_i386
|
||||
default y if BR2_x86_64
|
||||
default y if BR2_arm
|
||||
default y if BR2_aarch64
|
||||
default y if BR2_RISCV_64
|
||||
default y if BR2_loongarch64
|
||||
depends on BR2_USE_MMU
|
||||
|
||||
menuconfig BR2_TARGET_GRUB2
|
||||
bool "grub2"
|
||||
depends on BR2_TARGET_GRUB2_ARCH_SUPPORTS
|
||||
depends on BR2_USE_WCHAR
|
||||
select BR2_TARGET_GRUB2_I386_PC if \
|
||||
!BR2_TARGET_GRUB2_HAS_PTF && \
|
||||
(BR2_i386 || BR2_x86_64)
|
||||
select BR2_TARGET_GRUB2_ARM_UBOOT if \
|
||||
!BR2_TARGET_GRUB2_HAS_PTF && \
|
||||
BR2_arm
|
||||
select BR2_TARGET_GRUB2_ARM64_EFI if BR2_aarch64
|
||||
help
|
||||
GNU GRUB is a Multiboot boot loader. It was derived from
|
||||
GRUB, the GRand Unified Bootloader, which was originally
|
||||
designed and implemented by Erich Stefan Boleyn. GRUB 2 has
|
||||
replaced what was formerly known as GRUB (i.e. version
|
||||
0.9x), which has, in turn, become GRUB Legacy.
|
||||
|
||||
Amongst others, GRUB2 offers EFI support, which GRUB Legacy
|
||||
doesn't provide.
|
||||
|
||||
The file boot/grub2/grub.cfg is used by default as the Grub
|
||||
configuration file. It can be overridden using a rootfs
|
||||
overlay or post-build script.
|
||||
|
||||
For additional notes on using Grub 2 with Buildroot, see
|
||||
boot/grub2/readme.txt
|
||||
|
||||
http://www.gnu.org/software/grub/
|
||||
|
||||
if BR2_TARGET_GRUB2
|
||||
|
||||
config BR2_TARGET_GRUB2_HAS_LEGACY_BOOT
|
||||
bool
|
||||
|
||||
config BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
bool
|
||||
|
||||
config BR2_TARGET_GRUB2_HAS_PTF
|
||||
bool
|
||||
|
||||
config BR2_TARGET_GRUB2_I386_PC
|
||||
bool "i386-pc"
|
||||
depends on BR2_i386 || BR2_x86_64
|
||||
select BR2_TARGET_GRUB2_HAS_LEGACY_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting is a
|
||||
x86 or x86-64 legacy BIOS based platform.
|
||||
|
||||
config BR2_TARGET_GRUB2_I386_EFI
|
||||
bool "i386-efi"
|
||||
depends on BR2_i386 || BR2_x86_64
|
||||
select BR2_TARGET_GRUB2_HAS_PTF
|
||||
select BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting has a
|
||||
32 bits EFI BIOS. Note that some x86-64 platforms use a 32
|
||||
bits EFI BIOS, and this option should be used in this case.
|
||||
|
||||
config BR2_TARGET_GRUB2_X86_64_EFI
|
||||
bool "x86-64-efi"
|
||||
depends on BR2_x86_64
|
||||
select BR2_TARGET_GRUB2_HAS_PTF
|
||||
select BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting has a
|
||||
64 bits EFI BIOS.
|
||||
|
||||
config BR2_TARGET_GRUB2_ARM_UBOOT
|
||||
bool "arm-uboot"
|
||||
depends on BR2_arm
|
||||
select BR2_TARGET_GRUB2_HAS_LEGACY_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting is an
|
||||
ARM u-boot platform, and you want to boot Grub 2 as an u-boot
|
||||
compatible image.
|
||||
|
||||
config BR2_TARGET_GRUB2_ARM_EFI
|
||||
bool "arm-efi"
|
||||
depends on BR2_arm
|
||||
select BR2_TARGET_GRUB2_HAS_PTF
|
||||
select BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting is an
|
||||
ARM platform and you want to boot Grub 2 as an EFI
|
||||
application.
|
||||
|
||||
config BR2_TARGET_GRUB2_ARM64_EFI
|
||||
bool "arm64-efi"
|
||||
depends on BR2_aarch64
|
||||
select BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting is an
|
||||
Aarch64 platform and you want to boot Grub 2 as an EFI
|
||||
application.
|
||||
|
||||
config BR2_TARGET_GRUB2_RISCV64_EFI
|
||||
bool "riscv64-efi"
|
||||
depends on BR2_RISCV_64
|
||||
select BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting is a
|
||||
64bit RISC-V platform and you want to boot Grub 2 as an EFI
|
||||
application.
|
||||
|
||||
config BR2_TARGET_GRUB2_LOONGARCH64_EFI
|
||||
bool "loongarch64-efi"
|
||||
depends on BR2_loongarch64
|
||||
select BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
help
|
||||
Select this option if the platform you're targeting is a
|
||||
64bit LoongArch platform and you want to boot Grub 2 as an EFI
|
||||
application.
|
||||
|
||||
if BR2_TARGET_GRUB2_HAS_LEGACY_BOOT
|
||||
|
||||
comment "Options for the x86 legacy BIOS or ARM U-Boot support"
|
||||
|
||||
config BR2_TARGET_GRUB2_BOOT_PARTITION
|
||||
string "boot partition"
|
||||
default "hd0,msdos1"
|
||||
help
|
||||
Specify the partition where the /boot/grub/grub.cfg file is
|
||||
located. Use 'hd0,msdos1' for the first partition of the
|
||||
first disk if using a legacy partition table, or 'hd0,gpt1'
|
||||
if using GPT partition table.
|
||||
|
||||
config BR2_TARGET_GRUB2_BUILTIN_MODULES_PC
|
||||
string "builtin modules"
|
||||
default BR2_TARGET_GRUB2_BUILTIN_MODULES if BR2_TARGET_GRUB2_BUILTIN_MODULES != "" # legacy
|
||||
default "boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PC
|
||||
default "linux ext2 fat part_msdos normal" if BR2_TARGET_GRUB2_ARM_UBOOT
|
||||
|
||||
config BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC
|
||||
string "builtin config"
|
||||
default BR2_TARGET_GRUB2_BUILTIN_CONFIG if BR2_TARGET_GRUB2_BUILTIN_CONFIG != "" # legacy
|
||||
help
|
||||
Path to a Grub 2 configuration file that will be embedded
|
||||
into the Grub image itself. This allows to set the root
|
||||
device and other configuration parameters, but however menu
|
||||
entries cannot be described in this embedded configuration.
|
||||
|
||||
endif # BR2_TARGET_GRUB2_HAS_LEGACY_BOOT
|
||||
|
||||
if BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
|
||||
comment "Options for the EFI BIOS or ARM EFI support"
|
||||
|
||||
config BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI
|
||||
string "builtin modules"
|
||||
default BR2_TARGET_GRUB2_BUILTIN_MODULES if BR2_TARGET_GRUB2_BUILTIN_MODULES != "" # legacy
|
||||
default "boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop"
|
||||
|
||||
config BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI
|
||||
string "builtin config"
|
||||
default BR2_TARGET_GRUB2_BUILTIN_CONFIG if BR2_TARGET_GRUB2_BUILTIN_CONFIG != "" # legacy
|
||||
help
|
||||
Path to a Grub 2 configuration file that will be embedded
|
||||
into the Grub image itself. This allows to set the root
|
||||
device and other configuration parameters, but however menu
|
||||
entries cannot be described in this embedded configuration.
|
||||
|
||||
endif # BR2_TARGET_GRUB2_HAS_EFI_BOOT
|
||||
|
||||
config BR2_TARGET_GRUB2_INSTALL_TOOLS
|
||||
bool "install tools"
|
||||
help
|
||||
Install support tools to interact with GNU GRUB Multiboot
|
||||
boot loader.
|
||||
|
||||
This will also install the Grub 2 loadable modules to the
|
||||
target.
|
||||
|
||||
endif # BR2_TARGET_GRUB2
|
||||
|
||||
comment "grub2 needs a toolchain w/ wchar"
|
||||
depends on BR2_TARGET_GRUB2_ARCH_SUPPORTS
|
||||
depends on !BR2_USE_WCHAR
|
||||
6
boot/grub2/grub.cfg
Normal file
6
boot/grub2/grub.cfg
Normal file
@@ -0,0 +1,6 @@
|
||||
set default="0"
|
||||
set timeout="5"
|
||||
|
||||
menuentry "Buildroot" {
|
||||
linux /boot/bzImage root=/dev/sda1 rootwait console=tty1
|
||||
}
|
||||
5
boot/grub2/grub2.hash
Normal file
5
boot/grub2/grub2.hash
Normal file
@@ -0,0 +1,5 @@
|
||||
# Locally calculated after checking signature
|
||||
# https://ftp.gnu.org/gnu/grub/grub-2.14.tar.xz.sig
|
||||
sha256 bc8d3c73535b8838d8c8e2654d73edc4e6ae8c8acdb45d5df5dc9a1547446d43 grub-2.14.tar.xz
|
||||
# Locally computed:
|
||||
sha256 8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903 COPYING
|
||||
203
boot/grub2/grub2.mk
Normal file
203
boot/grub2/grub2.mk
Normal file
@@ -0,0 +1,203 @@
|
||||
################################################################################
|
||||
#
|
||||
# grub2
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GRUB2_VERSION = 2.14
|
||||
GRUB2_SITE = $(BR2_GNU_MIRROR)/grub
|
||||
GRUB2_SOURCE = grub-$(GRUB2_VERSION).tar.xz
|
||||
GRUB2_LICENSE = GPL-3.0+
|
||||
GRUB2_LICENSE_FILES = COPYING
|
||||
GRUB2_DEPENDENCIES = host-bison host-flex host-gawk host-grub2 \
|
||||
$(BR2_PYTHON3_HOST_DEPENDENCY)
|
||||
HOST_GRUB2_DEPENDENCIES = host-bison host-flex host-gawk \
|
||||
$(BR2_PYTHON3_HOST_DEPENDENCY)
|
||||
GRUB2_INSTALL_IMAGES = YES
|
||||
|
||||
# 0001-Revert-configure-Check-linker-for-image-base-support.patch
|
||||
# 0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch
|
||||
# Target grub2 package doesn't use autotools-package
|
||||
GRUB2_DEPENDENCIES += host-automake host-autoconf host-libtool host-pkgconf
|
||||
HOST_GRUB2_AUTORECONF = YES
|
||||
HOST_GRUB2_DEPENDENCIES += host-pkgconf
|
||||
|
||||
ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y)
|
||||
GRUB2_INSTALL_TARGET = YES
|
||||
else
|
||||
GRUB2_INSTALL_TARGET = NO
|
||||
endif
|
||||
GRUB2_CPE_ID_VENDOR = gnu
|
||||
|
||||
GRUB2_BUILTIN_MODULES_PC = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES_PC))
|
||||
GRUB2_BUILTIN_MODULES_EFI = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI))
|
||||
GRUB2_BUILTIN_CONFIG_PC = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC))
|
||||
GRUB2_BUILTIN_CONFIG_EFI = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI))
|
||||
GRUB2_BOOT_PARTITION = $(call qstrip,$(BR2_TARGET_GRUB2_BOOT_PARTITION))
|
||||
|
||||
GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img
|
||||
GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg
|
||||
GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub
|
||||
GRUB2_TARGET_i386-pc = i386
|
||||
GRUB2_PLATFORM_i386-pc = pc
|
||||
GRUB2_BUILTIN_CONFIG_i386-pc = $(GRUB2_BUILTIN_CONFIG_PC)
|
||||
GRUB2_BUILTIN_MODULES_i386-pc = $(GRUB2_BUILTIN_MODULES_PC)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pc
|
||||
|
||||
GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi
|
||||
GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
|
||||
GRUB2_PREFIX_i386-efi = /EFI/BOOT
|
||||
GRUB2_TARGET_i386-efi = i386
|
||||
GRUB2_PLATFORM_i386-efi = efi
|
||||
GRUB2_BUILTIN_CONFIG_i386-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
|
||||
GRUB2_BUILTIN_MODULES_i386-efi = $(GRUB2_BUILTIN_MODULES_EFI)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_EFI) += i386-efi
|
||||
|
||||
GRUB2_IMAGE_x86_64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootx64.efi
|
||||
GRUB2_CFG_x86_64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
|
||||
GRUB2_PREFIX_x86_64-efi = /EFI/BOOT
|
||||
GRUB2_TARGET_x86_64-efi = x86_64
|
||||
GRUB2_PLATFORM_x86_64-efi = efi
|
||||
GRUB2_BUILTIN_CONFIG_x86_64-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
|
||||
GRUB2_BUILTIN_MODULES_x86_64-efi = $(GRUB2_BUILTIN_MODULES_EFI)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_X86_64_EFI) += x86_64-efi
|
||||
|
||||
GRUB2_IMAGE_arm-uboot = $(BINARIES_DIR)/boot-part/grub/grub.img
|
||||
GRUB2_CFG_arm-uboot = $(BINARIES_DIR)/boot-part/grub/grub.cfg
|
||||
GRUB2_PREFIX_arm-uboot = ($(GRUB2_BOOT_PARTITION))/boot/grub
|
||||
GRUB2_TARGET_arm-uboot = arm
|
||||
GRUB2_PLATFORM_arm-uboot = uboot
|
||||
GRUB2_BUILTIN_CONFIG_arm-uboot = $(GRUB2_BUILTIN_CONFIG_PC)
|
||||
GRUB2_BUILTIN_MODULES_arm-uboot = $(GRUB2_BUILTIN_MODULES_PC)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_ARM_UBOOT) += arm-uboot
|
||||
|
||||
GRUB2_IMAGE_arm-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootarm.efi
|
||||
GRUB2_CFG_arm-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
|
||||
GRUB2_PREFIX_arm-efi = /EFI/BOOT
|
||||
GRUB2_TARGET_arm-efi = arm
|
||||
GRUB2_PLATFORM_arm-efi = efi
|
||||
GRUB2_BUILTIN_CONFIG_arm-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
|
||||
GRUB2_BUILTIN_MODULES_arm-efi = $(GRUB2_BUILTIN_MODULES_EFI)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_ARM_EFI) += arm-efi
|
||||
|
||||
GRUB2_IMAGE_arm64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootaa64.efi
|
||||
GRUB2_CFG_arm64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
|
||||
GRUB2_PREFIX_arm64-efi = /EFI/BOOT
|
||||
GRUB2_TARGET_arm64-efi = aarch64
|
||||
GRUB2_PLATFORM_arm64-efi = efi
|
||||
GRUB2_BUILTIN_CONFIG_arm64-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
|
||||
GRUB2_BUILTIN_MODULES_arm64-efi = $(GRUB2_BUILTIN_MODULES_EFI)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_ARM64_EFI) += arm64-efi
|
||||
|
||||
GRUB2_IMAGE_riscv64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootriscv64.efi
|
||||
GRUB2_CFG_riscv64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
|
||||
GRUB2_PREFIX_riscv64-efi = /EFI/BOOT
|
||||
GRUB2_TARGET_riscv64-efi = riscv64
|
||||
GRUB2_PLATFORM_riscv64-efi = efi
|
||||
GRUB2_BUILTIN_CONFIG_riscv64-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
|
||||
GRUB2_BUILTIN_MODULES_riscv64-efi = $(GRUB2_BUILTIN_MODULES_EFI)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_RISCV64_EFI) += riscv64-efi
|
||||
|
||||
GRUB2_IMAGE_loongarch64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootloongarch64.efi
|
||||
GRUB2_CFG_loongarch64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
|
||||
GRUB2_PREFIX_loongarch64-efi = /EFI/BOOT
|
||||
GRUB2_TARGET_loongarch64-efi = loongarch64
|
||||
GRUB2_PLATFORM_loongarch64-efi = efi
|
||||
GRUB2_BUILTIN_CONFIG_loongarch64-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
|
||||
GRUB2_BUILTIN_MODULES_loongarch64-efi = $(GRUB2_BUILTIN_MODULES_EFI)
|
||||
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_LOONGARCH64_EFI) += loongarch64-efi
|
||||
|
||||
# Grub2 is kind of special: it considers CC, LD and so on to be the
|
||||
# tools to build the host programs and uses TARGET_CC, TARGET_CFLAGS,
|
||||
# TARGET_CPPFLAGS, TARGET_LDFLAGS to build the bootloader itself.
|
||||
#
|
||||
# NOTE: TARGET_STRIP is overridden by !BR2_STRIP_strip, so always
|
||||
# use the cross compile variant to ensure grub2 builds
|
||||
|
||||
HOST_GRUB2_CONF_ENV = \
|
||||
CPP="$(HOSTCC) -E"
|
||||
|
||||
GRUB2_CONF_ENV = \
|
||||
CPP="$(TARGET_CC) -E" \
|
||||
TARGET_CC="$(TARGET_CC)" \
|
||||
CFLAGS="$(TARGET_CFLAGS) -Os" \
|
||||
TARGET_CFLAGS="$(TARGET_CFLAGS) -Os" \
|
||||
CPPFLAGS="$(TARGET_CPPFLAGS) -Os -fno-stack-protector" \
|
||||
TARGET_CPPFLAGS="$(TARGET_CPPFLAGS) -Os -fno-stack-protector" \
|
||||
TARGET_LDFLAGS="$(TARGET_LDFLAGS) -Os" \
|
||||
TARGET_NM="$(TARGET_NM)" \
|
||||
TARGET_OBJCOPY="$(TARGET_OBJCOPY)" \
|
||||
TARGET_STRIP="$(TARGET_CROSS)strip"
|
||||
|
||||
HOST_GRUB2_CONF_OPTS = \
|
||||
--with-platform=none \
|
||||
--disable-grub-mkfont \
|
||||
--enable-efiemu=no \
|
||||
ac_cv_lib_lzma_lzma_code=no \
|
||||
--enable-device-mapper=no \
|
||||
--enable-libzfs=no \
|
||||
--disable-werror
|
||||
|
||||
define GRUB2_CONFIGURE_CMDS
|
||||
cd $(@D); $(AUTORECONF)
|
||||
$(foreach tuple, $(GRUB2_TUPLES-y), \
|
||||
@$(call MESSAGE,Configuring $(tuple))
|
||||
mkdir -p $(@D)/build-$(tuple)
|
||||
cd $(@D)/build-$(tuple) && \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
$(TARGET_CONFIGURE_ARGS) \
|
||||
$(GRUB2_CONF_ENV) \
|
||||
../configure \
|
||||
--target=$(GRUB2_TARGET_$(tuple)) \
|
||||
--with-platform=$(GRUB2_PLATFORM_$(tuple)) \
|
||||
--host=$(GNU_TARGET_NAME) \
|
||||
--build=$(GNU_HOST_NAME) \
|
||||
--prefix=/ \
|
||||
--exec-prefix=/ \
|
||||
--disable-grub-mkfont \
|
||||
--enable-efiemu=no \
|
||||
ac_cv_lib_lzma_lzma_code=no \
|
||||
--enable-device-mapper=no \
|
||||
--enable-libzfs=no \
|
||||
--disable-werror
|
||||
)
|
||||
endef
|
||||
|
||||
define GRUB2_BUILD_CMDS
|
||||
$(foreach tuple, $(GRUB2_TUPLES-y), \
|
||||
@$(call MESSAGE,Building $(tuple))
|
||||
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple)
|
||||
)
|
||||
endef
|
||||
|
||||
define GRUB2_INSTALL_IMAGES_CMDS
|
||||
$(foreach tuple, $(GRUB2_TUPLES-y), \
|
||||
@$(call MESSAGE,Installing $(tuple) to images directory)
|
||||
mkdir -p $(dir $(GRUB2_IMAGE_$(tuple)))
|
||||
$(HOST_DIR)/bin/grub-mkimage \
|
||||
-d $(@D)/build-$(tuple)/grub-core/ \
|
||||
-O $(tuple) \
|
||||
-o $(GRUB2_IMAGE_$(tuple)) \
|
||||
-p "$(GRUB2_PREFIX_$(tuple))" \
|
||||
$(if $(GRUB2_BUILTIN_CONFIG_$(tuple)), \
|
||||
-c $(GRUB2_BUILTIN_CONFIG_$(tuple))) \
|
||||
$(GRUB2_BUILTIN_MODULES_$(tuple))
|
||||
$(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple))
|
||||
$(if $(findstring $(GRUB2_PLATFORM_$(tuple)), pc), \
|
||||
cat $(@D)/build-$(tuple)/grub-core/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \
|
||||
$(BINARIES_DIR)/grub-eltorito.img
|
||||
) \
|
||||
)
|
||||
endef
|
||||
|
||||
ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y)
|
||||
define GRUB2_INSTALL_TARGET_CMDS
|
||||
$(foreach tuple, $(GRUB2_TUPLES-y), \
|
||||
@$(call MESSAGE,Installing $(tuple) to target directory)
|
||||
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple) DESTDIR=$(TARGET_DIR) install
|
||||
)
|
||||
endef
|
||||
endif
|
||||
|
||||
$(eval $(generic-package))
|
||||
$(eval $(host-autotools-package))
|
||||
192
boot/grub2/readme.txt
Normal file
192
boot/grub2/readme.txt
Normal file
@@ -0,0 +1,192 @@
|
||||
Notes on using Grub2 for BIOS-based platforms
|
||||
=============================================
|
||||
|
||||
1. Create a disk image
|
||||
dd if=/dev/zero of=disk.img bs=1M count=32
|
||||
2. Partition it (either legacy or GPT style partitions work)
|
||||
cfdisk disk.img
|
||||
- Create one partition, type Linux, for the root
|
||||
filesystem. The only constraint is to make sure there
|
||||
is enough free space *before* the first partition to
|
||||
store Grub2. Leaving 1 MB of free space is safe.
|
||||
3. Setup loop device and loop partitions
|
||||
loop_dev=$(sudo losetup -f --show disk.img)
|
||||
sudo partx -a "$loop_dev"
|
||||
4. Prepare the root partition
|
||||
sudo mkfs.ext3 -L root "${loop_dev}p1"
|
||||
sudo mount "${loop_dev}p1" /mnt
|
||||
sudo tar -C /mnt -xf output/images/rootfs.tar
|
||||
sudo umount /mnt
|
||||
5. Install Grub2
|
||||
sudo ./output/host/sbin/grub-bios-setup \
|
||||
-b ./output/host/lib/grub/i386-pc/boot.img \
|
||||
-c ./output/images/grub.img -d . "$loop_dev"
|
||||
6. Cleanup loop device
|
||||
sudo partx -d "$loop_dev"
|
||||
sudo losetup -d "$loop_dev"
|
||||
7. Your disk.img is ready!
|
||||
|
||||
Using genimage
|
||||
--------------
|
||||
|
||||
If you use genimage to generate your complete image,
|
||||
installing Grub can be tricky. Here is how to achieve Grub's
|
||||
installation with genimage:
|
||||
|
||||
partition boot {
|
||||
in-partition-table = "no"
|
||||
image = "path_to_boot.img"
|
||||
offset = 0
|
||||
size = 512
|
||||
}
|
||||
partition grub {
|
||||
in-partition-table = "no"
|
||||
image = "path_to_grub.img"
|
||||
offset = 512
|
||||
}
|
||||
|
||||
The result is not byte to byte identical to what
|
||||
grub-bios-setup does but it works anyway.
|
||||
|
||||
To test your BIOS image in Qemu
|
||||
-------------------------------
|
||||
|
||||
qemu-system-{i386,x86_64} -hda disk.img
|
||||
|
||||
Notes on using Grub2 for x86/x86_64 EFI-based platforms
|
||||
=======================================================
|
||||
|
||||
1. Create a disk image
|
||||
dd if=/dev/zero of=disk.img bs=1M count=32
|
||||
2. Partition it with GPT partitions
|
||||
cgdisk disk.img
|
||||
- Create a first partition, type EF00, for the
|
||||
bootloader and kernel image
|
||||
- Create a second partition, type 8300, for the root
|
||||
filesystem.
|
||||
3. Setup loop device and loop partitions
|
||||
loop_dev=$(sudo losetup -f --show disk.img)
|
||||
sudo partx -a "$loop_dev"
|
||||
4. Prepare the boot partition
|
||||
sudo mkfs.vfat -n boot "${loop_dev}p1"
|
||||
sudo mount "${loop_dev}p1" /mnt
|
||||
sudo cp -a output/images/efi-part/* /mnt/
|
||||
sudo cp output/images/bzImage /mnt/
|
||||
sudo umount /mnt
|
||||
5. Prepare the root partition
|
||||
sudo mkfs.ext3 -L root "${loop_dev}p2"
|
||||
sudo mount "${loop_dev}p2" /mnt
|
||||
sudo tar -C /mnt -xf output/images/rootfs.tar
|
||||
sudo umount /mnt
|
||||
6 Cleanup loop device
|
||||
sudo partx -d "$loop_dev"
|
||||
sudo losetup -d "$loop_dev"
|
||||
7. Your disk.img is ready!
|
||||
|
||||
To test your i386/x86-64 EFI image in Qemu
|
||||
------------------------------------------
|
||||
|
||||
1. Download/install the EFI BIOS for Qemu
|
||||
You can get it using the edk2 package in Buildroot (installed
|
||||
in BINARIES_DIR), grab prebuilt images from the unofficial nightly
|
||||
builds [0], or use one provided by your distribution as OVMF.
|
||||
|
||||
[0] https://github.com/retrage/edk2-nightly
|
||||
|
||||
2. qemu-system-{i386,x86_64} -bios <path-to-OVMF.fd> -hda disk.img
|
||||
|
||||
Notes on using Grub2 for ARM u-boot-based platforms
|
||||
===================================================
|
||||
|
||||
The following steps show how to use the Grub2 arm-uboot platform
|
||||
support in the simplest way possible and with a single
|
||||
buildroot-generated filesystem.
|
||||
|
||||
1. Load qemu_arm_vexpress_defconfig
|
||||
|
||||
2. Enable u-boot with the vexpress_ca9x4 board name and with
|
||||
u-boot.elf image format.
|
||||
|
||||
3. Enable grub2 for the arm-uboot platform.
|
||||
|
||||
4. Enable "Install kernel image to /boot in target" in the kernel
|
||||
menu to populate a /boot directory with zImage in it.
|
||||
|
||||
5. The upstream u-boot vexpress_ca9x4 doesn't have CONFIG_API enabled
|
||||
by default, which is required.
|
||||
|
||||
Before building, patch u-boot (for example, make u-boot-extract to
|
||||
edit the source before building) file
|
||||
include/configs/vexpress_common.h to define:
|
||||
|
||||
#define CONFIG_API
|
||||
#define CONFIG_SYS_MMC_MAX_DEVICE 1
|
||||
|
||||
6. Create a custom grub2 config file with the following contents and
|
||||
set its path in BR2_TARGET_GRUB2_CFG:
|
||||
|
||||
set default="0"
|
||||
set timeout="5"
|
||||
|
||||
menuentry "Buildroot" {
|
||||
set root='(hd0)'
|
||||
linux /boot/zImage root=/dev/mmcblk0 console=ttyAMA0
|
||||
devicetree /boot/vexpress-v2p-ca9.dtb
|
||||
}
|
||||
|
||||
7. Create a custom builtin config file with the following contents
|
||||
and set its path in BR2_TARGET_GRUB2_BUILTIN_CONFIG:
|
||||
|
||||
set root=(hd0)
|
||||
set prefix=/boot/grub
|
||||
|
||||
8. Create a custom post-build script which copies files from
|
||||
${BINARIES_DIR}/boot-part to $(TARGET_DIR)/boot (set its path in
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT):
|
||||
|
||||
#!/bin/sh
|
||||
cp -r ${BINARIES_DIR}/boot-part/* ${TARGET_DIR}/boot/
|
||||
|
||||
9. make
|
||||
|
||||
10. Run qemu with:
|
||||
|
||||
qemu-system-arm -M vexpress-a9 -kernel output/images/u-boot -m 1024 \
|
||||
-nographic -sd output/images/rootfs.ext2
|
||||
|
||||
11. In u-boot, stop at the prompt and run grub2 with:
|
||||
|
||||
=> ext2load mmc 0:0 ${loadaddr} /boot/grub/grub.img
|
||||
=> bootm
|
||||
|
||||
12. This should bring the grub2 menu, upon which selecting the "Buildroot"
|
||||
entry should boot Linux.
|
||||
|
||||
|
||||
Notes on using Grub2 for Aarch64 EFI-based platforms
|
||||
====================================================
|
||||
|
||||
The following steps show how to use the Grub2 arm64-efi platform,
|
||||
using qemu and EFI firmware built for qemu.
|
||||
|
||||
1. Load aarch64_efi_defconfig
|
||||
|
||||
2. make
|
||||
|
||||
3. Download the EFI firmware for qemu aarch64
|
||||
|
||||
You can get it using the edk2 package in Buildroot (installed
|
||||
in BINARIES_DIR), grab prebuilt images from the unofficial nightly
|
||||
builds [1], or use one provided by your distribution as OVMF-aarch64
|
||||
or AAVMF.
|
||||
|
||||
[1] https://github.com/retrage/edk2-nightly
|
||||
|
||||
4. Run qemu with:
|
||||
|
||||
qemu-system-aarch64 -M virt -cpu cortex-a57 -m 512 -nographic \
|
||||
-bios <path/to/EDK2>/QEMU_EFI.fd -hda output/images/disk.img \
|
||||
-netdev user,id=eth0 -device virtio-net-device,netdev=eth0
|
||||
|
||||
5. This should bring the grub2 menu, upon which selecting the
|
||||
"Buildroot" entry should boot Linux.
|
||||
Reference in New Issue
Block a user