Yohann Martineau, blog, Boot coreboot, FILO and a tiny debian

Boot coreboot, FILO and a tiny debian

2012-04-29 19:27:38

I'm playing with open source bios software coreboot. To boot this opensource bios, I use qemu. I was bored of this default SEAbios prompt at virtual machine boot. So I decided to customize a bit my way to boot.

Actually, coreboot is just a piece of code that initialize hardware, it does not make a choice amongst bootable devices to start system. This task is performed by a payload. Actually, it's a payload for coreboot, but it's not the last payload we'll meet. Coreboot supports several payloads: SEAbios, FILO, custom linux, etc. Here, I will show how to install a FILO payload for coreboot and boot a tiny debian from this payload.

FILO is a bootloader that can read files on a local file system and use an image on a local file system to load an OS. So, after starting qemu, the boot sequence is: coreboot => FILO => tiny debian.

The first step is to retrieve coreboot and FILO. Actually, FILO has a dependency on libpayload, which is a library inside coreboot source code. So the compilation order will be: libpayload, FILO and coreboot.

Let's first create a root folder:

mkdir coreboot
In this directory, download coreboot source code:
cd coreboot
svn co svn://coreboot.org/coreboot/trunk coreboot-svn
We download FILO in coreboot-svn/payloads as it seems to be simpler to compile from here.
cd coreboot-svn/payloads
svn co https://svn.coreboot.org/filo/trunk/filo

Now, configure, build and install libpayload:

cd libpayload
make defconfig
make DESTDIR=../filo/build install
Now come back in filo folder and configure filo:
cd ../filo
make menuconfig
Use default options. You will see two make menuconfig interfaces, keep default options for both. You can now compile FILO:

Configure coreboot:

make menuconfig
Enter payload menu, choose "Add a payload", An ELF executable payload. Select your filo binary file (filo.elf) in "Payload path and filename"

Compile coreboot, compilation instructions can be found in bottom links:


My qemu version is a locally compiled one, not the latest one, but any reasonably recent qemu version should work.

Create tiny debian:

~/programs/qemu-0.14.1-local/bin/qemu-img create -f raw disk.img 2G
/sbin/mkfs.ext2 -F disk.img
# mkdir /mnt/rootfs
# mount -o loop disk.img /mnt/rootfs/
# mkdir /mnt/rootfs/boot
# cp /boot/vmlinuz-2.6.32-5-686 /mnt/rootfs/boot/vmlinuz
# cp /boot/initrd.img-2.6.32-5-686 /mnt/rootfs/boot/initrd
# apt-get install debootstrap
# debootstrap --arch i386 squeeze /mnt/rootfs/ http://ftp.debian.org/debian/
# umount /mnt/rootfs/
this listing:
  1. creates a qemu empty disk,
  2. format this disk to ext2 file system,
  3. as root, mount qemu disk locally,
  4. copy linux kernel and its temporary file system from real debian install to this new tiny boot file system,
  5. install debootstrap (first time only, of course), this tool creates tiny debian images using debian version in parameter. It will load packages from internet, you may have to be patient for this one,
  6. unmount cleanly this new file system.

start qemu:

~/programs/qemu-0.14.1-local/bin/qemu -bios coreboot-svn/build/coreboot.rom -hda disk.img -nographic

To start debian, in FILO, use:

root (hd0)
kernel /boot/vmlinuz root=/dev/sda initrd=/boot/initrd console=ttyS0
you may have to type Enter twice to see all feedback. Debian automatically renames /dev/hda to /dev/sda, this is the reason why we provide this root.

Once booted, you can see a debian root prompt!

Links, sources

Permanent link
linux, embedded systems, debian, english