Upgrading coreboot

· monkeybusiness's blog


Upgrading Coreboot

Quite some time ago, I had posted about my laptop. If you scroll down a bit, you will know it was corebooted. As good as it sounds, the sad part is that I had never updated it. Now, this resulted in my laptop having a version of coreboot installed from over two years ago. Now, that's what you call procrastination.

Not long after I had bought my laptop couple of years ago, I did dabble a bit with flashrom. Even saying "a bit" would be an absolute stretch given the fact that I only ran a couple of commands from what I remember.

1$ sudo flashrom -p internal

The output was as desired as per instructions documented here

I was able to dump and read and even write the ROM back. But I had totally forgotten about it. Fast forward to now and I remembered that I may have to update the BIOS after all this time. I noticed the MH's coreboot repo hasn't been updated in all this time. But a search for Skulls distribution revealed the repo where it is hosted now and I incidentally came across an old FOSSDEM video where Skulls' primary dev, Martin Kepplinger makes a presentation on Skulls and that was it. I had to get this done now.

So, I ran flashrom again to verify if I could flash coreboot internally, which I what I wanted to do. Doing it externally, would have been a significant logistical headache given I have my Raspberry Pi 4B back home, a good 400 Kms away and I would need a SIOC-8 clip to flas the BIOS chips. This would mean going in search for one, which safe to say is something I disliked doing. Internal flashing is a possibility and I knew it from multiple sources that the BIOS chip is not longer locked after Coreboot was first flashed externally. So, I ran this command:

 1$ doas flashrom -pinternal
 2doas (farhan@crypt) password:
 3flashrom v1.2 on Linux 6.4.10-hardened1-1-hardened (x86_64)
 4flashrom is free software, get the source code at https://flashrom.org
 5Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
 6Critical error: open(/dev/mem): No such file or directory
 7Error accessing low megabyte, 0x100000 bytes at 0x0000000000000000
 8/dev/mem mmap failed: No such file or directory
 9Failed getting access to coreboot low tables.
10Critical error: open(/dev/mem): No such file or directory
11Error accessing DMI, 0x10000 bytes at 0x00000000000f0000
12/dev/mem mmap failed: No such file or directory
13Warning: Can't autodetect Roda RV11, DMI info unavailable.
14Please supply the board vendor and model name with the -p internal:mainboard=<vendor>:<model> option.
15Found chipset "Intel QM77".
16Enabling flash write... Critical error: open(/dev/mem): No such file or directory
17Error accessing ICH RCRB, 0x4000 bytes at 0x00000000fed1c000
18/dev/mem mmap failed: No such file or directory
19FAILED!
20FATAL ERROR!
21Error: Programmer initialization failed.

Wow, I ran into an error. And I swear I did run this command successfully back then and it failed. Major changes from back then?

  1. Pure OS v Artix Linux
  2. Linux LTS v Linux-hardened kernel All coreboot documentation I have referred to mentioned a pre-requisite before flashing coreboot internally, add the following line to the boot parameters: "iomem=relaxed". I immediately updated my boot configuration with iomem=relaxed. Yet, it still failed to work. A quick internet search revealed this hint and this was even more ominous that this was the kernel. A quick question in Libera IRC channel #libreboot recommended me trying a different kernel and run flashrom again. So, I installed linux-zen(linux will also work for that matter)
1$ doas pacman -S linux-zen

Rebooted my PC and in the grub's configuration editor at boot, replaced linux-hardened with linux-zen. Then, I ran flashrom as planned and voila! this worked.

 1$ sudo flashrom -p internal -r x230-coreboot.rom
 2flashrom v1.2 on Linux 5.10.9-gnu (x86_64)
 3flashrom is free software, get the source code at https://flashrom.org
 4Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
 5coreboot table found at 0xbff51000.
 6Found chipset "Intel QM77".
 7Enabling flash write... SPI Configuration is locked down.
 8Enabling hardware sequencing due to multiple flash chips detected.
 9OK.
10Found Programmer flash chip "Opaque flash chip" (12288 kB, Programmer-specific) mapped at physical address 0x0000000000000000.
11Reading flash... done

Now, I downloaded Skulls tarball from Github, extracted it using the command

1$ tar -xvf ~/Downloads/skulls-1.0.8.tar.xz
2$ cd skulls*

Then came the moment of truth:

1$ sudo ./skulls.sh -b x230
21) ./x230_coreboot_seabios_aa1efece74_top.rom
32) ./x230_coreboot_seabios_free_aa1efece74_top.rom
43) Quit
5file not specified. Please select a file to flash. Please read the README for details about the differences:

I chose the first option and a restart later, I could see the new coreboot version number and the Skulls logo at startup. Thus confirming a successful upgrade.