Build and Flash Coreboot With UEFI on Lenovo ThinkPad X200 and HP EliteBook 820 G2
2026-01-02T21:39:14+08:00
WARNING: The author wrote this guide just after his laptops SEEMED to work fine and may encounter issues in the future. The author is not responsible for any damages caused by following this guide.
Foreword
I have flashed Libreboot on my Lenovo ThinkPad X200 and my HP EliteBook 820 G2, but they only support SeaBIOS, which in turn only supports CSM. The Libreboot documentation states that their U-Boot supports EFI boot, but it never worked for me. Tianocore is a mature UEFI implementation within the free software community, and I recently discovered that I can build and flash a coreboot build with EDK II (a project within Tianocore) to enable EFI boot support.
Yesterday, I completed building and flashing both of my machines, and I am pleased to share the procedure.
Lenovo ThinkPad X200
For the Lenovo ThinkPad X200, the steps are relatively simple, and you can flash directly on top of your stock firmware. If you are currently using Libreboot, I suggest returning to the stock firmware first, as flashing directly over Libreboot is untested by me.
Step 1: Check your machine's chip size
Boot your machine with the iomem=relaxed parameter. If you are using Debian 13 or a distribution whose repository already contains flashprog, you can install it directly instead of building from source:
# apt install flashprog
On your machine, run:
# flashprog -p internal
You will see your chip size. If it is 4 MiB, unfortunately your machine may not be supported by coreboot with EDK II, as the firmware build will likely fail; however, you may still give it a try. If it is 8 MiB, it is supported — my X200 has an 8 MiB flash.
Step 2: Build the firmware
Obtain and prepare coreboot:
$ git clone https://review.coreboot.org/coreboot
$ cd coreboot
$ make help_toolchain
$ make crossgcc-i386 CPUS=$(nproc)
$ make -C payloads/coreinfo olddefconfig
$ make -C payloads/coreinfo
Open menuconfig:
$ make menuconfig
Then do the following:
- Choose Lenovo, ThinkPad X200 / X200s / X200t, and your chip size in the Mainboard section.
- Choose edk2 in Payload to add, disable Enable UEFI Secure Boot support, and enable Disable TPM support in edk2 in the Payload section.
- Leave everything else as-is, quit, and save the configuration.
Then run:
$ make -j$(nproc)
Your firmware will be located at ./build/coreboot.rom.
Step 3: Flash the firmware
On an external machine, prepare flashprog. Install it via your package manager if possible, or build it if necessary.
Follow Steps 2, 5, and the first half of Step 6 in this guide, then flash only the bios region using:
# flashprog -p serprog:dev=/dev/ttyACMx,spispeed=8M -w /path/to/rom/file.rom -c "MX25L6405D" --ifd -i bios
Boot your machine. You should see the coreboot logo. If so, the process is complete.
HP EliteBook 820 G2
This process is slightly more complicated than for the Lenovo ThinkPad X200.
Step 1: Flash Libreboot
I am unsure how to flash coreboot over stock firmware, so please follow this guide to flash Libreboot first. Afterwards, we can flash coreboot over Libreboot.
Step 2: Extract the blobs
Step 2.1: Extract the chip contents
Extract your chip multiple times and compare the hashes of the extracted ROM files:
# flashprog -p serprog:dev=/dev/ttyACMx,spispeed=8M -r /path/to/rom/file1.rom -c "MX25L12805D"
# flashprog -p serprog:dev=/dev/ttyACMx,spispeed=8M -r /path/to/rom/file2.rom -c "MX25L12805D"
...
$ sha256sum /path/to/rom/file1.rom
$ sha256sum /path/to/rom/file2.rom
...
If the hashes differ, repeat this step. If they are identical, proceed.
Step 2.2: Extract the blobs from the ROM file
Extract the memory reference code and external reference code from your extracted ROM file:
$ ./build/cbfstool /path/to/extracted/rom/file.rom extract -n mrc.bin -f /path/where/you/want/to/store/your/mrc.bin -m x86
$ ./build/cbfstool /path/to/extracted/rom/file.rom extract -n fallback/refcode -f /path/where/you/want/to/store/your/refcode.bin -m x86
Step 3: Build the firmware
Obtain and prepare coreboot:
$ git clone https://review.coreboot.org/coreboot
$ cd coreboot
$ make help_toolchain
$ make crossgcc-i386 CPUS=$(nproc)
$ make -C payloads/coreinfo olddefconfig
$ make -C payloads/coreinfo
Open menuconfig:
$ make menuconfig
Then do the following:
- Choose HP, EliteBook 820 G2, and your chip size. Set Size of coreboot owned area in ROM to
0x600000in the Mainboard section. - Choose the memory reference code and external reference code extracted in Step 2.2 in the Chipset section.
- Choose edk2 in Payload to add in the Payload section.
- Leave everything else as-is, quit, and save the configuration.
Then run:
$ make -j$(nproc)
Your firmware will be at ./build/coreboot.rom.
Step 4: Flash the firmware
On an external machine, prepare flashprog, your programmer, and flash only the bios region:
# flashprog -p serprog:dev=/dev/ttyACMx,spispeed=8M -w /path/to/rom/file.rom -c "MX25L12805D" --ifd -i bios --no-verifyall
Do not remove the --no-verifyall option; otherwise, errors may occur. Even with this option, flashprog will still verify the flash after writing.
Boot your machine. You should see the coreboot logo. The process is complete.