aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorGravatar Peter Korsgaard <peter@korsgaard.com>2018-12-02 08:15:26 +0100
committerGravatar Peter Korsgaard <peter@korsgaard.com>2018-12-02 08:16:10 +0100
commit13c43455a05b036002e79808ca1c8e0d91d7871b (patch)
tree147ddbfc5486085018bb527de1a43961fc8ee1ca /boot
parent2e08c7398a47b414c288ea516514adac3edf00fb (diff)
parent0393f5d34433e34e49ff7ce0fb998735453ed4fc (diff)
downloadbuildroot-13c43455a05b036002e79808ca1c8e0d91d7871b.tar.gz
buildroot-13c43455a05b036002e79808ca1c8e0d91d7871b.tar.bz2
Merge branch 'next'
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'boot')
-rw-r--r--boot/grub2/Config.in48
-rw-r--r--boot/grub2/grub2.mk74
-rw-r--r--boot/grub2/readme.txt102
3 files changed, 192 insertions, 32 deletions
diff --git a/boot/grub2/Config.in b/boot/grub2/Config.in
index 9a61b3b633..e45133999e 100644
--- a/boot/grub2/Config.in
+++ b/boot/grub2/Config.in
@@ -2,6 +2,9 @@ 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
+ depends on BR2_USE_MMU
config BR2_TARGET_GRUB2
bool "grub2"
@@ -29,12 +32,14 @@ choice
config BR2_TARGET_GRUB2_I386_PC
bool "i386-pc"
+ depends on BR2_i386 || BR2_x86_64
help
Select this option if the platform you're targetting 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
help
Select this option if the platform you're targetting has a
32 bits EFI BIOS. Note that some x86-64 platforms use a 32
@@ -42,14 +47,38 @@ config BR2_TARGET_GRUB2_I386_EFI
config BR2_TARGET_GRUB2_X86_64_EFI
bool "x86-64-efi"
- depends on BR2_ARCH_IS_64
+ depends on BR2_x86_64
help
Select this option if the platform you're targetting has a
64 bits EFI BIOS.
+config BR2_TARGET_GRUB2_ARM_UBOOT
+ bool "arm-uboot"
+ depends on BR2_arm
+ help
+ Select this option if the platform you're targetting 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
+ help
+ Select this option if the platform you're targetting 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
+ help
+ Select this option if the platform you're targetting is an
+ Aarch64 platform and you want to boot Grub 2 as an EFI
+ application.
+
endchoice
-if BR2_TARGET_GRUB2_I386_PC
+if BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_ARM_UBOOT
config BR2_TARGET_GRUB2_BOOT_PARTITION
string "boot partition"
@@ -60,13 +89,15 @@ config BR2_TARGET_GRUB2_BOOT_PARTITION
first disk if using a legacy partition table, or 'hd0,gpt1'
if using GPT partition table.
-endif # BR2_TARGET_GRUB2_I386_PC
+endif # BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_ARM_UBOOT
config BR2_TARGET_GRUB2_BUILTIN_MODULES
string "builtin modules"
default "boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PC
default "boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop" \
- if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
+ if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI || \
+ BR2_TARGET_GRUB2_ARM_EFI || BR2_TARGET_GRUB2_ARM64_EFI
+ default "linux ext2 fat part_msdos normal" if BR2_TARGET_GRUB2_ARM_UBOOT
config BR2_TARGET_GRUB2_BUILTIN_CONFIG
string "builtin config"
@@ -76,6 +107,15 @@ config BR2_TARGET_GRUB2_BUILTIN_CONFIG
device and other configuration parameters, but however menu
entries cannot be described in this embedded configuration.
+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"
diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk
index 35aea41287..65371f0170 100644
--- a/boot/grub2/grub2.mk
+++ b/boot/grub2/grub2.mk
@@ -9,7 +9,15 @@ GRUB2_SITE = http://ftp.gnu.org/gnu/grub
GRUB2_SOURCE = grub-$(GRUB2_VERSION).tar.xz
GRUB2_LICENSE = GPL-3.0+
GRUB2_LICENSE_FILES = COPYING
-GRUB2_DEPENDENCIES = host-bison host-flex
+GRUB2_DEPENDENCIES = host-bison host-flex host-grub2
+HOST_GRUB2_DEPENDENCIES = host-bison host-flex
+GRUB2_INSTALL_IMAGES = YES
+
+ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y)
+GRUB2_INSTALL_TARGET = YES
+else
+GRUB2_INSTALL_TARGET = NO
+endif
GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES))
GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG))
@@ -36,29 +44,48 @@ GRUB2_PREFIX = /EFI/BOOT
GRUB2_TUPLE = x86_64-efi
GRUB2_TARGET = x86_64
GRUB2_PLATFORM = efi
+else ifeq ($(BR2_TARGET_GRUB2_ARM_UBOOT),y)
+GRUB2_IMAGE = $(BINARIES_DIR)/boot-part/grub/grub.img
+GRUB2_CFG = $(BINARIES_DIR)/boot-part/grub/grub.cfg
+GRUB2_PREFIX = ($(GRUB2_BOOT_PARTITION))/boot/grub
+GRUB2_TUPLE = arm-uboot
+GRUB2_TARGET = arm
+GRUB2_PLATFORM = uboot
+else ifeq ($(BR2_TARGET_GRUB2_ARM_EFI),y)
+GRUB2_IMAGE = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootarm.efi
+GRUB2_CFG = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
+GRUB2_PREFIX = /EFI/BOOT
+GRUB2_TUPLE = arm-efi
+GRUB2_TARGET = arm
+GRUB2_PLATFORM = efi
+else ifeq ($(BR2_TARGET_GRUB2_ARM64_EFI),y)
+GRUB2_IMAGE = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootaa64.efi
+GRUB2_CFG = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg
+GRUB2_PREFIX = /EFI/BOOT
+GRUB2_TUPLE = arm64-efi
+GRUB2_TARGET = aarch64
+GRUB2_PLATFORM = efi
endif
# Grub2 is kind of special: it considers CC, LD and so on to be the
-# tools to build the native tools (i.e to be executed on the build
-# machine), and uses TARGET_CC, TARGET_CFLAGS, TARGET_CPPFLAGS,
-# TARGET_LDFLAGS to build the bootloader itself. However, to add to
-# the confusion, it also uses NM, OBJCOPY and STRIP to build the
-# bootloader itself; none of these are used to build the native
-# tools.
+# 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 = \
- $(HOST_CONFIGURE_OPTS) \
- CPP="$(HOSTCC) -E" \
+ CPP="$(TARGET_CC) -E" \
TARGET_CC="$(TARGET_CC)" \
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
TARGET_CPPFLAGS="$(TARGET_CPPFLAGS) -fno-stack-protector" \
TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
- NM="$(TARGET_NM)" \
- OBJCOPY="$(TARGET_OBJCOPY)" \
- STRIP="$(TARGET_CROSS)strip"
+ TARGET_NM="$(TARGET_NM)" \
+ TARGET_OBJCOPY="$(TARGET_OBJCOPY)" \
+ TARGET_STRIP="$(TARGET_CROSS)strip"
GRUB2_CONF_OPTS = \
--target=$(GRUB2_TARGET) \
@@ -72,12 +99,13 @@ GRUB2_CONF_OPTS = \
--enable-libzfs=no \
--disable-werror
-# We don't want all the native tools and Grub2 modules to be installed
-# in the target. So we in fact install everything into the host
-# directory, and the image generation process (below) will use the
-# grub-mkimage tool and Grub2 modules from the host directory.
-
-GRUB2_INSTALL_TARGET_OPTS = DESTDIR=$(HOST_DIR) install
+HOST_GRUB2_CONF_OPTS = \
+ --disable-grub-mkfont \
+ --enable-efiemu=no \
+ ac_cv_lib_lzma_lzma_code=no \
+ --enable-device-mapper=no \
+ --enable-libzfs=no \
+ --disable-werror
ifeq ($(BR2_TARGET_GRUB2_I386_PC),y)
define GRUB2_IMAGE_INSTALL_ELTORITO
@@ -86,10 +114,10 @@ define GRUB2_IMAGE_INSTALL_ELTORITO
endef
endif
-define GRUB2_IMAGE_INSTALLATION
+define GRUB2_INSTALL_IMAGES_CMDS
mkdir -p $(dir $(GRUB2_IMAGE))
- $(HOST_DIR)/bin/grub-mkimage \
- -d $(HOST_DIR)/lib/grub/$(GRUB2_TUPLE) \
+ $(HOST_DIR)/usr/bin/grub-mkimage \
+ -d $(@D)/grub-core/ \
-O $(GRUB2_TUPLE) \
-o $(GRUB2_IMAGE) \
-p "$(GRUB2_PREFIX)" \
@@ -99,14 +127,14 @@ define GRUB2_IMAGE_INSTALLATION
$(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG)
$(GRUB2_IMAGE_INSTALL_ELTORITO)
endef
-GRUB2_POST_INSTALL_TARGET_HOOKS += GRUB2_IMAGE_INSTALLATION
ifeq ($(GRUB2_PLATFORM),efi)
define GRUB2_EFI_STARTUP_NSH
echo $(notdir $(GRUB2_IMAGE)) > \
$(BINARIES_DIR)/efi-part/startup.nsh
endef
-GRUB2_POST_INSTALL_TARGET_HOOKS += GRUB2_EFI_STARTUP_NSH
+GRUB2_POST_INSTALL_IMAGES_HOOKS += GRUB2_EFI_STARTUP_NSH
endif
$(eval $(autotools-package))
+$(eval $(host-autotools-package))
diff --git a/boot/grub2/readme.txt b/boot/grub2/readme.txt
index f6fd4566fe..0282fbdd13 100644
--- a/boot/grub2/readme.txt
+++ b/boot/grub2/readme.txt
@@ -53,8 +53,8 @@ To test your BIOS image in Qemu
qemu-system-{i386,x86-64} -hda disk.img
-Notes on using Grub2 for EFI-based platforms
-============================================
+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
@@ -83,16 +83,108 @@ Notes on using Grub2 for EFI-based platforms
sudo losetup -d /dev/loop0
7. Your disk.img is ready!
-To test your EFI image in Qemu
-------------------------------
+To test your i386/x86-64 EFI image in Qemu
+------------------------------------------
1. Download the EFI BIOS for Qemu
Version IA32 or X64 depending on the chosen Grub2
platform (i386-efi vs. x86-64-efi)
- http://sourceforge.net/projects/edk2/files/OVMF/
+ https://www.kraxel.org/repos/jenkins/edk2/
+ (or use one provided by your distribution as OVMF)
2. Extract, and rename OVMF.fd to bios.bin and
CirrusLogic5446.rom to vgabios-cirrus.bin.
3. qemu-system-{i386,x86-64} -L ovmf-dir/ -hda disk.img
4. Make sure to pass pci=nocrs to the kernel command line,
to workaround a bug in the EFI BIOS regarding the
EFI framebuffer.
+
+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
+ https://www.kraxel.org/repos/jenkins/edk2/
+ (or use one provided by your distribution as OVMF-aarch64 or AAVMF)
+
+ 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.