Design a site like this with
Get started

Coreboot for the Lenovo T420 / T420i with Ivy Bridge support

Usually I tend to decline offers for old laptops, because I have too many projects anyway, but when a friend offered me a broken T420, I thought “Hmm, good opportunity to try out Coreboot…”. Because, why not?!

The laptop

The device arrived in a sad state: It was dirty, had old stickers on it, its screws had been tortured by the wrong screwdriver type, it didn’t have a cooler and the WiFi card had its main antenna connector ripped right off. After restoring the device to a clean, working state and resoldering an antenna connector, I tested booting it, but the “click-click” sounds from the hard disk told me, that the drive was gone for good. But the laptop booted Linux Mint 20 flawlessly from a USB stick – First success!

I flashed the latest stock BIOS (v1.52) and a modded BIOS (based on v1.52) to remove the Lenovo WiFi card whitelist and allow RAM speeds > 1333MHz. But I wanted to go one step further. The Laptop had an Intel i5 2520M (2.5 / 3.2 GHz) and one 4GB DDR3 1333MHz DDR3 SO-DIMM installed. I heard that by flashing Coreboot instead of the stock the BIOS you could use an Ivy Bridge CPU. I found 2 x 4GB of 1600MHz DDR3L RAM* and an Intel i5 3360M (2.8 / 3.5 GHz) for a couple of Euros on EBay and decided to give it a shot. The CPUs are both 35W types, but the newer i5 has ~15% more performance, supports 1600MHz RAM and the HD4000 IGP is more capable when it comes to graphics and hardware video decoding.

* The Coreboot Intel RAMinit page says 1.35V RAM is not supported, but the Thinkpad Wiki mentions DDR3L RAM as being usable with the stock BIOS. People on the Coreboot IRC said DDR3L should work, as it’s merely “better” RAM that supports both 1.5V and 1.35V. I used 2 sticks of 4GB 1Rx8 PC3L-12800S CL11 RAM (Samsung M471B5173QH0-YK0 / resp. EB0-YK0) which worked fine for me.

Preparing yourself and the laptop

  • Install the latest BIOS to update the EC. You will need Windows for this, which you can boot off of an USB drive if you want.
  • Optional: Install the modded BIOS AFTER installing the latest stock BIOS. It worked flawlessly for me. Needs Windows too though.
  • You have to disassemble the whole device to get the mainboard out, because the flash chip in hidden under the aluminum frame. You can consult the internet or the T420 Hardware Maintenance Manual on how to do this.
  • After disassembly check which flash chip you have (mine was a Macronix MX25L6406E), as a different brand or model could be installed in you laptop (see Coreboot page for the T420).
  • Have a means to flash an SMD SPI flash chip. This can be done using a Raspberry Pi (any model will do). You will need to solder leads to the flash chip or use something like a (Pomona) SOIC8 test clip.
  • Make sure you DISCONNECT ALL POWER SOURCES from the laptop mainboard (power supply, battery and CMOS battery) before soldering to the flash chip or connecting the RPi!

First make sure you can make a proper connection to the flash chip. I decided to solder leads to the chip and use a flat, 6-pin 2,5mm board connector / DIP socket to install the connection to the flash chip permanently.

This way you don’t have to disassemble the whole device all over again when something goes wrong and the installed ROM doesn’t boot. Not that anything ever goes wrong…

I added a bit of hot glue to the chip and the leads so they don’t wiggle off and reassembled the laptop:

Now you can connect the flash chip to RPi (mainboard and RPi POWERED OFF). My handwriting is awful, but you’ll get the idea…

Backing up the stock BIOS

Make sure you can boot up the RPi and log into it. It doesn’t hurt to update the system so you have a recent version of flashrom on it. You will need to edit “/boot/config.txt” to enable SPI:


Make sure the SPI driver is loaded by adding it to “/etc/modules”:


Install flashrom if it isn’t installed yet:

sudo apt install flashrom

Now reboot the RPi to active SPI and try to detect the flash chip:

sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=4000

If flashrom tells you it was able to find the chip, it will look something like this:

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Macronix flash chip "MX25L6405" (8192 kB, SPI) on linux_spi.

If flashrom failed to find the chip, it will look something like this:

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Generic flash chip "unknown SPI chip (RDID)" (0 kB, SPI) on linux_spi.

If this happens, check the electrical connections and / or lower the SPI speed (from 4MHz / 4000 to 2000, 1000 or 500) and try again. If flashrom finds a chip, but isn’t sure which type it is, you have to specify the type:

sudo flashrom -c "MX25L6406E/MX25L6408E" -p linux_spi:dev=/dev/spidev0.0,spispeed=4000

Now you can read the stock ROM from the chip and compare the dumps:

sudo flashrom -c "MX25L6406E/MX25L6408E" -p linux_spi:dev=/dev/spidev0.0,spispeed=4000 -r stock_01.rom
sudo flashrom -c "MX25L6406E/MX25L6408E" -p linux_spi:dev=/dev/spidev0.0,spispeed=4000 -r stock_02.rom
md5sum stock_01.rom stock_02.rom

Make sure md5sum gives you the same MD5 checksum for both files:

aa4136e10015f7e854eb6ab68fcb9abb stock_01.rom
aa4136e10015f7e854eb6ab68fcb9abb stock_02.rom

If not, reduce the SPI speed and repeat the process until the checksums match to be sure the ROM was read correctly! Then backup the 8MB ROM file somewhere safe to make sure you can restore it if needed.

Preparing Coreboot

To compile Coreboot you need the dumped stock ROM from the previous step. There is Libreboot which is a Coreboot distribution and excludes proprietary firmware blobs, but afaik it has no support for the T420 / T420i.

First install some Coreboot dependencies to the computer you will be compiling the new ROM on:

sudo apt install git build-essential gnat flex bison libncurses5-dev wget zlib1g-dev

Now clone Coreboot and build ifdtool:

git clone ~/coreboot
cd ~/coreboot
git submodule update --init --recursive
cd ~/coreboot/util/ifdtool
cd ~

You can now decompile your ROM dump, move its parts to the proper directory and rename them to compile them into the new ROM:

mkdir -p ~/coreboot/3rdparty/blobs/mainboard/lenovo/t420
cp stock_02.rom ~/coreboot/3rdparty/blobs/mainboard/lenovo/t420
cd ~/coreboot/3rdparty/blobs/mainboard/lenovo/t420
~/coreboot/util/ifdtool/ifdtool -x stock_02.rom
mv flashregion_0_flashdescriptor.bin descriptor.bin
mv flashregion_2_intel_me.bin me.bin
mv flashregion_3_gbe.bin gbe.bin

Also add the latest video BIOS (VBIOS 2170) with Sandy Bridge and Ivy Bridge support. Copy the (same) video BIOS ROM file to “pci8086,0126.rom” and “pci8086,0166.rom” in the base Coreboot directory. This was mandatory for me to get a working boot splash.

If you want to add a boot splash image, add a 1024×768 pixel (keep in mind that it will be stretched to the screen resolution) “bootsplash.jpg” file to the base Coreboot directory. Use these encoding options in GIMP (“Ganzzahlen” = “Integer”):

Here is a working bootsplash.jpg for the lower-resolution 1366×768 screen:

Thinkpad logo from Wikipedia (seems to be PD)

Compiling Coreboot

Now that everything is prepared you can configure Coreboot and set everything up:

cd ~/coreboot
make nconfig

Use these settings:

When you’re done install some tools for the compilation process:

make crossgcc-i386 CPUS=$(nproc)
make iasl

then finally build your ROM:

make -j$(nproc)

If the build succeeds you will find an 8MB “coreboot.rom” in the “~/coreboot/build” directory, which you can copy to the machine you will be flashing the BIOS from.

Flashing the new BIOS

Copy your new “coreboot.rom” to the machine you’re flashing from, e.g. the RPi. Make sure you DISCONNECT ALL POWER SOURCES from the laptop mainboard (power supply, battery and CMOS battery) before connecting the RPi to the flash chip and run:

sudo flashrom -c "MX25L6406E/MX25L6408E" -p linux_spi:dev=/dev/spidev0.0,spispeed=4000 -w coreboot.rom

Flashrom will read, erase, write and then verify the flash chip and tell you if it succeeded. When done, FIRST REMOVE THE CONNECTION TO THE RPi, then connect a power source and boot the machine.

Coreboot should boot into the OS via SeaBIOS if you have an OS installed. Else it will boot the first secondary payload you compiled into Coreboot, e.g. Memtest86+. Press ESC to select between different boot drives and payloads.

Success \o/

Happy Corebooting!



Published by HorstBaerbel

Software developer by trade and interest, but I venture into the electronics- and diy-world from time to time.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: