Add GRUB2 payload to build system

Since a long time GRUB 2 is a viable payload alternative to SeaBIOS and
FILO. So make it easy for coreboot users to use GRUB 2 as a payload by
integrating it into coreboot’s build system, so it can be selected in
Kconfig.

As the last GRUB 2 release 2.00 is too old and has several bugs when
used as a coreboot payload only allow to build GRUB 2 master until a new
GRUB release is done. The downside is, that accidental breakage in
GRUB’s upstream does not affect coreboot users.

Currently the GRUB 2 payload is built with the default modules which
results in an uncompressed size of around 730 kB. Compressed it has a
size of 340 kB, so it should be useable with 512 kB flash ROMs.

Tested with QEMU.

Change-Id: Ie75d5a2cb230390cd5a063d5f6a5d5e3fab6b354
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-on: http://review.coreboot.org/4058
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Vladimir Serbinenko 2013-11-14 12:10:08 +01:00 committed by Stefan Reinauer
parent c37b05c413
commit 113a366848
4 changed files with 85 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
build/ build/
coreboot-builds/ coreboot-builds/
payloads/external/FILO/filo/ payloads/external/FILO/filo/
payloads/external/GRUB2/grub2/
payloads/external/SeaBIOS/seabios/ payloads/external/SeaBIOS/seabios/
util/crossgcc/acpica-unix-*/ util/crossgcc/acpica-unix-*/
util/crossgcc/binutils-*/ util/crossgcc/binutils-*/

43
payloads/external/GRUB2/Makefile.inc vendored Normal file
View File

@ -0,0 +1,43 @@
TAG-$(CONFIG_GRUB2_MASTER)=
NAME-$(CONFIG_GRUB2_MASTER)=HEAD
unexport KCONFIG_AUTOCONFIG
all: grub2
checkout:
echo " GIT GRUB2 $(NAME-y)"
test -d grub2 || \
git clone git://git.sv.gnu.org/grub.git grub2
cd grub2 && \
git checkout master && \
git pull; \
test -n "$(TAG-y)" && \
git branch -f $(NAME-y) $(TAG-y) && \
git checkout $(NAME-y) || true
config: checkout
echo " CONFIG GRUB2 $(NAME-y)"
rm -rf grub2/build
mkdir grub2/build
cd grub2 && ./autogen.sh
cd grub2/build && ../configure BUILD_CC="$(HOSTCC)" CC="$(HOSTCC)" \
TARGET_CC="$(CC)" \
TARGET_OBJCOPY="$(OBJCOPY)" TARGET_STRIP="$(STRIP)" CFLAGS=-O2 TARGET_CFLAGS=-Os --with-platform=coreboot
grub2: config
echo " MAKE GRUB2 $(NAME-y)"
$(MAKE) -C grub2/build BUILD_CC="$(HOSTCC)" CC="$(HOSTCC)" \
TARGET_CC="$(CC)" TARGET_OBJCOPY="$(OBJCOPY)" \
TARGET_STRIP="$(STRIP)" CFLAGS=-O2 TARGET_CFLAGS=-Os \
&& $(MAKE) -C grub2/build BUILD_CC="$(HOSTCC)" CC="$(HOSTCC)" \
TARGET_CC="$(CC)" TARGET_OBJCOPY="$(OBJCOPY)" TARGET_STRIP="$(STRIP)" \
CFLAGS=-O2 TARGET_CFLAGS=-Os default_payload.elf
clean:
test -d grub2 && $(MAKE) -C grub2 clean || exit 0
distclean:
rm -rf grub2
.PHONY: checkout config grub2 clean distclean

View File

@ -569,6 +569,15 @@ config PAYLOAD_FILO
See http://coreboot.org/Payloads for more information. See http://coreboot.org/Payloads for more information.
config PAYLOAD_GRUB2
bool "GRUB2"
help
Select this option if you want to build a coreboot image
with a GRUB2 payload. If you don't know what this is
about, just leave it enabled.
See http://coreboot.org/Payloads for more information.
config PAYLOAD_TIANOCORE config PAYLOAD_TIANOCORE
bool "Tiano Core" bool "Tiano Core"
help help
@ -605,6 +614,17 @@ config SEABIOS_PS2_TIMEOUT
after powering on. This specifies how long SeaBIOS will wait for the after powering on. This specifies how long SeaBIOS will wait for the
keyboard controller to become ready before giving up. keyboard controller to become ready before giving up.
choice
prompt "GRUB2 version"
default GRUB2_MASTER
depends on PAYLOAD_GRUB2
config GRUB2_MASTER
bool "HEAD"
help
Newest GRUB2 version
endchoice
choice choice
prompt "FILO version" prompt "FILO version"
default FILO_STABLE default FILO_STABLE
@ -642,6 +662,10 @@ config PAYLOAD_FILE
depends on PAYLOAD_FILO depends on PAYLOAD_FILO
default "payloads/external/FILO/filo/build/filo.elf" default "payloads/external/FILO/filo/build/filo.elf"
config PAYLOAD_FILE
depends on PAYLOAD_GRUB2
default "payloads/external/GRUB2/grub2/build/default_payload.elf"
config PAYLOAD_FILE config PAYLOAD_FILE
string "Tianocore firmware volume" string "Tianocore firmware volume"
depends on PAYLOAD_TIANOCORE depends on PAYLOAD_TIANOCORE
@ -653,7 +677,7 @@ config PAYLOAD_FILE
config COMPRESSED_PAYLOAD_LZMA config COMPRESSED_PAYLOAD_LZMA
bool "Use LZMA compression for payloads" bool "Use LZMA compression for payloads"
default y default y
depends on PAYLOAD_ELF || PAYLOAD_SEABIOS || PAYLOAD_FILO || PAYLOAD_TIANOCORE depends on PAYLOAD_ELF || PAYLOAD_SEABIOS || PAYLOAD_FILO || PAYLOAD_TIANOCORE || PAYLOAD_GRUB2
help help
In order to reduce the size payloads take up in the ROM chip In order to reduce the size payloads take up in the ROM chip
coreboot can compress them using the LZMA algorithm. coreboot can compress them using the LZMA algorithm.

View File

@ -48,6 +48,9 @@ endif
ifeq ($(CONFIG_PAYLOAD_FILO),y) ifeq ($(CONFIG_PAYLOAD_FILO),y)
COREBOOT_ROM_DEPENDENCIES+=filo COREBOOT_ROM_DEPENDENCIES+=filo
endif endif
ifeq ($(CONFIG_PAYLOAD_GRUB2),y)
COREBOOT_ROM_DEPENDENCIES+=grub2
endif
extract_nth=$(word $(1), $(subst |, ,$(2))) extract_nth=$(word $(1), $(subst |, ,$(2)))
@ -113,6 +116,12 @@ ifeq ($(CONFIG_PAYLOAD_FILO),y)
@printf " PAYLOAD FILO (internal, compression: $(CBFS_PAYLOAD_COMPRESS_FLAG))\n" @printf " PAYLOAD FILO (internal, compression: $(CBFS_PAYLOAD_COMPRESS_FLAG))\n"
$(CBFSTOOL) $@.tmp add-payload -f $(CONFIG_PAYLOAD_FILE) -n $(CONFIG_CBFS_PREFIX)/payload -c $(CBFS_PAYLOAD_COMPRESS_FLAG) $(CBFSTOOL) $@.tmp add-payload -f $(CONFIG_PAYLOAD_FILE) -n $(CONFIG_CBFS_PREFIX)/payload -c $(CBFS_PAYLOAD_COMPRESS_FLAG)
endif endif
ifeq ($(CONFIG_PAYLOAD_GRUB2),y)
@printf " PAYLOAD GRUB2 (internal, compression: $(CBFS_PAYLOAD_COMPRESS_FLAG))\n"
$(CBFSTOOL) $@.tmp add-payload -f $(CONFIG_PAYLOAD_FILE) -n $(CONFIG_CBFS_PREFIX)/payload -c $(CBFS_PAYLOAD_COMPRESS_FLAG)
endif
ifeq ($(CONFIG_PAYLOAD_TIANOCORE),y) ifeq ($(CONFIG_PAYLOAD_TIANOCORE),y)
@printf " PAYLOAD Tiano Core (compression: $(CBFS_PAYLOAD_COMPRESS_FLAG))\n" @printf " PAYLOAD Tiano Core (compression: $(CBFS_PAYLOAD_COMPRESS_FLAG))\n"
$(CBFSTOOL) $@.tmp add-payload -f $(CONFIG_PAYLOAD_FILE) -n $(CONFIG_CBFS_PREFIX)/payload -c $(CBFS_PAYLOAD_COMPRESS_FLAG) $(CBFSTOOL) $@.tmp add-payload -f $(CONFIG_PAYLOAD_FILE) -n $(CONFIG_CBFS_PREFIX)/payload -c $(CBFS_PAYLOAD_COMPRESS_FLAG)
@ -440,3 +449,10 @@ filo:
CONFIG_FILO_MASTER=$(CONFIG_FILO_MASTER) \ CONFIG_FILO_MASTER=$(CONFIG_FILO_MASTER) \
CONFIG_FILO_STABLE=$(CONFIG_FILO_STABLE) CONFIG_FILO_STABLE=$(CONFIG_FILO_STABLE)
grub2:
$(MAKE) -C payloads/external/GRUB2 -f Makefile.inc \
HOSTCC="$(HOSTCC)" \
CC="$(CC)" LD="$(LD)" OBJDUMP="$(OBJDUMP)" \
OBJCOPY="$(OBJCOPY)" STRIP="$(STRIP)" \
CONFIG_GRUB2_MASTER=$(CONFIG_GRUB2_MASTER)