[coreboot] Reduce size of GRUB 2 payload (was: GRUB 2 is a great payload!)

Paul Menzel paulepanter at users.sourceforge.net
Sat Apr 11 11:13:57 CEST 2015


Dear Alexandru,


Am Montag, den 06.04.2015, 23:09 -0700 schrieb Alexandru Gagniuc:
> On Monday, April 06, 2015 11:22:18 PM Paul Menzel wrote:

> > Am Montag, den 06.04.2015, 14:07 -0700 schrieb Alexandru Gagniuc:
> > > On Monday, April 06, 2015 10:46:32 PM Paul Menzel wrote:
> > > > Am Donnerstag, den 26.03.2015, 11:54 -0700 schrieb Alexandru Gagniuc:
> > > > > On Thursday, March 26, 2015 07:53:04 AM Paul Menzel wrote:

[…]

> > > > And the cherry on top: If you don’t need a functionality, for example in
> > > > production after development, most of it is provided through modules.
> > > 
> > > Sure. You can trim off some of the fat. If you know how to trim enough so
> > > that it's comparable in size to SeaBIOS, please let me know.
> > 
> > I will.
>  
> I'm not geek enough to build GRUB2.

everybody knows, you are capable enough to do it. Otherwise Google would
not be your employer. ;-)

> Last time I did it, I was telepathically controlled by Vladimir via IRC.

Well, it’s now integrated into coreboot’s and GRUB’s build system.

In coreboot, just select GRUB as the payload in Kconfig. You can also do
the step manually.

In GRUB, just do (in a Git checkout) to get the payload
`default_payload.elf`.

        $ ./autogen.sh
        $ ./configure --with-platform=coreboot
        $ make -j
        $ make default_payload.elf
        pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg
        $ du -sh default_payload.elf
        720K	default_payload.elf

If you don’t want the default modules, adapt `Makefile` and edit the
target `default_payload`.

> > Please let me understand your point better. I don’t see, why that size
> > difference is a problem?
>  
> This shouldn't even be questioned. Smaller is always better. Anyhow, the big 
> issue is when you're running normal/fallback.
> 
> > Do you have a system where a 200 kB GRUB payload doesn’t fit?
> 
> I've had this issue on many occasions. Since I've gotten rid of MRC.bin on 
> butterfly, I've been able to do SeaBIOS/Grub2 fallback/normal. Might need a bit 
> of trimming to get to grub2/grub2.

Hmm, I don’t see how it can be a problem with flash ROM sizes of 4 MB.
But anyway, let’s remove most of the modules and only include cbfs and
`chain`. You need to tune your `grub.cfg` so it works. (Note, that I did
not test this yet.)

        $ make default_payload.elf
        pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='cbfs' --install-modules='chain' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg
        $ du -sh default_payload.elf
        168K	default_payload.elf
        $ xz default_payload.elf && du -sh default_payload.elf.xz
        64K	default_payload.elf.xz
        $ du -sh /seabios/out/bios.bin.elf
        72K	/home/paul/src/seabios/out/bios.bin.elf

So it’s well under a 100 KB.


Thanks,

Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20150411/ef3406ee/attachment-0001.asc>


More information about the coreboot mailing list