Build GRUB as a coreboot payload

Install git:

sudo apt install git

Clone the sources from git:

git clone git://git.savannah.gnu.org/grub.git grub
cd grub/
git checkout grub-2.12

Install build dependencies:

sudo apt install autoconf autogen automake autopoint bison build-essential flex help2man libdevmapper-dev libfreetype6-dev libfuse-dev liblzma-dev libpci-dev libssl-dev m4 ttf-dejavu ttf-unifont zlib1g-dev

Configure and make:

./bootstrap
./configure --with-platform=coreboot
make


Generate a payload, and include the DejaVu Sans Mono font (it can be found here):

pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci at_keyboard cbfs ehci ext2 fat ohci part_gpt part_msdos pata uhci usb_keyboard usbms usbserial_usbdebug' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg /boot/grub/fonts/dejavusansmono.pf2=./fonts/dejavusansmono.pf2


Optionally, you may wish to build a GRUB payload with different keyboard mappings (those can be found here):

pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci at_keyboard cbfs ehci ext2 fat ohci part_gpt part_msdos pata uhci usb_keyboard usbms usbserial_usbdebug' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg /boot/grub/layouts/deqwertz.gkb=./layouts/deqwertz.gkb /boot/grub/layouts/esqwerty.gkb=./layouts/esqwerty.gkb /boot/grub/layouts/frazerty.gkb=./layouts/frazerty.gkb /boot/grub/layouts/frdvbepo.gkb=./layouts/frdvbepo.gkb /boot/grub/layouts/itqwerty.gkb=./layouts/itqwerty.gkb /boot/grub/layouts/svenska.gkb=./layouts/svenska.gkb /boot/grub/layouts/keymaps/ukdvorak.gkb=./ukdvorak.gkb /boot/grub/layouts/ukqwerty.gkb=./layouts/ukqwerty.gkb /boot/grub/layouts/usdvorak.gkb=./layouts/usdvorak.gkb /boot/grub/layouts/keymaps/usqwerty.gkb=./usqwerty.gkb /boot/grub/fonts/dejavusansmono.pf2=./fonts/dejavusansmono.pf2