Skip to main content

Build coreboot

Building coreboot from source takes five steps on a Linux computer: install the build dependencies, download the coreboot source, build its cross-compiler toolchain (the slowest part), configure the build for your mainboard and payload, and compile it into a ROM image to flash.

Step 1: Install the build tools and libraries​

Step 1 installs the development tools and libraries coreboot needs to compile. The packages you need depend on your Linux distribution. Run the command that matches your system:

Debian-based distros (e.g., Ubuntu, Linux Mint):

sudo apt install -y python-is-python3 bison build-essential curl flex git gnat libncurses-dev libssl-dev libcmocka-dev zlib1g-dev pkgconf libpci-dev flashrom coreboot-utils

Arch-based distros (e.g., Manjaro, EndeavourOS):

sudo pacman -S base-devel curl git gcc-ada ncurses zlib

Red Hat-based distros (e.g., Fedora, CentOS, RHEL):

sudo dnf install git make gcc-gnat flex bison xz bzip2 gcc g++ ncurses-devel wget zlib-devel patch

If any package is missing, Coreboot may fail to build, so make sure the installation finishes without errors.

Step 2: Download the coreboot source​

Step 2 downloads the coreboot source from the official repository and moves into its directory:

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

This will give you the latest development version of Coreboot. If you want to build a specific version, you can check out the corresponding branch or tag after cloning.

Step 3: Build the coreboot toolchain​

Step 3 builds coreboot's own cross-compiler toolchain, which keeps builds reproducible and working on every supported board. You must build this toolchain before compiling Coreboot itself.

First, see which toolchains are available:

make help_toolchain
Output
*** Toolchain targets ***
crossgcc - Build coreboot cross-compilers for all platforms
crossgcc-clean - Remove all built coreboot cross-compilers
iasl - Build coreboot IASL compiler (built by all cross targets)
clang - Build coreboot clang compiler
nasm - Build coreboot nasm
test-toolchain - Reports if toolchain components are out of date
crossgcc-ARCH - Build cross-compiler for specific architecture
ARCH can be "i386", "x64", "arm", "aarch64", "riscv", "ppc64", "nds32le"
Use "make [target] CPUS=#" to build toolchain using multiple cores
Use "make [target] DEST=some/path" to install toolchain there
Use "make [target] BUILDGCC_OPTIONS="-m" to get packages from coreboot mirror"

Choose the one that matches your target architecture. For most x86 systems, including laptops like the ThinkPad T430s, use the i386 toolchain.

Examples:

make crossgcc-i386 CPUS=$(nproc) # build i386 toolchain
make crossgcc-aarch64 CPUS=$(nproc) # build Aarch64 toolchain
make crossgcc-riscv CPUS=$(nproc) # build RISC-V toolchain

Important notes:

  • The i386 toolchain works for all x86 and x86_64 boards.
  • You can try building with your system’s compiler, but this often causes build errors. The Coreboot toolchain is strongly recommended.

Step 4: Configure the build​

Step 4 configures coreboot for your computer, here a Lenovo ThinkPad T430s. The configuration decides how coreboot initialises the hardware and which payload, the software it hands over to after startup, it runs.

Run the interactive configuration menu:

make menuconfig

This menu lets you select various options such as the motherboard, ROM chip size, and payload.

Motherboard​

Navigate in the menu:

Mainboard --->
Mainboard vendor (Lenovo)
Mainboard model (ThinkPad T430s)
ROM chip size (16384 KB (16 MB))
< Exit >
note

Make sure the ROM chip size matches your actual hardware. Using the wrong size may result in a non-working firmware.

Payload​

A payload in Coreboot is a small program that Coreboot loads after it finishes initializing the hardware. Common payloads include:

  • SeaBIOS: provides a legacy BIOS environment to boot traditional operating systems.
  • GRUB2: a modern bootloader capable of booting Linux, Windows, and other systems, with more features than SeaBIOS.

Next, select your preferred payload.

SeaBIOS​

SeaBIOS provides a traditional BIOS interface, making it a simple choice for booting legacy operating systems or when you want a classic BIOS like experience.

Payload --->
Payload to add (SeaBIOS)
SeaBIOS version (1.16.3)
< Exit >
< Exit >
< Yes >

GRUB2​

GRUB2 is a modern, flexible bootloader that can boot Linux, Windows, and other systems. It is more powerful than SeaBIOS but requires some extra configuration.

Install the required dependencies for building the GRUB2 payload:

sudo apt install automake autoconf autopoint libfreetype6-dev unifont fonts-unifont unifont-bin gawk

In the configuration menu:

Payload --->
Payload to add (GRUB2)
GRUB version (2.12)
Extra modules to include in GRUB image (NEW)
[*]Include GRUB2 runtime config file into ROM image (NEW)
< Exit >
< Exit >
< Yes >

Add GRUB2 Extra Modules.

Modules extend GRUB’s capabilities, for example supporting USB, LVM, encryption, or different filesystems. For a typical laptop, include:

cryptodisk nativedisk ehci ohci usb usbms usbserial_pl2303 usbserial_ftdi usbserial_usbdebug jpeg all_video hashsum regexp linux part_msdos part_gpt lvm luks gcry_md5 gcry_sha1 gcry_sha256 gcry_sha512 gcry_rsa gcry_rijndael gcry_des search search_fs_file search_fs_uuid configfile probe

These modules ensure that GRUB can boot from internal disks, USB sticks, handle encrypted drives, and support multiple filesystems.

Create a basic grub.cfg to define the boot behavior and include it in the “Include GRUB2 runtime config file into ROM image” option.

grub.cfg
# Coreboot GRUB2: auto-boot with ESC menu and user instructions

set timeout=2
set timeout_style=hidden
set default=0

# Show instructions
echo "Press ESC to access the boot menu."
echo "Otherwise, the system will boot from the hard drive automatically."

### Primary entry: Boot internal disk ###
menuentry "Boot first disk" {
echo "Booting from the hard drive..."
search --no-floppy --set=root --file /grub/grub.cfg
configfile /grub/grub.cfg
}

### Secondary entry: Boot from USB via ESC ###
menuentry "Boot USB" {
search --no-floppy --removable --file /boot/grub/grub.cfg --set=root
configfile /grub/grub.cfg
}

Save the configuration to a file (optional)​

make savedefconfig
cat defconfig

For SeaBIOS, your configuration might include:

CONFIG_VENDOR_LENOVO=y
CONFIG_BOARD_LENOVO_T430S=y

For GRUB2, it might look like:

CONFIG_VENDOR_LENOVO=y
CONFIG_BOARD_LENOVO_T430S=y
CONFIG_PAYLOAD_GRUB2=y
CONFIG_GRUB2_EXTRA_MODULES="cryptodisk nativedisk ehci ohci usb usbms usbserial_pl2303 usbserial_ftdi usbserial_usbdebug jpeg all_video hashsum regexp linux part_msdos part_gpt lvm luks gcry_md5 gcry_sha1 gcry_sha256 gcry_sha512 gcry_rsa gcry_rijndael gcry_des search search_fs_file search_fs_uuid configfile probe"
CONFIG_GRUB2_INCLUDE_RUNTIME_CONFIG_FILE=y

The exact lines depend on the coreboot version, so more or fewer lines than these is normal.

Step 5: Build coreboot​

Step 5 compiles the coreboot image:

make

If the build completes successfully, you will see a message like:

Built lenovo/t430s (ThinkPad T430s)

The compiled ROM file will be located at build/coreboot.rom.

If you want to start fresh and remove all compiled files, run:

make distclean

This will reset the build environment so you can reconfigure and rebuild from scratch.

You now have a coreboot ROM to flash, internally or externally.