# vikings wiki

It's better when it's simple

User Tools

Site Tools


building_coreboot_from_source

Building coreboot from source

A step-by-step howto for a basic build of coreboot:

Download, configure and build coreboot

Install tools and libraries required for coreboot

Trisquel 8.0 LTS "Flidas" GNU/Linux

$ sudo apt install -y bison build-essential curl flex git gnat-5 libncurses5-dev m4 zlib1g-dev cmake gcc-multilib iasl  

If you are using a different distribution you might need to install the basic gcc toolchain, wget, make and/or other packages.

Download coreboot source tree

$ git clone https://review.coreboot.org/coreboot
$ cd coreboot  

This will download a 'read-only' copy of the coreboot tree. This just means that if you made changes to the coreboot tree, you couldn't immediately contribute them back to the community. To pull a copy of coreboot that would allow you to contribute back, you would first need to sign up for an account on gerrit.

Build the coreboot toolchain

Please note that this can take a significant amount of time (e.g. ~6 minutes on a Vikings D8 with 8 cores)

$ make crossgcc-i386 CPUS=$(nproc)  

“CPUS=$(nproc)” will build with the # of cores available in your system. If you'd prefer to use a different number of cores, e.g. only one, adjust to:

$ make crossgcc-i386 CPUS=1  

This builds one of the coreboot cross-compiler toolchains for x86 platforms. Because of the variability of compilers and the other required tools between the various operating systems that coreboot can be built on, coreboot supplies and uses its own cross-compiler toolchain to build the binaries that end up as part of the coreboot ROM. The toolchain provided by the operating system (the 'host toolchain') is used to build various tools that will run on the local system during the build process.

Build the payload - coreinfo

$ make -C payloads/coreinfo olddefconfig  \\
$ make -C payloads/coreinfo  

To actually do anything useful with coreboot, you need to build a payload to include in the rom. The idea behind coreboot is that it does the minimum amount possible before passing control of the machine to a payload. There are various payloads such as grub or SeaBIOS that are typically used to boot the operating system. Instead, we used coreinfo, a small demonstration payload that allows the user to look at various things such as memory and the contents of coreboot's cbfs - the pieces that make up the coreboot rom.

Configure the mainboard

This example configures a QEMU “mainboard”.

$ make menuconfig  \\
   select 'Mainboard' menu  \\
   Beside 'Mainboard vendor' should be '(Emulation)'  \\
   Beside 'Mainboard model' should be 'QEMU x86 i440fx/piix4'  \\
   select exit  \\
     \\
   select 'Payload' menu  \\
   select 'Add a Payload'  \\
   choose 'An Elf executable payload'  \\
   select '(payload.elf) Payload path and filename (NEW)'  \\
   enter 'payloads/coreinfo/build/coreinfo.elf'  \\
   select exit  \\
   select exit  \\
   select 'yes' to save the configuration as '.config' in the coreboot folder.  

This step configures coreboot's build options using the menuconfig interface to Kconfig. Kconfig is the same configuration program used by Linux (the kernel). It allows you to enable, disable and change various values to control the coreboot build process. Including which mainboard to use, which toolchain to use and how the runtime debug console should be presented and saved.

Anytime you change mainboards in Kconfig, you should always run “make distclean” before running “make menuconfig”. Due to the way that Kconfig works, values will be kept from the previous mainboard if you skip the clean step. This leads to a hybrid configuration which may or may not work as expected.

Build coreboot

$ make  

At the end of the build, you should see:

Built emulation/qemu-i440fx (QEMU x86 i440fx/piix4)  

This means your build was successful. The output from the build is in the build directory, so you'll find the rom file at 'coreboot/build/coreboot.rom'.

You may notice that a number of other pieces are downloaded at the beginning of the build process. These are the git submodules used in various coreboot builds. By default, the BLOBs submodule is not downloaded. This git submodule may be required for other builds for microcode or other binaries. To enable downloading this submodule, select the option “Allow use of binary-only repository” in the “General Setup” menu of Kconfig.

This attempts to build the coreboot rom. The rom file itself ends up in the build directory as 'coreboot.rom'. At the end of the build process, the build displayed the contents of the rom file.

Test the image using QEMU

Install QEMU

$ sudo apt install -y qemu  

QEMU is a processor emulator which we can use to show coreboot.

Run QEMU

No need to mention that this won't work in a headless system configuration.

Start QEMU, and point it to the ROM you just built:

$ qemu-system-x86_64 -bios build/coreboot.rom -serial stdio  

You should now see the serial output of coreboot in the original console window and a new window will appear running the coreinfo payload.

Here's the command line broken down:

qemu-system-x86_64  

This starts the QEMU emulator with the i440FX host PCI bridge and PIIX3 PCI to ISA bridge.

-bios build/coreboot.rom

Use the bios rom image that we just built. If this is left off, the standard SeaBIOS image that comes with QEMU is used.

-serial stdio

Send the serial output to the console. This allows you to view the coreboot debug output.

building_coreboot_from_source.txt · Last modified: 2023/04/16 12:04 by thum