<p>Marty Plummer would like Marty E. Plummer to <strong>review</strong> this change.</p><p><a href="https://review.coreboot.org/23339">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">payloads/external/GRUB2: configurable modules<br><br>Currently one cannot configure what modules are installed into<br>default_payload.elf other than adding extra modules into it, so<br>grub2 is unable to be used as a payload on devices with small<br>flash.<br><br>Kconfig:<br>Add config item GRUB2_EXPERT_OPTIONS, with suboptions<br>GRUB2_DEFAULT_MODULES, GRUB2_PRELOAD_MODULES, and GRUB2_FS_MODULES.<br>GRUB2_FS_MODULES are separated as they are logically different and<br>otherwise the default config would be obscenely long.<br><br>Makefile:<br>Copy grub2/build/Makefile's 'default_payload.elf' make target here,<br>and use the above Kconfig options to configure which modules are<br>included and preloaded.<br>Use --target instead of --host when cross-compiling; --target is where<br>grub2 and its modules will run, --host is where the grub utilities<br>(grub-mkstandalone, grub-mkimage, etc) will run and more often than<br>not matches the --build machine.<br><br>Makefile.inc:<br>Pass these new Kconfig options to GRUB2's make call, and actually<br>pass CONFIG_ARCH_X86 as well.<br><br>Change-Id: I9203f164277a53946bb29ef2f2bc4b45a48b52cf<br>Signed-off-by: Marty E. Plummer <hanetzer@startmail.com><br>---<br>M payloads/external/GRUB2/Kconfig<br>M payloads/external/GRUB2/Makefile<br>M payloads/external/Makefile.inc<br>3 files changed, 36 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/39/23339/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/payloads/external/GRUB2/Kconfig b/payloads/external/GRUB2/Kconfig</span><br><span>index c4edab9..757b1c2 100644</span><br><span>--- a/payloads/external/GRUB2/Kconfig</span><br><span>+++ b/payloads/external/GRUB2/Kconfig</span><br><span>@@ -32,6 +32,28 @@</span><br><span>     help</span><br><span>            The commit's SHA-1 or branch name of the revision to use.</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+menuconfig GRUB2_EXPERT_OPTIONS</span><br><span style="color: hsl(120, 100%, 40%);">+ bool "Advanced GRUB configuration options (for devices with small flash)"</span><br><span style="color: hsl(120, 100%, 40%);">+   default n</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   config GRUB2_DEFAULT_MODULES</span><br><span style="color: hsl(120, 100%, 40%);">+          string "Default modules to include in GRUB image" if GRUB2_EXPERT_OPTIONS</span><br><span style="color: hsl(120, 100%, 40%);">+           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"</span><br><span style="color: hsl(120, 100%, 40%);">+          help</span><br><span style="color: hsl(120, 100%, 40%);">+            Space-separated list of modules to include</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        config GRUB2_PRELOAD_MODULES</span><br><span style="color: hsl(120, 100%, 40%);">+          string "Modules to pre-load" if GRUB2_EXPERT_OPTIONS</span><br><span style="color: hsl(120, 100%, 40%);">+                default "ahci at_keyboard cbfs ehci ext2 fat ohci part_gpt part_msdos pata uhci usb_keyboard usbms usbserial_usbdebug"</span><br><span style="color: hsl(120, 100%, 40%);">+              help</span><br><span style="color: hsl(120, 100%, 40%);">+            Space-separated list of modules to pre-load</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       config GRUB2_FS_MODULES</span><br><span style="color: hsl(120, 100%, 40%);">+               string "Default filesystem modules to include in GRUB image" if GRUB2_EXPERT_OPTIONS</span><br><span style="color: hsl(120, 100%, 40%);">+                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"</span><br><span style="color: hsl(120, 100%, 40%);">+             help</span><br><span style="color: hsl(120, 100%, 40%);">+            Space-separated list of filesystem modules to include</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> config GRUB2_EXTRA_MODULES</span><br><span>      string "Extra modules to include in GRUB image"</span><br><span>    help</span><br><span>diff --git a/payloads/external/GRUB2/Makefile b/payloads/external/GRUB2/Makefile</span><br><span>index e2d8293..d26abc8 100644</span><br><span>--- a/payloads/external/GRUB2/Makefile</span><br><span>+++ b/payloads/external/GRUB2/Makefile</span><br><span>@@ -24,10 +24,10 @@</span><br><span>                      git branch -f $(NAME-y) $(TAG-y) && \</span><br><span>                        git checkout $(NAME-y) || true</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ARCH_TRIPLE=unsupported</span><br><span> ifeq ($(CONFIG_ARCH_X86),y)</span><br><span> ARCH_TRIPLE=i386-linux-gnu</span><br><span style="color: hsl(0, 100%, 40%);">-else</span><br><span style="color: hsl(0, 100%, 40%);">-ARCH_TRIPLE=unsupported</span><br><span style="color: hsl(120, 100%, 40%);">+IMAGE_FORMAT=i386-coreboot</span><br><span> endif</span><br><span> </span><br><span> grub2/build/config.h: $(CONFIG_DEP) | checkout</span><br><span>@@ -37,7 +37,7 @@</span><br><span>   cd grub2 && ./autogen.sh</span><br><span>     cd grub2/build && ../configure CC="$(HOSTCC)" LD="$(LD)" \</span><br><span>       TARGET_CC="$(CC)" TARGET_OBJCOPY="$(OBJCOPY)" TARGET_STRIP="$(STRIP)" \</span><br><span style="color: hsl(0, 100%, 40%);">-   CFLAGS=-O2 TARGET_CFLAGS=-Os --host=$(ARCH_TRIPLE) \</span><br><span style="color: hsl(120, 100%, 40%);">+  CFLAGS=-O2 TARGET_CFLAGS=-Os --target=$(ARCH_TRIPLE) \</span><br><span>       --with-platform=coreboot --enable-boot-time --disable-werror</span><br><span> </span><br><span> config: grub2/build/config.h checkout</span><br><span>@@ -45,8 +45,13 @@</span><br><span> grub2: config</span><br><span>      echo "    MAKE       GRUB2 $(NAME-y)"</span><br><span>      $(MAKE) -C grub2/build</span><br><span style="color: hsl(0, 100%, 40%);">-  $(MAKE) -C grub2/build default_payload.elf \</span><br><span style="color: hsl(0, 100%, 40%);">-            EXTRA_PAYLOAD_MODULES="$(CONFIG_GRUB2_EXTRA_MODULES)"</span><br><span style="color: hsl(120, 100%, 40%);">+       pkgdatadir=grub2/build ./grub2/build/grub-mkstandalone \</span><br><span style="color: hsl(120, 100%, 40%);">+              --grub-mkimage=./grub2/build/grub-mkimage -O \</span><br><span style="color: hsl(120, 100%, 40%);">+                $(IMAGE_FORMAT) -o grub2/build/default_payload.elf \</span><br><span style="color: hsl(120, 100%, 40%);">+          --modules="$(CONFIG_GRUB2_PRELOAD_MODULES) $(CONFIG_GRUB2_FS_MODULES)" \</span><br><span style="color: hsl(120, 100%, 40%);">+            --install-modules="$(CONFIG_GRUB2_DEFAULT_MODULES) $(CONFIG_GRUB2_EXTRA_MODULES)" \</span><br><span style="color: hsl(120, 100%, 40%);">+         --fonts= --themes= --locales= --directory=./grub2/build/grub-core/ \</span><br><span style="color: hsl(120, 100%, 40%);">+          /boot/grub/grub.cfg=./grub2/coreboot.cfg $(DTB)$(CONFIG_GRUB2_ARM_DTB_FILE)</span><br><span> </span><br><span> clean:</span><br><span>    test -f grub2/build/Makefile && $(MAKE) -C grub2/build clean || exit 0</span><br><span>diff --git a/payloads/external/Makefile.inc b/payloads/external/Makefile.inc</span><br><span>index 62d8a44..7777aea 100644</span><br><span>--- a/payloads/external/Makefile.inc</span><br><span>+++ b/payloads/external/Makefile.inc</span><br><span>@@ -161,7 +161,11 @@</span><br><span>                   HOSTCC="$(HOSTCC)" \</span><br><span>                       CC="$(CC_x86_32)" LD="$(LD_x86_32)" \</span><br><span>                    OBJCOPY="$(OBJCOPY_x86_32)" STRIP="$(STRIP_x86_32)" \</span><br><span style="color: hsl(120, 100%, 40%);">+                     CONFIG_ARCH_X86=$(CONFIG_ARCH_X86) \</span><br><span>                         CONFIG_DEP="$(abspath $(obj)/config.h)" \</span><br><span style="color: hsl(120, 100%, 40%);">+                   CONFIG_GRUB2_PRELOAD_MODULES=$(CONFIG_GRUB2_PRELOAD_MODULES) \</span><br><span style="color: hsl(120, 100%, 40%);">+                        CONFIG_GRUB2_DEFAULT_MODULES=$(CONFIG_GRUB2_DEFAULT_MODULES) \</span><br><span style="color: hsl(120, 100%, 40%);">+                        CONFIG_GRUB2_FS_MODULES=$(CONFIG_GRUB2_FS_MODULES) \</span><br><span>                         CONFIG_GRUB2_STABLE=$(CONFIG_GRUB2_STABLE) \</span><br><span>                         CONFIG_GRUB2_MASTER=$(CONFIG_GRUB2_MASTER) \</span><br><span>                         CONFIG_GRUB2_REVISION=$(CONFIG_GRUB2_REVISION) \</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23339">change 23339</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/23339"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I9203f164277a53946bb29ef2f2bc4b45a48b52cf </div>
<div style="display:none"> Gerrit-Change-Number: 23339 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Marty Plummer <hanetzer@protonmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Marty E. Plummer <hanetzer@startmail.com> </div>