summaryrefslogtreecommitdiffstats
path: root/posts
diff options
context:
space:
mode:
authorAndreas Widen <andreas@harmonicflow.org>2023-11-25 17:21:37 +0100
committerAndreas Widen <andreas@harmonicflow.org>2023-11-25 17:21:37 +0100
commit1b2b7c3eb939724696894f31ff27db97b0cac84c (patch)
treeefb7b7746a628efb7bb99b2e44c9c2fbfd75b656 /posts
downloadhf-web-1b2b7c3eb939724696894f31ff27db97b0cac84c.tar.xz
hf-web-1b2b7c3eb939724696894f31ff27db97b0cac84c.zip
Initial commit.
Signed-off-by: Andreas Widen <andreas@harmonicflow.org>
Diffstat (limited to 'posts')
-rw-r--r--posts/2019-04-02-17:57-flashing-coreboot-on-a-lenovo-thinkpad-x220-with-a-ch341a-usb-programmer-tutorial.md432
-rw-r--r--posts/2019-04-03-16:59-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.md299
-rw-r--r--posts/2022-01-13-16:24-setup-raspberry-pi-for-flashing-with-flashrom-tutorial.md160
-rw-r--r--posts/2022-01-13-21:14-flashing-coreboot-on-a-lenovo-thinkpad-x200-with-a-raspberry-pi-tutorial.md436
-rw-r--r--posts/2022-01-14-18:36-flashing-coreboot-on-a-lenovo-thinkpad-x230-with-a-raspberry-pi-tutorial.md502
5 files changed, 1829 insertions, 0 deletions
diff --git a/posts/2019-04-02-17:57-flashing-coreboot-on-a-lenovo-thinkpad-x220-with-a-ch341a-usb-programmer-tutorial.md b/posts/2019-04-02-17:57-flashing-coreboot-on-a-lenovo-thinkpad-x220-with-a-ch341a-usb-programmer-tutorial.md
new file mode 100644
index 0000000..3045d39
--- /dev/null
+++ b/posts/2019-04-02-17:57-flashing-coreboot-on-a-lenovo-thinkpad-x220-with-a-ch341a-usb-programmer-tutorial.md
@@ -0,0 +1,432 @@
+title: Flashing coreboot on a Lenovo Thinkpad X220 with a ch341a USB programmer Tutorial
+author: Andreas
+date: 2019-04-02 17:57
+tags: Lenovo Thinkpad X220, coreboot, flashrom, Raspberry Pi, ch341a
+---
+
+In this tutorial, we will go through the steps to get [coreboot](https://www.coreboot.org/) compiled and flashed on a **Lenovo Thinkpad X220** laptop.
+We'll also change the Wifi card so that Wifi will work with a libre kernel driver.
+
+***Updated 2022-01-13: Use latest coreboot-4.15 release***
+
+# Prerequisites
+
+![Prerequisites](/static/blog/media/x220/01-prerequisites.jpg)
+
+Things you need:
+
+- Lenovo Thinkpad X220
+- Atheros AR9382 AR5BHB116 Mini PCIE Dual Band Wifi card
+- ch341a USB programmer or Raspberry Pi
+- Pomona 5250 SOIC-8 clip
+- 6 x 10 cm female - female jumper wires
+- Screwdriver
+
+This tutorial assumes you're using a GNU/Linux distro and are familiar
+with how to use a terminal.
+
+[Debian GNU/Linux](https://www.debian.org/) 11 (bullseye) was used to
+compile the coreboot image produced in this tutorial.
+
+Files needed:
+
+[`dejavusansmono.pf2`](/static/blog/media/x220/dejavusansmono.pf2)\
+[`grub.cfg`](/static/blog/media/x220/grub.cfg)\
+[`background.jpg`](/static/blog/media/x220/background.jpg)
+
+For more information about DejaVu Fonts, see:\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)
+
+For DejaVu Font license, see:\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)
+
+'**background.jpg**' is borrowed from the libreboot project and it's license
+information is as follows:
+
+```plaintext
+These images are based on http://libreboot.org/logo/logo.svg
+which is Copyright 2014 Marcus Moeller and released under CC-0
+https://creativecommons.org/publicdomain/zero/1.0/legalcode
+```
+
+# Packages needed to compile flashrom/coreboot/grub
+
+```sh
+sudo apt-get build-dep flashrom grub
+sudo apt-get install git build-essential gnat flex bison libncurses5-dev libfreetype-dev pkg-config unifont wget
+```
+
+# Compile flashrom
+
+Clone flashrom git repository:
+
+```sh
+git clone https://review.coreboot.org/flashrom.git
+```
+
+Compile flashrom:
+
+```sh
+cd flashrom
+sudo make install
+sudo cp /usr/local/sbin/flashrom /usr/local/bin/
+```
+
+# Compile GRUB
+
+See '**Prerequisites**' above for the files needed.
+
+Clone GRUB git repository:
+
+```sh
+git clone https://git.savannah.gnu.org/git/grub.git
+```
+
+Compile GRUB:
+
+```sh
+cd grub
+./bootstrap
+./configure --with-platform=coreboot
+make -j4
+```
+
+Create '**pack-payload-minimal.sh**' script file:
+
+```sh
+touch pack-payload-minimal.sh
+chmod +x pack-payload-minimal.sh
+```
+
+Paste the following in '**pack-payload-minimal.sh**':
+
+```sh
+#! /bin/bash
+
+# ./pack-payload-minimal.sh – To be invoked within GRUB project folder, packs
+# an executable elf payload file for the coreboot project, using just one
+# keyboard layout file. Adapt “settings” to your needs. Specify a lighter
+# pf2-fontfile if available on your system.
+
+# settings
+elf_output="grub2.elf"
+#pf2_fontfile="unicode.pf2"
+pf2_fontfile="dejavusansmono.pf2"
+keyboard_layout="se"
+grub_modules="cbfs"
+
+# generate keyboard layout
+ckbcomp "${keyboard_layout}" | ./grub-mklayout -o "${keyboard_layout}.gkb"
+
+# pack the GRUB payload file
+./grub-mkstandalone \
+ --grub-mkimage=./grub-mkimage \
+ -O i386-coreboot \
+ -o "${elf_output}" \
+ -d grub-core \
+ --fonts= \
+ --themes= \
+ --locales= \
+ --modules="${grub_modules}" \
+ /boot/grub/grub.cfg=coreboot.cfg \
+ /boot/grub/fonts/${pf2_fontfile}="${pf2_fontfile}" \
+ /boot/grub/layouts/${keyboard_layout}.gkb="${keyboard_layout}.gkb"
+
+# message
+echo "Payload ${elf_output} has been packed with:"
+echo " * fontfile: ${pf2_fontfile}"
+echo " * keyboard layout: ${keyboard_layout}"
+echo " * GRUB modules, to be preloaded: ${grub_modules}"
+
+# code snippet suggestion
+echo "Don't forget to add 'keymap ${keyboard_layout}' to your GRUB Configuration File."
+
+# clean up
+rm "${keyboard_layout}.gkb"
+```
+
+Execute the script to create '**grub2.elf**' file:
+
+```sh
+./pack-payload-minimal.sh
+```
+
+# Connect programmer to flash chip
+
+See [`Setup Raspberry Pi for flashing with flashrom Tutorial`](../../2022/setup-raspberry-pi-for-flashing-with-flashrom-tutorial/)
+if you're using a Raspberry Pi.
+
+Remove the following parts to access the flash chip:
+
+```plaintext
+Battery
+Keyboard
+Palmrest
+```
+
+![Connect ch341a USB programmer](/static/blog/media/x220/02-lenovo-thinkpad-x220-internals.jpg)
+
+Connect Pomona 5250 to flash chip like this:
+
+```plaintext
+Screen (furthest from you)
+ __
+ MOSI 5 --| |-- 4 GND
+ CLK 6 --| |-- 3 N/C
+ N/C 7 --| |-- 2 MISO
+ 3.3v 8 --|__|-- 1 CS
+
+ N/C = Not connected / Not used
+
+ Edge (closest to you)
+```
+
+![ch341a USB programmer connected](/static/blog/media/x220/03-ch341a-programmer-connected.jpg)
+
+# Read Factory BIOS
+
+Read Factory BIOS 3 times if using **ch341a**:
+
+```sh
+sudo flashrom -p ch341a_spi -r factory_bios_01.rom -V
+sudo flashrom -p ch341a_spi -r factory_bios_02.rom -V
+sudo flashrom -p ch341a_spi -r factory_bios_03.rom -V
+```
+
+Read Factory BIOS 3 times if using **Raspberry Pi**:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_01.rom -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_02.rom -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_03.rom -V
+```
+
+Make sure checksums are identical:
+
+```plaintext
+sha512sum *.rom
+```
+
+# Download coreboot
+
+Download coreboot:
+
+```sh
+wget https://coreboot.org/releases/coreboot-4.15.tar.xz
+wget https://coreboot.org/releases/coreboot-blobs-4.15.tar.xz
+```
+
+**coreboot-blobs-4.15.tar.xz** is needed for CPU microcode updates.
+
+Extract coreboot and blobs needed:
+
+```sh
+tar xvf coreboot-4.15.tar.xz
+tar xvf coreboot-blobs-4.15.tar.xz --strip-components=1 -C coreboot-4.15
+```
+
+Create folder to hold '**descriptor/gbe/me.bin**' files:
+
+```sh
+mkdir -pv coreboot-4.15/3rdparty/blobs/mainboard/lenovo/x220/
+```
+
+Extract blob files from Factory BIOS (see '**flashrom/util/ich_descriptors_tool**' folder:
+
+```sh
+cd ~/misc-src/flashrom/util/ich_descriptors_tool
+./ich_descriptors_tool -f your/path/to/factory_bios.rom -d
+```
+
+Copy blob files to coreboot folder:
+
+```sh
+cp factory_bios.rom.Descriptor.bin ~/misc-src/coreboot-4.15/3rdparty/blobs/mainboard/lenovo/x220/descriptor.bin
+cp factory_bios.rom.GbE.bin ~/misc-src/coreboot-4.15/3rdparty/blobs/mainboard/lenovo/x220/gbe.bin
+cp factory_bios.rom.ME.bin ~/misc-src/coreboot-4.15/3rdparty/blobs/mainboard/lenovo/x220/me.bin
+```
+
+# Setup and compile coreboot
+
+Enter coreboot folder:
+
+```sh
+cd coreboot-4.15
+```
+
+Build toolchain needed first (this will take a long time, be patient):
+
+```sh
+make crossgcc-i386 CPUS=4
+```
+
+coreboot settings menu:
+
+```sh
+make menuconfig
+```
+
+Set the following options:
+
+```plaintext
+NOTE: Leave default values as is and specifically set the following
+options:
+
+mainboard -|
+ |-Mainboard vendor (Lenovo)
+ |-Mainboard model (ThinkPad X220)
+ |-ROM chip size (8192 KB (8 MB))
+ |-(0x300000) Size of CBFS filesystem in ROM
+chipset ---|
+ |-Include CPU microcode in CBFS (Generate from tree)
+ |-[*] Add Intel descriptor.bin file (leave default path as is)
+ |-(3rdparty/blobs/mainboard/$(MAINBOARDDIR)/descriptor.bin) Path and filename of the descriptor.bin file
+ |-[*] Add Intel ME/TXE firmware (leave default path as is)
+ |-(3rdparty/blobs/mainboard/$(MAINBOARDDIR)/me.bin) Path to management engine firmware
+ |- [*] Verify the integrity of the supplied ME/TXE firmware
+ |- [*] Strip down the Intel ME/TXE firmware
+ |-[*] Add gigabit ethernet firmware (leave default path as is)
+ |-(3rdparty/blobs/mainboard/$(MAINBOARDDIR)/gbe.bin) Path to gigabit ethernet firmware
+Devices ---|
+ |-Graphics initialization (Use libgfxinit)
+ |-Display
+ |- Framebuffer mode (Linear "high-resolution" framebuffer)
+payload ---|
+ |-Add a payload (An ELF executable payload)
+ |-"(/path/to/grub/grub2.elf)" Payload path and filename
+```
+
+If you don't want to include CPU microcode updates:
+
+```plaintext
+chipset ---|
+ |-Include CPU microcode in CBFS (Do not include microcode updates)
+```
+
+This will create a '**.config**' file containing all settings.
+
+Compile coreboot:
+
+```sh
+make -j4
+```
+
+This will create '**build/coreboot.rom**' image with the size of 8mb.
+
+# Add custom files to 'coreboot.rom' image
+
+Add '**grub.cfg**' and '**background.jpg**' to coreboot.rom. See
+'**Prerequisites**' above for the files needed.
+
+Make sure '**cbfstool**' is built:
+
+```sh
+cd coreboot-4.15/util/cbfstool
+make -j4
+```
+
+Add custom GRUB configuration file:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n etc/grub.cfg -f your/path/to/grub.cfg
+```
+
+Check so that '**etc/grub.cfg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+Add background image:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n background.jpg -f your/path/to/background.jpg
+```
+
+Check so that '**background.jpg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+Done! Now it's time to flash the new '**coreboot.rom**' image!
+
+# Flash coreboot image
+
+See '**Connect programmer to flash chip**' for details on how
+to connect programmer.
+
+Flash coreboot using **ch341a** USB programmer:
+
+```sh
+sudo flashrom -p ch341a_spi -w coreboot.rom -V
+```
+
+Flash coreboot using **Raspberry Pi** programmer:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w coreboot.rom -V
+```
+
+# Change Wifi card
+
+Remove the following parts to access the Wifi card:
+
+```sh
+Battery
+Keyboard
+Palmrest
+```
+
+See '**Connect programmer to flash chip**' for details on
+where the Wifi card is located.
+
+Now you can install a libre distro such as [Debian
+GNU/Linux](https://www.debian.org/).
+
+# Boot Debian GNU/Linux netinst iso from usb in GRUB2
+
+Download Debian GNU/Linux netinst from [here](https://www.debian.org/).
+
+Check name of USB device:
+
+```sh
+sudo fdisk -l
+```
+
+Create bootable USB drive:
+
+```sh
+sudo dd bs=4M if=/path/to/debian-img.iso of=/dev/YOUR_USB status=progress oflag=sync
+```
+
+Start the computer up and in the GRUB2 menu press '**c**' to enter
+command line and from there type the following:
+
+```sh
+set root='usb0'
+linux /install.amd/vmlinuz
+initrd /install.amd/initrd.gz
+boot
+```
+
+Install Debian GNU/Linux normally and put GRUB2 on master boot record at
+the end of installation process. After reboot default option in GRUB2
+menu on the flashchip will load GRUB2 on the AHCI HDD you installed on.
+
+# Download compiled coreboot image
+
+The resulting coreboot image from this tutorial can be downloaded here:
+
+[`lenovo-thinkpad-x220_coreboot-4-15-grub-master-with-cpu-microcode.rom`](/static/blog/files/x220/lenovo-thinkpad-x220_coreboot-4-15-grub-master-with-cpu-microcode.rom)
+
+Congratulations! We’re done.
+
+# Recommended reading
+
+[https://www.coreboot.org/](https://www.coreboot.org/)\
+[https://www.flashrom.org/](https://www.flashrom.org/)\
+[https://www.thinkwiki.org/wiki/Category:X220](https://www.thinkwiki.org/wiki/Category:X220)\
+[https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles_pdf/0a60739.pdf](https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles_pdf/0a60739.pdf)\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)
diff --git a/posts/2019-04-03-16:59-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.md b/posts/2019-04-03-16:59-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.md
new file mode 100644
index 0000000..f95dd95
--- /dev/null
+++ b/posts/2019-04-03-16:59-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.md
@@ -0,0 +1,299 @@
+title: Flashing coreboot on Gigabyte GA-G41M-ES2L with a ch341a USB programmer Tutorial
+author: Andreas
+date: 2019-04-03 16:59
+tags: Gigabyte GA-G41M-ES2L, coreboot, flashrom, ch341a
+---
+
+In this tutorial, we will go through the steps to get [coreboot](https://www.coreboot.org/) compiled and flashed on a **Gigabyte GA-G41M-ES2L** motherboard.
+
+***Updated 2022-01-13: Use latest coreboot-4.15 release***
+
+# Prerequisites
+
+![Prerequisites](/static/blog/media/gigabyte-ga-g41m-es2l/01-prerequisites.jpg)
+
+Things you need:
+
+- Gigabyte GA-G41M-ES2L
+- ch341a USB programmer
+- Pomona 5250 SOIC-8 clip
+- 6 x 10 cm female - female jumper wires
+
+This tutorial assumes you're using a GNU/Linux distro and are familiar
+with how to use a terminal.
+
+[Debian GNU/Linux](https://www.debian.org/) 11 (bullseye) was used to
+compile the coreboot image produced in this tutorial.
+
+Files needed:
+
+[`grub.cfg`](/static/blog/media/gigabyte-ga-g41m-es2l/grub.cfg)
+
+# Packages needed to compile flashrom/coreboot/grub
+
+```sh
+sudo apt-get build-dep flashrom grub
+sudo apt-get install git build-essential gnat flex bison libncurses5-dev libfreetype-dev pkg-config unifont wget
+```
+
+# Compile flashrom
+
+Clone flashrom git repository:
+
+```sh
+git clone https://review.coreboot.org/flashrom.git
+```
+
+Compile flashrom:
+
+```sh
+cd flashrom
+sudo make install
+sudo cp /usr/local/sbin/flashrom /usr/local/bin/
+```
+
+# Connect ch341a USB programmer to flash chip
+
+![Connect ch341a USB programmer](/static/blog/media/gigabyte-ga-g41m-es2l/02-gigabyte-ga-g41m-es2l-internals.jpg)
+
+Connect Pomona 5250 to flash chip named '**M_BIOS**' like this:
+
+```sh
+Gigabyte logo text towards you:
+ __
+ CS 5 --| |-- 4 3.3v
+ MISO 6 --| |-- 3 N/C
+ N/C 7 --| |-- 2 CLK
+ GND 8 --|__|-- 1 MOSI
+
+ N/C = Not connected / Not used
+```
+
+![ch341a USB programmer connected](/media/gigabyte-ga-g41m-es2l/03-ch341a-programmer-connected.jpg)
+
+# Read Factory BIOS
+
+Read Factory BIOS 3 times:
+
+```sh
+sudo flashrom -p ch341a_spi -r factory_bios_01.rom -V
+sudo flashrom -p ch341a_spi -r factory_bios_02.rom -V
+sudo flashrom -p ch341a_spi -r factory_bios_03.rom -V
+```
+
+Make sure checksums are identical:
+
+```sh
+sha512sum *.rom
+```
+
+# Download coreboot
+
+Download coreboot:
+
+```sh
+wget https://coreboot.org/releases/coreboot-4.15.tar.xz
+wget https://coreboot.org/releases/coreboot-blobs-4.15.tar.xz
+```
+
+**coreboot-blobs-4.15.tar.xz** is needed for CPU microcode updates.
+
+Extract coreboot:
+
+```sh
+tar xvf coreboot-4.15.tar.xz
+tar xvf coreboot-blobs-4.15.tar.xz --strip-components=1 -C coreboot-4.15
+```
+
+# Setup and compile coreboot
+
+Enter coreboot folder:
+
+```sh
+cd coreboot-4.15
+```
+
+Build toolchain needed first (this will take a long time, be patient):
+
+```sh
+make crossgcc-i386 CPUS=4
+```
+
+coreboot settings menu:
+
+```sh
+make menuconfig
+```
+
+Set the following options:
+
+```plaintext
+NOTE: Leave default values as is and specifically set the following
+options:
+
+mainboard ---------|
+ |-Mainboard vendor (GIGABYTE)
+ |-Mainboard model (GA-G41M-ES2L)
+ |-ROM chip size (1024 KB (1 MB))
+ |-0x00100000) Size of CBFS filesystem in ROM
+chipset -----------|
+ |-Include CPU microcode in CBFS (Generate from tree)
+Devices -----------|
+ |-Graphics initialization (Use libgfxinit)
+ |-Display
+ |- Legacy VGA text mode
+Generic Drivers ---|
+ |-(XX:XX:XX:XX:XX:XX) Realtek rt8168 mac address
+payload -----------|
+ |-Add a payload (GRUB2)
+ |- GRUB2 version (2.04)
+```
+
+If you don't want to include CPU microcode updates:
+
+```plaintext
+chipset ---|
+ |-Include CPU microcode in CBFS (Do not include microcode updates)
+```
+
+Check the mac address for the onboard RT8168 network card and enter that
+in '**Generic Drivers -> Realtek rt8168 mac address**'. My board is rev.
+1.1 and it **didn't** find the onboard network card at all. If this
+happens to you, just leave default mac address as is and install a PCI
+or PCI express network card instead. I'm using a PCI network card
+'**D-Link DGE-528T**' which uses RTL8169 kernel driver. Do some research
+beforehand to make sure your network card will work with default libre
+kernel drivers.
+
+This will create a '**.config**' file containing all settings.
+
+Compile coreboot:
+
+```sh
+make -j4
+```
+
+This will create '**build/coreboot.rom**' image with the size of 1mb.
+
+# Add custom files to 'coreboot.rom' image
+
+Add '**grub.cfg**' to coreboot.rom. See '**Prerequisites**' above for
+the file needed.
+
+Make sure '**cbfstool**' is built:
+
+```sh
+cd coreboot-4.15/util/cbfstool
+make -j4
+```
+
+Add custom GRUB2 configuration file:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n etc/grub.cfg -f your/path/to/grub.cfg
+```
+
+Check so that '**etc/grub.cfg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+Done! Now it's time to flash the new '**coreboot.rom**' image!
+
+# Flash coreboot image
+
+See '**Connect ch341a USB programmer to flash chip**' for details on how
+to connect ch341a USB programmer.
+
+Flash coreboot using ch341a USB programmer:
+
+```sh
+sudo flashrom -p ch341a_spi -w coreboot.rom -V
+```
+
+# Additional parts needed
+
+To build a desktop/server the following additional parts are needed:
+
+```plaintext
+Desktop case
+Power supply
+CPU
+CPU Fan
+Memory
+Harddrive
+```
+
+Here's the parts I used to build a server:
+
+```plaintext
+Desktop case: Fractal Design Define R6 Gunmetal
+Power supply: Corsair RM750X 750W v2
+CPU: Intel Core 2 Quad Q9550 2,83 GHz 12M
+CPU Fan: Arctic Cooling Freezer 7 Pro rev.2
+Memory: Corsair 2 x 2 GB DDR2 800 (PC2-6400) Memory
+Network card: D-Link DGE-528T PCI (RTL8169 kernel driver)
+Harddrive: Samsung 850 EVO 250GB SSD harddrive
+PCI Express to USB 3.0 4-Port PCI Express Expansion Card Adapter Hub VIA 5Gbps
+PCI Express SATA 3 Controller Card, 2 Port PCIe SATA III 6GB/s Internal Ada L80
+```
+
+The parts were carefully choosen so that the server would be as close to
+completely silent as possible and be able to run 100% free/libre
+software.
+
+For a list of compatible CPU's (socket LGA 775), see:\
+[https://en.wikipedia.org/wiki/List_of_Intel_Core_2_microprocessors](https://en.wikipedia.org/wiki/List_of_Intel_Core_2_microprocessors)
+
+The onboard network card might not work by default, and if so, just get
+a PCI or PCI Express network card.
+
+Now you can install a libre distro such as [Debian
+GNU/Linux](https://www.debian.org/).
+
+# Boot Debian GNU/Linux netinst iso from usb in GRUB2
+
+Download Debian GNU/Linux netinst from [here](https://www.debian.org/).
+
+Check name of USB device:
+
+```sh
+sudo fdisk -l
+```
+
+Create bootable USB drive:
+
+```sh
+sudo dd bs=4M if=/path/to/debian-img.iso of=/dev/YOUR_USB status=progress oflag=sync
+```
+
+Start the computer up and in the GRUB2 menu press '**c**' to enter
+command line and from there type the following:
+
+```sh
+set root='usb0'
+linux /install.amd/vmlinuz
+initrd /install.amd/initrd.gz
+boot
+```
+
+Install Debian GNU/Linux normally and put GRUB2 on master boot record at
+the end of installation process. After reboot default option in GRUB2
+menu on the flashchip will load GRUB2 on the AHCI HDD you installed on.
+
+# Download compiled coreboot image
+
+The resulting coreboot image from this tutorial can be downloaded here:
+
+[`gigabyte-ga-g41m-es2l_coreboot-4-15-grub-2-04-with-cpu-microcode.rom`](/static/blog/files/gigabyte-ga-g41m-es2l/gigabyte-ga-g41m-es2l_coreboot-4-15-grub-2-04-with-cpu-microcode.rom)
+
+Congratulations! We’re done.
+
+# Recommended reading
+
+[https://www.coreboot.org/](https://www.coreboot.org/)\
+[https://www.flashrom.org/](https://www.flashrom.org/)\
+[https://en.wikipedia.org/wiki/List_of_Intel_Core_2_microprocessors](https://en.wikipedia.org/wiki/List_of_Intel_Core_2_microprocessors)\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)
diff --git a/posts/2022-01-13-16:24-setup-raspberry-pi-for-flashing-with-flashrom-tutorial.md b/posts/2022-01-13-16:24-setup-raspberry-pi-for-flashing-with-flashrom-tutorial.md
new file mode 100644
index 0000000..10dc6fb
--- /dev/null
+++ b/posts/2022-01-13-16:24-setup-raspberry-pi-for-flashing-with-flashrom-tutorial.md
@@ -0,0 +1,160 @@
+title: Setup Raspberry Pi for flashing with flashrom Tutorial
+author: Andreas
+date: 2022-01-13 16:24
+tags: Raspberry Pi, flashrom
+---
+
+In this tutorial, we will go through the steps to setup a Raspberry Pi for flashing with [flashrom](https://www.flashrom.org/).
+
+# Prerequisites
+
+![Prerequisites](/static/blog/media/raspberry-pi/01-prerequisites.jpg)
+
+Things you need:
+
+- Raspberry Pi
+- Official 5.1V 2.5A Power Supply for Raspberry Pi.
+- 16 GB (or more) class 10 MicroSD card for Raspberry Pi OS.
+- HDMI cable
+- Keyboard and Mouse
+
+This tutorial assumes you're using a GNU/Linux distro for the commands
+outside of the Raspberry Pi and are familiar with how to use a terminal.
+
+I'm using a **Raspberry Pi 3 Model B** for this tutorial but any model
+supported by Raspberry Pi OS will work fine.
+
+# Install and setup Raspberry Pi OS
+
+Download Raspberry Pi OS (with Desktop is recommended) from
+[here](https://www.raspberrypi.com/software/operating-systems/)
+
+Unzip Raspberry Pi OS image:
+
+```sh
+unzip IMAGE_NAME.zip
+```
+
+Insert the MicroSD card in a reader and check name of MicroSD card:
+
+```sh
+sudo fdisk -l
+```
+
+Flash the unpacked Raspberry Pi OS image to the MicroSD card:
+
+```sh
+sudo dd if=IMAGE_NAME.img of=/dev/YOURSDCARD bs=2M status=progress oflag=sync
+```
+
+Connect the peripherals (keyboard, mouse, HDMI, power cable), insert the
+MicroSD card and boot the Raspberry Pi and make sure it works.
+
+Make sure all software is updated:
+
+```sh
+sudo apt-get update
+sudo apt-get dist-upgrade
+sudo reboot
+```
+
+Check the IP address of your Raspberry Pi:
+
+```sh
+ip addr
+```
+
+Write down the IP address (if using WiFi see '**inet**' under
+'**wlan0**'). It should look something like **192.168.1.11**. You'll
+need this IP address later to be able to connect using SSH from another
+computer.
+
+Next you need to change some things in the config:
+
+```sh
+sudo raspi-config
+```
+
+In this menu, select '**3. Interface Options**' and enable the
+following options:
+
+```plaintext
+SSH
+SPI
+I2C
+```
+
+Reboot the Raspberry Pi once this is done.
+
+Try connecting to the Raspberry Pi from another computer using SSH:
+
+```sh
+ssh pi@192.168.1.11
+```
+
+Change '**192.168.1.11**' to the IP address you wrote down in earlier
+step. When it asks for a password, enter the password for the user
+'**pi**'.
+
+From here on you can disconnect all peripherals and do the rest using
+SSH.
+
+# Compile flashrom
+
+Clone flashrom git repository:
+
+```sh
+git clone https://review.coreboot.org/flashrom.git
+```
+
+Compile flashrom:
+
+```sh
+cd flashrom
+sudo make install CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no
+sudo cp /usr/local/sbin/flashrom /usr/local/bin/
+```
+
+# Raspberry Pi GPIO pinout
+
+**Raspberry Pi 3 Model B** GPIO pinout below. **Raspberry Pi 4** seems
+to have the same layout and other models too probably. See GPIO pinout
+diagram for your specific Raspberry Pi to be sure.
+
+Note: In flashing tutorials **CS = GPIO08(CE0)** (/dev/spidev0.0)
+
+![Raspberry Pi 3 Model B pinout](/static/blog//media/raspberry-pi/raspberry-pi-3-model-b-gpio-pinout.jpg)
+
+# Example usage
+
+Read from connected chip:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_01.rom -V
+```
+
+Read from specified chip:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory-bios-top-1.bin -c "MX25L3206E/MX25L3208E" -V
+```
+
+Write to connected chip:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w coreboot.rom -V
+```
+
+Write to specified chip:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w coreboot.rom -c "MX25L3206E/MX25L3208E" -V
+```
+
+Congratulations! We're done. Now you can start flashing [coreboot](https://www.coreboot.org/) rom's.
+
+# Recommended reading
+
+[https://www.raspberrypi.com/](https://www.raspberrypi.com/)\
+[https://www.coreboot.org/](https://www.coreboot.org/)\
+[https://www.flashrom.org/](https://www.flashrom.org/)
diff --git a/posts/2022-01-13-21:14-flashing-coreboot-on-a-lenovo-thinkpad-x200-with-a-raspberry-pi-tutorial.md b/posts/2022-01-13-21:14-flashing-coreboot-on-a-lenovo-thinkpad-x200-with-a-raspberry-pi-tutorial.md
new file mode 100644
index 0000000..a696cc8
--- /dev/null
+++ b/posts/2022-01-13-21:14-flashing-coreboot-on-a-lenovo-thinkpad-x200-with-a-raspberry-pi-tutorial.md
@@ -0,0 +1,436 @@
+title: Flashing coreboot on a Lenovo Thinkpad X200 with a Raspberry Pi Tutorial
+author: Andreas
+date: 2022-01-13 21:14
+tags: Lenovo Thinkpad X200, coreboot, flashrom, Raspberry Pi, ch341a
+---
+
+In this tutorial, we will go through the steps to get [coreboot](https://www.coreboot.org/) compiled and flashed on a **Lenovo Thinkpad X200** laptop.
+
+We'll also change the Wifi card so that Wifi will work with a libre kernel driver.
+
+# Prerequisites
+
+![Prerequisites](/static/blog/media/x200/01-prerequisites.jpg)
+
+Things you need:
+
+- Lenovo Thinkpad X200
+- Atheros AR9382 AR5BHB116 Mini PCIE Dual Band Wifi card
+- Raspberry Pi or ch341a USB programmer
+- Pomona 5252 SOIC-16 clip
+- 6 x 10 cm female - female jumper wires
+- Screwdriver
+
+This tutorial assumes you're using a GNU/Linux distro and are familiar
+with how to use a terminal.
+
+[Debian GNU/Linux](https://www.debian.org/) 11 (bullseye) was used to
+compile the coreboot image produced in this tutorial.
+
+Files needed:
+
+[`dejavusansmono.pf2`](/static/blog/media/x200/dejavusansmono.pf2)\
+[`grub.cfg`](/static/blog//media/x200/grub.cfg)\
+[`background.jpg`](/static/blog/media/x200/background.jpg)
+
+For more information about DejaVu Fonts, see:\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)
+
+For DejaVu Font license, see:\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)
+
+'**background.jpg**' is borrowed from the libreboot project and it's license
+information is as follows:
+
+```plaintext
+These images are based on http://libreboot.org/logo/logo.svg
+which is Copyright 2014 Marcus Moeller and released under CC-0
+https://creativecommons.org/publicdomain/zero/1.0/legalcode
+```
+
+# Packages needed to compile flashrom/coreboot/grub
+
+```sh
+sudo apt-get build-dep flashrom grub
+sudo apt-get install git build-essential gnat flex bison libncurses5-dev libfreetype-dev pkg-config unifont wget
+```
+
+# Compile flashrom
+
+Clone flashrom git repository:
+
+```sh
+git clone https://review.coreboot.org/flashrom.git
+```
+
+Compile flashrom:
+
+```sh
+cd flashrom
+sudo make install
+sudo cp /usr/local/sbin/flashrom /usr/local/bin/
+```
+
+# Compile GRUB
+
+See '**Prerequisites**' above for the files needed.
+
+Clone GRUB git repository:
+
+```sh
+git clone https://git.savannah.gnu.org/git/grub.git
+```
+
+Compile GRUB:
+
+```sh
+cd grub
+./bootstrap
+./configure --with-platform=coreboot
+make -j4
+```
+
+Create '**pack-payload-minimal.sh**' script file:
+
+```sh
+touch pack-payload-minimal.sh
+chmod +x pack-payload-minimal.sh
+```
+
+Paste the following in '**pack-payload-minimal.sh**':
+
+```sh
+#! /bin/bash
+
+# ./pack-payload-minimal.sh – To be invoked within GRUB project folder, packs
+# an executable elf payload file for the coreboot project, using just one
+# keyboard layout file. Adapt “settings” to your needs. Specify a lighter
+# pf2-fontfile if available on your system.
+
+# settings
+elf_output="grub2.elf"
+#pf2_fontfile="unicode.pf2"
+pf2_fontfile="dejavusansmono.pf2"
+keyboard_layout="se"
+grub_modules="cbfs"
+
+# generate keyboard layout
+ckbcomp "${keyboard_layout}" | ./grub-mklayout -o "${keyboard_layout}.gkb"
+
+# pack the GRUB payload file
+./grub-mkstandalone \
+ --grub-mkimage=./grub-mkimage \
+ -O i386-coreboot \
+ -o "${elf_output}" \
+ -d grub-core \
+ --fonts= \
+ --themes= \
+ --locales= \
+ --modules="${grub_modules}" \
+ /boot/grub/grub.cfg=coreboot.cfg \
+ /boot/grub/fonts/${pf2_fontfile}="${pf2_fontfile}" \
+ /boot/grub/layouts/${keyboard_layout}.gkb="${keyboard_layout}.gkb"
+
+# message
+echo "Payload ${elf_output} has been packed with:"
+echo " * fontfile: ${pf2_fontfile}"
+echo " * keyboard layout: ${keyboard_layout}"
+echo " * GRUB modules, to be preloaded: ${grub_modules}"
+
+# code snippet suggestion
+echo "Don't forget to add 'keymap ${keyboard_layout}' to your GRUB Configuration File."
+
+# clean up
+rm "${keyboard_layout}.gkb"
+```
+
+Execute the script to create '**grub2.elf**' file:
+
+```sh
+./pack-payload-minimal.sh
+```
+
+# Connect programmer to flash chip
+
+See [`Setup Raspberry Pi for flashing with flashrom Tutorial`](../../2022/setup-raspberry-pi-for-flashing-with-flashrom-tutorial/)
+if you're using a Raspberry Pi.
+
+Remove the following parts to access the flash chip:
+
+```plaintext
+Battery
+Keyboard
+Palmrest
+```
+
+![Connect programmer](/static/blog/media/x200/02-lenovo-thinkpad-x200-internals.jpg)
+
+Connect Pomona 5252 to flash chip like this:
+
+```plaintext
+Screen (furthest from you)
+ __
+ N/C 1 --| |-- 9 MISO
+ GND 2 --| |-- 10 CS
+ N/C 3 --| |-- 11 N/C
+ N/C 4 --| |-- 12 N/C
+ N/C 5 --| |-- 13 N/C
+ N/C 6 --| |-- 14 N/C
+ MOSI 7 --| |-- 15 3.3V
+ CLK 8 --|__|-- 16 N/C
+
+ N/C = Not connected / Not used
+
+ Edge (closest to you)
+```
+
+![ch341a USB programmer connected](/static/blog/media/x200/03-raspberry-pi-connected.jpg)
+
+# Read Factory BIOS
+
+Read Factory BIOS 3 times if using **Raspberry Pi**:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_01.rom -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_02.rom -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_03.rom -V
+```
+
+Read Factory BIOS 3 times if using **ch341a**:
+
+```sh
+sudo flashrom -p ch341a_spi -r factory_bios_01.rom -V
+sudo flashrom -p ch341a_spi -r factory_bios_02.rom -V
+sudo flashrom -p ch341a_spi -r factory_bios_03.rom -V
+```
+
+Make sure checksums are identical:
+
+```sh
+sha512sum *.rom
+```
+
+# Download coreboot
+
+Download coreboot:
+
+```sh
+wget https://coreboot.org/releases/coreboot-4.15.tar.xz
+wget https://coreboot.org/releases/coreboot-blobs-4.15.tar.xz
+```
+
+**coreboot-blobs-4.15.tar.xz** is needed for CPU microcode updates.
+
+Extract coreboot and blobs needed:
+
+```sh
+tar xvf coreboot-4.15.tar.xz
+tar xvf coreboot-blobs-4.15.tar.xz --strip-components=1 -C coreboot-4.15
+```
+
+# Setup and compile coreboot
+
+Enter coreboot folder:
+
+```sh
+cd coreboot-4.15
+```
+
+Build toolchain needed first (this will take a long time, be patient):
+
+```sh
+make crossgcc-i386 CPUS=4
+```
+
+coreboot settings menu:
+
+```sh
+make menuconfig
+```
+
+Set the following options:
+
+```plaintext
+NOTE: Leave default values as is and specifically set the following
+options:
+
+mainboard -|
+ |-Mainboard vendor (Lenovo)
+ |-Mainboard model (ThinkPad X200)
+ |-ROM chip size (8192 KB (8 MB))
+ |-(0x300000) Size of CBFS filesystem in ROM
+chipset ---|
+ |-Include CPU microcode in CBFS (Generate from Tree)
+Devices ---|
+ |-Graphics initialization (Use libgfxinit)
+ |-Display
+ |- Framebuffer mode (Linear "high-resolution" framebuffer)
+Generic Dr.|
+ |- Select: PS/2 keyboard init
+payload ---|
+ |-Add a payload (An ELF executable payload)
+ |-"(/path/to/grub/grub2.elf)" Payload path and filename
+
+If you don't want to include CPU microcode updates:
+
+```plaintext
+chipset ---|
+ |-Include CPU microcode in CBFS (Do not include microcode updates)
+```
+
+This will create a '**.config**' file containing all settings.
+
+Compile coreboot:
+
+```sh
+make -j4
+```
+
+This will create '**build/coreboot.rom**' image with the size of 8mb.
+
+# Add custom files to 'coreboot.rom' image
+
+Add '**grub.cfg**' and '**background.jpg**' to coreboot.rom. See
+'**Prerequisites**' above for the files needed.
+
+Make sure '**cbfstool**' is built:
+
+```sh
+cd coreboot-4.15/util/cbfstool
+make -j4
+```
+
+Add custom GRUB configuration file:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n etc/grub.cfg -f your/path/to/grub.cfg
+```
+
+Check so that '**etc/grub.cfg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+Add background image:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n background.jpg -f your/path/to/background.jpg
+```
+
+Check so that '**background.jpg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+# Add Descriptor and GbE File
+
+Download libreboot utils:
+
+```sh
+wget https://mirrors.mit.edu/libreboot/stable/20160907/libreboot_r20160907_util.tar.xz
+```
+
+Extract the utils:
+
+```sh
+tar xvf libreboot_r20160907_util.tar.xz
+```
+
+Generate MAC address (MAC address is listed on the bottom of the X200 on
+a white label on the right side):
+
+```sh
+cd libreboot_r20160907_util/ich9deblob/x86_64
+./ich9gen --macaddress xx:xx:xx:xx:xx:xx
+```
+
+And lastly append it to coreboot.rom:
+
+```sh
+dd if=ich9fdgbe_8m.bin of=~/misc-src/coreboot-4.15/build/coreboot.rom bs=1 count=12k conv=notrunc
+```
+
+Done! Now it's time to flash the new '**coreboot.rom**' image!
+
+# Flash coreboot image
+
+See '**Connect programmer to flash chip**' for details on how
+to connect programmer.
+
+Flash coreboot using **Raspberry Pi** programmer:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w coreboot.rom -V
+```
+
+Flash coreboot using **ch341a** USB programmer:
+
+```sh
+sudo flashrom -p ch341a_spi -w coreboot.rom -V
+```
+
+# Change Wifi card
+
+Remove the following parts to access the Wifi card:
+
+```plaintext
+Battery
+Keyboard
+Palmrest
+```
+
+See '**Connect programmer to flash chip**' for details on
+where the Wifi card is located.
+
+Now you can install a libre distro such as [Debian
+GNU/Linux](https://www.debian.org/).
+
+# Boot Debian GNU/Linux netinst iso from usb in GRUB2
+
+Download Debian GNU/Linux netinst from [here](https://www.debian.org/).
+
+Check name of USB device:
+
+```sh
+sudo fdisk -l
+```
+
+Create bootable USB drive:
+
+```sh
+sudo dd bs=4M if=/path/to/debian-img.iso of=/dev/YOUR_USB status=progress oflag=sync
+```
+
+Start the computer up and in the GRUB2 menu press '**c**' to enter
+command line and from there type the following:
+
+```sh
+set root='usb0'
+linux /install.amd/vmlinuz
+initrd /install.amd/initrd.gz
+boot
+```
+
+Install Debian GNU/Linux normally and put GRUB2 on master boot record at
+the end of installation process. After reboot default option in GRUB2
+menu on the flashchip will load GRUB2 on the AHCI HDD you installed on.
+
+# Download compiled coreboot image
+
+The resulting coreboot image from this tutorial can be downloaded here:
+
+[`lenovo-thinkpad-x200_coreboot-4-15-grub-master-with-cpu-microcode.rom`](/static/blog/files/x200/lenovo-thinkpad-x200_coreboot-4-15-grub-master-with-cpu-microcode.rom)
+
+Congratulations! We’re done.
+
+# Recommended reading
+
+[https://www.coreboot.org/](https://www.coreboot.org/)\
+[https://www.flashrom.org/](https://www.flashrom.org/)\
+[https://www.thinkwiki.org/wiki/Category:X200](https://www.thinkwiki.org/wiki/Category:X200)\
+[https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles_pdf/43y6632_03.pdf](https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles_pdf/43y6632_03.pdf)\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)
+
diff --git a/posts/2022-01-14-18:36-flashing-coreboot-on-a-lenovo-thinkpad-x230-with-a-raspberry-pi-tutorial.md b/posts/2022-01-14-18:36-flashing-coreboot-on-a-lenovo-thinkpad-x230-with-a-raspberry-pi-tutorial.md
new file mode 100644
index 0000000..dd33dba
--- /dev/null
+++ b/posts/2022-01-14-18:36-flashing-coreboot-on-a-lenovo-thinkpad-x230-with-a-raspberry-pi-tutorial.md
@@ -0,0 +1,502 @@
+title: Flashing coreboot on a Lenovo Thinkpad X230 with a Raspberry Pi Tutorial
+author: Andreas
+date: 2022-01-14 18:36:36
+tags: Lenovo Thinkpad X230, coreboot, flashrom, Raspberry Pi, ch341a
+---
+
+In this tutorial, we will go through the steps to get [coreboot](https://www.coreboot.org/) compiled and flashed on a **Lenovo Thinkpad X230** laptop.
+
+We'll also change the Wifi card so that Wifi will work with a libre kernel driver.
+
+# Prerequisites
+
+![Prerequisites](/static/blog/media/x230/01-prerequisites.jpg)
+
+Things you need:
+
+- Lenovo Thinkpad X230
+- Atheros AR9382 AR5BHB116 Mini PCIE Dual Band Wifi card
+- Raspberry Pi or ch341a USB programmer
+- Pomona 5250 SOIC-8 clip
+- 6 x 10 cm female - female jumper wires
+- Screwdriver
+
+This tutorial assumes you're using a GNU/Linux distro and are familiar
+with how to use a terminal.
+
+[Debian GNU/Linux](https://www.debian.org/) 11 (bullseye) was used to
+compile the coreboot image produced in this tutorial.
+
+Files needed:
+
+[`dejavusansmono.pf2`](/static/blog/media/x230/dejavusansmono.pf2)\
+[`grub.cfg`](/static/blog/media/x230/grub.cfg)\
+[`background.jpg`](/static/blog/media/x230/background.jpg)
+
+For more information about DejaVu Fonts, see:\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)
+
+For DejaVu Font license, see:\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)
+
+'**background.jpg**' is borrowed from the libreboot project and it's license
+information is as follows:
+
+```plaintext
+These images are based on http://libreboot.org/logo/logo.svg
+which is Copyright 2014 Marcus Moeller and released under CC-0
+https://creativecommons.org/publicdomain/zero/1.0/legalcode
+```
+
+# Packages needed to compile flashrom/coreboot/grub
+
+```sh
+sudo apt-get build-dep flashrom grub
+sudo apt-get install git build-essential gnat flex bison libncurses5-dev libfreetype-dev pkg-config unifont wget
+```
+
+# Compile flashrom
+
+Clone flashrom git repository:
+
+```sh
+git clone https://review.coreboot.org/flashrom.git
+```
+
+Compile flashrom:
+
+```sh
+cd flashrom
+sudo make install
+sudo cp /usr/local/sbin/flashrom /usr/local/bin/
+```
+
+# Compile GRUB
+
+See '**Prerequisites**' above for the files needed.
+
+Clone GRUB git repository:
+
+```sh
+git clone https://git.savannah.gnu.org/git/grub.git
+```
+
+Compile GRUB:
+
+```sh
+cd grub
+./bootstrap
+./configure --with-platform=coreboot
+make -j4
+```
+
+Create '**pack-payload-minimal.sh**' script file:
+
+```sh
+touch pack-payload-minimal.sh
+chmod +x pack-payload-minimal.sh
+```
+
+Paste the following in '**pack-payload-minimal.sh**':
+
+```sh
+#! /bin/bash
+
+# ./pack-payload-minimal.sh – To be invoked within GRUB project folder, packs
+# an executable elf payload file for the coreboot project, using just one
+# keyboard layout file. Adapt “settings” to your needs. Specify a lighter
+# pf2-fontfile if available on your system.
+
+# settings
+elf_output="grub2.elf"
+#pf2_fontfile="unicode.pf2"
+pf2_fontfile="dejavusansmono.pf2"
+keyboard_layout="se"
+grub_modules="cbfs"
+
+# generate keyboard layout
+ckbcomp "${keyboard_layout}" | ./grub-mklayout -o "${keyboard_layout}.gkb"
+
+# pack the GRUB payload file
+./grub-mkstandalone \
+ --grub-mkimage=./grub-mkimage \
+ -O i386-coreboot \
+ -o "${elf_output}" \
+ -d grub-core \
+ --fonts= \
+ --themes= \
+ --locales= \
+ --modules="${grub_modules}" \
+ /boot/grub/grub.cfg=coreboot.cfg \
+ /boot/grub/fonts/${pf2_fontfile}="${pf2_fontfile}" \
+ /boot/grub/layouts/${keyboard_layout}.gkb="${keyboard_layout}.gkb"
+
+# message
+echo "Payload ${elf_output} has been packed with:"
+echo " * fontfile: ${pf2_fontfile}"
+echo " * keyboard layout: ${keyboard_layout}"
+echo " * GRUB modules, to be preloaded: ${grub_modules}"
+
+# code snippet suggestion
+echo "Don't forget to add 'keymap ${keyboard_layout}' to your GRUB Configuration File."
+
+# clean up
+rm "${keyboard_layout}.gkb"
+```
+
+Execute the script to create '**grub2.elf**' file:
+
+```sh
+./pack-payload-minimal.sh
+```
+
+# Connect programmer to flash chip
+
+See [`Setup Raspberry Pi for flashing with flashrom Tutorial`](../../2022/setup-raspberry-pi-for-flashing-with-flashrom-tutorial/)
+if you're using a Raspberry Pi.
+
+Remove the following parts to access the flash chip:
+
+```plaintext
+Battery
+Keyboard
+Palmrest
+```
+
+![Connect ch341a USB programmer](/static/blog/media/x230/02-lenovo-thinkpad-x230-internals.jpg)
+
+Connect Pomona 5250 to flash chip like this (same for both **top** and
+**bottom** flash chips):
+
+```plaintext
+Screen (furthest from you)
+ __
+ MOSI 5 --| |-- 4 GND
+ CLK 6 --| |-- 3 N/C
+ N/C 7 --| |-- 2 MISO
+ 3.3V 8 --|__|-- 1 CS
+
+ Edge (closest to you)
+
+ N/C = Not connected / Not used
+```
+
+![ch341a USB programmer connected](/static/blog/media/x230/03-raspberry-pi-connected.jpg)
+
+# Read Factory BIOS from Top flash chip
+
+Read Factory BIOS 3 times if using **Raspberry Pi**:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_top_01.rom -c "MX25L3206E/MX25L3208E" -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_top_02.rom -c "MX25L3206E/MX25L3208E" -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_top_03.rom -c "MX25L3206E/MX25L3208E" -V
+```
+
+Read Factory BIOS 3 times if using **ch341a**:
+
+```sh
+sudo flashrom -p ch341a_spi -r factory_bios_top_01.rom -c "MX25L3206E/MX25L3208E" -V
+sudo flashrom -p ch341a_spi -r factory_bios_top_02.rom -c "MX25L3206E/MX25L3208E" -V
+sudo flashrom -p ch341a_spi -r factory_bios_top_03.rom -c "MX25L3206E/MX25L3208E" -V
+```
+
+Make sure checksums are identical:
+
+```sh
+sha512sum *.rom
+```
+
+# Read Factory BIOS from Bottom flash chip
+
+Read Factory BIOS 3 times if using **Raspberry Pi**:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_bottom_01.rom -c "MX25L6406E/MX25L6408E" -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_bottom_02.rom -c "MX25L6406E/MX25L6408E" -V
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -r factory_bios_bottom_03.rom -c "MX25L6406E/MX25L6408E" -V
+```
+
+Read Factory BIOS 3 times if using **ch341a**:
+
+```sh
+sudo flashrom -p ch341a_spi -r factory_bios_bottom_01.rom -c "MX25L6406E/MX25L6408E" -V
+sudo flashrom -p ch341a_spi -r factory_bios_bottom_02.rom -c "MX25L6406E/MX25L6408E" -V
+sudo flashrom -p ch341a_spi -r factory_bios_bottom_03.rom -c "MX25L6406E/MX25L6408E" -V
+```
+
+Make sure checksums are identical:
+
+```sh
+sha512sum *.rom
+```
+
+# Combine Bottom and Top rom files
+
+Combine bottom and top into a 12MB combined rom file:
+
+```sh
+cat factory_bios_bottom_01.rom factory_bios_top_01.rom > factory_bios_combined.rom
+```
+
+# Download coreboot
+
+Download coreboot:
+
+```sh
+wget https://coreboot.org/releases/coreboot-4.15.tar.xz
+wget https://coreboot.org/releases/coreboot-blobs-4.15.tar.xz
+```
+
+**coreboot-blobs-4.15.tar.xz** is needed for CPU microcode updates.
+
+Extract coreboot and blobs needed:
+
+```sh
+tar xvf coreboot-4.15.tar.xz
+tar xvf coreboot-blobs-4.15.tar.xz --strip-components=1 -C coreboot-4.15
+```
+
+Create folder to hold '**descriptor/gbe/me.bin**' files:
+
+```sh
+mkdir -pv coreboot-4.15/3rdparty/blobs/mainboard/lenovo/x230/
+```
+
+# Extract blobs from 'factory_bios_combined.rom'
+
+Extract flash descriptor, BIOS, Intel ME, GbE and platform data regions:
+
+```sh
+cd ~/misc-src/coreboot-4.15/util/ifdtool/
+make
+./ifdtool -x factory_bios_combined.rom
+```
+
+Copy blob files to coreboot folder:
+
+```sh
+cp flashregion_0_flashdescriptor.bin ../../3rdparty/blobs/mainboard/lenovo/x230/descriptor.bin
+cp flashregion_2_intel_me.bin ../../3rdparty/blobs/mainboard/lenovo/x230/me.bin
+cp flashregion_3_gbe.bin ../../3rdparty/blobs/mainboard/lenovo/x230/gbe.bin
+```
+
+# Setup and compile coreboot
+
+Enter coreboot folder:
+
+```sh
+cd coreboot-4.15
+```
+
+Build toolchain needed first (this will take a long time, be patient):
+
+```sh
+make crossgcc-i386 CPUS=4
+```
+
+coreboot settings menu:
+
+```plaintext
+make menuconfig
+```
+
+Set the following options:
+
+```plaintext
+NOTE: Leave default values as is and specifically set the following
+options:
+
+mainboard -|
+ |-Mainboard vendor (Lenovo)
+ |-Mainboard model (ThinkPad X230)
+ |-ROM chip size (12288 KB (12 MB))
+ |-(0x300000) Size of CBFS filesystem in ROM
+chipset ---|
+ |-Include CPU microcode in CBFS (Generate from tree)
+ |-[*] Add Intel descriptor.bin file (leave default path as is)
+ |-(3rdparty/blobs/mainboard/$(MAINBOARDDIR)/descriptor.bin) Path and filename of the descriptor.bin file
+ |-[*] Add Intel ME/TXE firmware (leave default path as is)
+ |-(3rdparty/blobs/mainboard/$(MAINBOARDDIR)/me.bin) Path to management engine firmware
+ |- [*] Verify the integrity of the supplied ME/TXE firmware
+ |- [*] Strip down the Intel ME/TXE firmware
+ |-[*] Add gigabit ethernet firmware (leave default path as is)
+ |-(3rdparty/blobs/mainboard/$(MAINBOARDDIR)/gbe.bin) Path to gigabit ethernet firmware
+Devices ---|
+ |-Graphics initialization (Use libgfxinit)
+ |-Display
+ |- Framebuffer mode (Linear "high-resolution" framebuffer)
+ |- Add a Video Bios Table (VBT) binary to CBFS
+ |- (src/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/data.vbt)
+Generic Dr.|
+ |- Select: PS/2 keyboard init
+payload ---|
+ |-Add a payload (An ELF executable payload)
+ |-"(/path/to/grub/grub2.elf)" Payload path and filename
+```
+
+If you don't want to include CPU microcode updates:
+
+```plaintext
+chipset ---|
+ |-Include CPU microcode in CBFS (Do not include microcode updates)
+```
+
+This will create a '**.config**' file containing all settings.
+
+Compile coreboot:
+
+```sh
+make -j4
+```
+
+This will create '**build/coreboot.rom**' image with the size of 12mb.
+
+# Add custom files to 'coreboot.rom' image
+
+Add '**grub.cfg**' and '**background.jpg**' to coreboot.rom. See
+'**Prerequisites**' above for the files needed.
+
+Make sure '**cbfstool**' is built:
+
+```sh
+cd coreboot-4.15/util/cbfstool
+make -j4
+```
+
+Add custom GRUB configuration file:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n etc/grub.cfg -f your/path/to/grub.cfg
+```
+
+Check so that '**etc/grub.cfg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+Add background image:
+
+```sh
+./cbfstool ../../build/coreboot.rom add -t raw -n background.jpg -f your/path/to/background.jpg
+```
+
+Check so that '**background.jpg**' exists in coreboot.rom:
+
+```sh
+./cbfstool ../../build/coreboot.rom print
+```
+
+Done! Now it's time to flash the new '**coreboot.rom**' image!
+
+# Split coreboot.rom into top and bottom
+
+Enter coreboot folder:
+
+```sh
+cd coreboot-4.15
+```
+
+```sh
+dd if=build/coreboot.rom of=build/coreboot_bottom.rom bs=1M count=8
+dd if=build/coreboot.rom of=build/coreboot_top.rom bs=1M skip=8
+```
+
+# Flash Top flash chip coreboot image
+
+See '**Connect programmer to flash chip**' for details on how
+to connect programmer.
+
+Flash coreboot using **Raspberry Pi** programmer:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w coreboot_top.rom -c "MX25L3206E/MX25L3208E" -V
+```
+
+Flash coreboot using **ch341a** USB programmer:
+
+```sh
+sudo flashrom -p ch341a_spi -w coreboot_top.rom -c "MX25L3206E/MX25L3208E" -V
+```
+
+# Flash Bottom flash chip coreboot image
+
+See '**Connect programmer to flash chip**' for details on how
+to connect programmer.
+
+Flash coreboot using **Raspberry Pi** programmer:
+
+```sh
+sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=32768 -w coreboot_bottom.rom -c "MX25L6406E/MX25L6408E" -V
+```
+
+Flash coreboot using **ch341a** USB programmer:
+
+```sh
+sudo flashrom -p ch341a_spi -w coreboot_bottom.rom -c "MX25L6406E/MX25L6408E" -V
+```
+
+# Change Wifi card
+
+Remove the following parts to access the Wifi card:
+
+```plaintext
+Battery
+Keyboard
+Palmrest
+```
+
+See '**Connect programmer to flash chip**' for details on
+where the Wifi card is located.
+
+Now you can install a libre distro such as [Debian
+GNU/Linux](https://www.debian.org/).
+
+# Boot Debian GNU/Linux netinst iso from usb in GRUB2
+
+Download Debian GNU/Linux netinst from [here](https://www.debian.org/).
+
+Check name of USB device:
+
+```sh
+sudo fdisk -l
+```
+
+Create bootable USB drive:
+
+```sh
+sudo dd bs=4M if=/path/to/debian-img.iso of=/dev/YOUR_USB status=progress oflag=sync
+```
+
+Start the computer up and in the GRUB2 menu press '**c**' to enter
+command line and from there type the following:
+
+```sh
+set root='usb0'
+linux /install.amd/vmlinuz
+initrd /install.amd/initrd.gz
+boot
+```
+
+Install Debian GNU/Linux normally and put GRUB2 on master boot record at
+the end of installation process. After reboot default option in GRUB2
+menu on the flashchip will load GRUB2 on the AHCI HDD you installed on.
+
+# Download compiled coreboot images
+
+The resulting coreboot images from this tutorial can be downloaded here:
+
+[`lenovo-thinkpad-x230_coreboot-4-15-grub-master-with-cpu-microcode-top.rom`](/static/blog/files/x230/lenovo-thinkpad-x230_coreboot-4-15-grub-master-with-cpu-microcode-top.rom)\
+[`lenovo-thinkpad-x230_coreboot-4-15-grub-master-with-cpu-microcode-bottom.rom`](/static/blog/files/x230/lenovo-thinkpad-x230_coreboot-4-15-grub-master-with-cpu-microcode-bottom.rom)
+
+Congratulations! We’re done.
+
+# Recommended reading
+
+[https://www.coreboot.org/](https://www.coreboot.org/)\
+[https://www.flashrom.org/](https://www.flashrom.org/)\
+[https://www.thinkwiki.org/wiki/Category:X230](https://www.thinkwiki.org/wiki/Category:X230)\
+[https://download.lenovo.com/pccbbs/mobiles_pdf/0b48666.pdf](https://download.lenovo.com/pccbbs/mobiles_pdf/0b48666.pdf)\
+[https://dejavu-fonts.github.io/](https://dejavu-fonts.github.io/)\
+[https://dejavu-fonts.github.io/License.html](https://dejavu-fonts.github.io/License.html)