[coreboot-gerrit] Change in coreboot[master]: payloads/external/GRUB2: configurable modules

Marty Plummer (Code Review) gerrit at coreboot.org
Sat Jan 20 22:15:39 CET 2018


Hello Marty E. Plummer,

I'd like you to do a code review. Please visit

    https://review.coreboot.org/23339

to review the following change.


Change subject: payloads/external/GRUB2: configurable modules
......................................................................

payloads/external/GRUB2: configurable modules

Currently one cannot configure what modules are installed into
default_payload.elf other than adding extra modules into it, so
grub2 is unable to be used as a payload on devices with small
flash.

Kconfig:
Add config item GRUB2_EXPERT_OPTIONS, with suboptions
GRUB2_DEFAULT_MODULES, GRUB2_PRELOAD_MODULES, and GRUB2_FS_MODULES.
GRUB2_FS_MODULES are separated as they are logically different and
otherwise the default config would be obscenely long.

Makefile:
Copy grub2/build/Makefile's 'default_payload.elf' make target here,
and use the above Kconfig options to configure which modules are
included and preloaded.
Use --target instead of --host when cross-compiling; --target is where
grub2 and its modules will run, --host is where the grub utilities
(grub-mkstandalone, grub-mkimage, etc) will run and more often than
not matches the --build machine.

Makefile.inc:
Pass these new Kconfig options to GRUB2's make call, and actually
pass CONFIG_ARCH_X86 as well.

Change-Id: I9203f164277a53946bb29ef2f2bc4b45a48b52cf
Signed-off-by: Marty E. Plummer <hanetzer at startmail.com>
---
M payloads/external/GRUB2/Kconfig
M payloads/external/GRUB2/Makefile
M payloads/external/Makefile.inc
3 files changed, 36 insertions(+), 5 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/23339/1

diff --git a/payloads/external/GRUB2/Kconfig b/payloads/external/GRUB2/Kconfig
index c4edab9..757b1c2 100644
--- a/payloads/external/GRUB2/Kconfig
+++ b/payloads/external/GRUB2/Kconfig
@@ -32,6 +32,28 @@
 	help
 	   The commit's SHA-1 or branch name of the revision to use.
 
+menuconfig GRUB2_EXPERT_OPTIONS
+	bool "Advanced GRUB configuration options (for devices with small flash)"
+	default n
+
+	config GRUB2_DEFAULT_MODULES
+		string "Default modules to include in GRUB image" if GRUB2_EXPERT_OPTIONS
+		default "cbls cbmemc cbtime chain configfile echo gzio halt help hexdump iorw linux linux16 ls lsacpi lsmmap lspci memrw minicmd multiboot normal password_pbkdf2 pcidump reboot regexp search serial setpci syslinuxcfg test xnu"
+		help
+		  Space-separated list of modules to include
+
+	config GRUB2_PRELOAD_MODULES
+		string "Modules to pre-load" if GRUB2_EXPERT_OPTIONS
+		default "ahci at_keyboard cbfs ehci ext2 fat ohci part_gpt part_msdos pata uhci usb_keyboard usbms usbserial_usbdebug"
+		help
+		  Space-separated list of modules to pre-load
+
+	config GRUB2_FS_MODULES
+		string "Default filesystem modules to include in GRUB image" if GRUB2_EXPERT_OPTIONS
+		default "affs afs bfs btrfs cbfs cpio cpio_be exfat ext2 fat hfs hfsplus iso9660 jfs minix minix2 minix2_be minix3 minix3_be minix_be newc nilfs2 ntfs odc procfs reiserfs romfs sfs squash4 tar udf ufs1 ufs1_be ufs2 xfs zfs"
+		help
+		  Space-separated list of filesystem modules to include
+
 config GRUB2_EXTRA_MODULES
 	string "Extra modules to include in GRUB image"
 	help
diff --git a/payloads/external/GRUB2/Makefile b/payloads/external/GRUB2/Makefile
index e2d8293..d26abc8 100644
--- a/payloads/external/GRUB2/Makefile
+++ b/payloads/external/GRUB2/Makefile
@@ -24,10 +24,10 @@
 			git branch -f $(NAME-y) $(TAG-y) && \
 			git checkout $(NAME-y) || true
 
+ARCH_TRIPLE=unsupported
 ifeq ($(CONFIG_ARCH_X86),y)
 ARCH_TRIPLE=i386-linux-gnu
-else
-ARCH_TRIPLE=unsupported
+IMAGE_FORMAT=i386-coreboot
 endif
 
 grub2/build/config.h: $(CONFIG_DEP) | checkout
@@ -37,7 +37,7 @@
 	cd grub2 && ./autogen.sh
 	cd grub2/build && ../configure CC="$(HOSTCC)" LD="$(LD)" \
 	TARGET_CC="$(CC)" TARGET_OBJCOPY="$(OBJCOPY)" TARGET_STRIP="$(STRIP)" \
-	CFLAGS=-O2 TARGET_CFLAGS=-Os --host=$(ARCH_TRIPLE) \
+	CFLAGS=-O2 TARGET_CFLAGS=-Os --target=$(ARCH_TRIPLE) \
 	--with-platform=coreboot --enable-boot-time --disable-werror
 
 config: grub2/build/config.h checkout
@@ -45,8 +45,13 @@
 grub2: config
 	echo "    MAKE       GRUB2 $(NAME-y)"
 	$(MAKE) -C grub2/build
-	$(MAKE) -C grub2/build default_payload.elf \
-		EXTRA_PAYLOAD_MODULES="$(CONFIG_GRUB2_EXTRA_MODULES)"
+	pkgdatadir=grub2/build ./grub2/build/grub-mkstandalone \
+		--grub-mkimage=./grub2/build/grub-mkimage -O \
+		$(IMAGE_FORMAT) -o grub2/build/default_payload.elf \
+		--modules="$(CONFIG_GRUB2_PRELOAD_MODULES) $(CONFIG_GRUB2_FS_MODULES)" \
+		--install-modules="$(CONFIG_GRUB2_DEFAULT_MODULES) $(CONFIG_GRUB2_EXTRA_MODULES)" \
+		--fonts= --themes= --locales= --directory=./grub2/build/grub-core/ \
+		/boot/grub/grub.cfg=./grub2/coreboot.cfg $(DTB)$(CONFIG_GRUB2_ARM_DTB_FILE)
 
 clean:
 	test -f grub2/build/Makefile && $(MAKE) -C grub2/build clean || exit 0
diff --git a/payloads/external/Makefile.inc b/payloads/external/Makefile.inc
index 62d8a44..7777aea 100644
--- a/payloads/external/Makefile.inc
+++ b/payloads/external/Makefile.inc
@@ -161,7 +161,11 @@
 			HOSTCC="$(HOSTCC)" \
 			CC="$(CC_x86_32)" LD="$(LD_x86_32)" \
 			OBJCOPY="$(OBJCOPY_x86_32)" STRIP="$(STRIP_x86_32)" \
+			CONFIG_ARCH_X86=$(CONFIG_ARCH_X86) \
 			CONFIG_DEP="$(abspath $(obj)/config.h)" \
+			CONFIG_GRUB2_PRELOAD_MODULES=$(CONFIG_GRUB2_PRELOAD_MODULES) \
+			CONFIG_GRUB2_DEFAULT_MODULES=$(CONFIG_GRUB2_DEFAULT_MODULES) \
+			CONFIG_GRUB2_FS_MODULES=$(CONFIG_GRUB2_FS_MODULES) \
 			CONFIG_GRUB2_STABLE=$(CONFIG_GRUB2_STABLE) \
 			CONFIG_GRUB2_MASTER=$(CONFIG_GRUB2_MASTER) \
 			CONFIG_GRUB2_REVISION=$(CONFIG_GRUB2_REVISION) \

-- 
To view, visit https://review.coreboot.org/23339
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9203f164277a53946bb29ef2f2bc4b45a48b52cf
Gerrit-Change-Number: 23339
Gerrit-PatchSet: 1
Gerrit-Owner: Marty Plummer <hanetzer at protonmail.com>
Gerrit-Reviewer: Marty E. Plummer <hanetzer at startmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180120/74133d35/attachment.html>


More information about the coreboot-gerrit mailing list