summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Widen <andreas@harmonicflow.org>2019-04-03 17:05:18 +0200
committerAndreas Widen <andreas@harmonicflow.org>2019-04-03 17:05:18 +0200
commit384a9b981dff424de8beb1f847d2acfa14d8b00b (patch)
tree3f2842ea8e80c22a190fc0bd671864b8732121b2
parent9d9df1c6b507c8099f359b0d5be05ffb76c39096 (diff)
downloadHarmonicFlowOrgWeb-384a9b981dff424de8beb1f847d2acfa14d8b00b.tar.xz
HarmonicFlowOrgWeb-384a9b981dff424de8beb1f847d2acfa14d8b00b.zip
New blog about coreboot-on-gigabyte-ga-g41m-es2l.
Signed-off-by: Andreas Widen <andreas@harmonicflow.org>
-rw-r--r--blog/data/2019-04-03-16:59:50-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.txt287
-rwxr-xr-xinclude/sidebar.inc.php4
-rw-r--r--media/gigabyte-ga-g41m-es2l/01-prerequisites.jpgbin0 -> 124791 bytes
-rw-r--r--media/gigabyte-ga-g41m-es2l/02-gigabyte-ga-g41m-es2l-internals.jpgbin0 -> 136210 bytes
-rw-r--r--media/gigabyte-ga-g41m-es2l/03-ch341a-programmer-connected.jpgbin0 -> 137963 bytes
-rw-r--r--media/gigabyte-ga-g41m-es2l/dejavusansmono.pf2bin0 -> 100513 bytes
-rw-r--r--media/gigabyte-ga-g41m-es2l/grub.cfg129
7 files changed, 420 insertions, 0 deletions
diff --git a/blog/data/2019-04-03-16:59:50-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.txt b/blog/data/2019-04-03-16:59:50-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.txt
new file mode 100644
index 0000000..758e7e7
--- /dev/null
+++ b/blog/data/2019-04-03-16:59:50-flashing-coreboot-on-gigabyte-ga-g41m-es2l-with-a-ch341a-usb-programmer-tutorial.txt
@@ -0,0 +1,287 @@
+Title: Flashing coreboot on Gigabyte GA-G41M-ES2L with a ch341a USB programmer Tutorial
+Tags: gigabyte-ga-g41m-es2l, coreboot, libreboot, flashrom, ch341a
+Date: 2019-04-03 16:59:50
+Format: markdown
+
+In this tutorial, we will go through the steps to get
+[coreboot](https://www.coreboot.org/) compiled and flashed on Gigabyte
+GA-G41M-ES2L.
+__CUT__
+
+## Prerequisites
+
+![Prerequisites](../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
+> * D-Link DGE-528T PCI network card (Optional but recommended. Most
+PCI/PCIE cards should be fine and work without proprietary kernel
+drivers)
+
+Files needed:
+
+[dejavusansmono.pf2](../media/gigabyte-ga-g41m-es2l/dejavusansmono.pf2)<br>
+[grub.cfg](../media/gigabyte-ga-g41m-es2l/grub.cfg)<br>
+
+## Packages needed to compile flashrom/coreboot/grub
+
+<pre>
+sudo apt-get install git build-essential gnat flex bison libncurses5-dev wget libpci-dev libusb-dev libftdi1 libftdi-dev unifont zlib1g-dev
+</pre>
+
+## Compile flashrom
+
+Clone flashrom git repository:
+
+<pre>
+git clone https://review.coreboot.org/flashrom.git
+</pre>
+
+Compile flashrom:
+
+<pre>
+cd flashrom
+make -j4
+sudo make install
+sudo cp /usr/local/sbin/flashrom /usr/local/bin/
+</pre>
+
+## Compile GRUB
+
+See '**Prerequisites**' above for the font file needed.
+
+Clone GRUB git repository:
+
+<pre>
+git clone https://git.savannah.gnu.org/git/grub.git
+</pre>
+
+Compile GRUB:
+
+<pre>
+cd grub
+git checkout grub-2.02
+./autogen.sh
+./configure --with-platform=coreboot
+make -j4
+</pre>
+
+Create '**pack-payload-minimal.sh**' script file:
+
+<pre>
+touch pack-payload-minimal.sh
+chmod +x pack-payload-minimal.sh
+</pre>
+
+Paste the following in '**pack-payload-minimal.sh**':
+
+<pre>
+#! /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"
+</pre>
+
+Execute the script to create '**grub2.elf**' file:
+
+<pre>
+./pack-payload-minimal.sh
+</pre>
+
+## Connect ch341a USB programmer to flash chip
+
+![Connect ch341a USB programmer](../media/gigabyte-ga-g41m-es2l/02-gigabyte-ga-g41m-es2l-internals.jpg)
+
+Connect Pomona 5250 to flash chip named '**M_BIOS**' like this:
+
+<pre>
+ __
+ CS 5 --| |-- 4 VCC
+ MISO 6 --| |-- 3 N/C
+ N/C 7 --| |-- 2 CLK
+ GND 8 --|__|-- 1 MOSI
+
+</pre>
+
+![ch341a USB programmer connected](../media/gigabyte-ga-g41m-es2l/03-ch341a-programmer-connected.jpg)
+
+## Read Factory BIOS
+
+Read Factory BIOS 3 times:
+
+<pre>
+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
+</pre>
+
+Make sure checksums are identical:
+
+<pre>
+sha512sum *.rom
+</pre>
+
+## Download coreboot
+
+Download coreboot:
+
+<pre>
+wget https://coreboot.org/releases/coreboot-4.9.tar.xz
+wget https://coreboot.org/releases/coreboot-blobs-4.9.tar.xz
+</pre>
+
+Extract coreboot and blobs needed:
+
+<pre>
+tar xvf coreboot-4.9.tar.xz
+tar xvf coreboot-blobs-4.9.tar.xz --strip-components=1 -C coreboot-4.9
+</pre>
+
+## Setup and compile coreboot
+
+Enter coreboot folder:
+
+<pre>
+cd coreboot-4.9
+</pre>
+
+Build toolchain needed first (this will take a long time, be patient):
+
+<pre>
+make crossgcc CPUS=4
+</pre>
+
+coreboot settings menu:
+
+<pre>
+make menuconfig
+</pre>
+
+Set the following options:
+
+<pre>
+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))
+ |-(0x100000) Size of CBFS filesystem in ROM
+Devices ---|
+ |-Graphics initialization (Use libgfxinit)
+ |-Display
+ |- Legacy VGA text mode
+payload ---|
+ |-Add a payload (An ELF executable payload)
+ |-"(grub2.elf)" Payload path and filename
+</pre>
+
+This will create a '**.config**' file containing all settings.
+
+Compile coreboot:
+
+<pre>
+make -j4
+</pre>
+
+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:
+
+<pre>
+cd coreboot-4.9/util/cbfstool
+make -j4
+</pre>
+
+Add custom GRUB configuration file:
+
+<pre>
+./cbfstool ../../build/coreboot.rom add -t raw -n etc/grub.cfg -f your/path/to/grub.cfg
+</pre>
+
+Check so that '**etc/grub.cfg**' exists in coreboot.rom:
+
+<pre>
+./cbfstool ../../build/coreboot.rom print
+</pre>
+
+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:
+
+<pre>
+sudo flashrom -p ch341a_spi -w coreboot.rom -V
+</pre>
+
+## Change Network card (optional)
+
+The onboard network card doesn't work by default and I recommend getting
+a PCI or PCIE network card. I'm using a PCI network card (D-Link
+DGE-528T) and that card works just fine without any proprietary drivers.
+
+Congratulations! We're done. Now you can install a libre distro such as
+[Debian GNU/Linux](https://www.debian.org/). I recommend setting up
+[full disc encryption (including
+/boot)](https://libreboot.org/docs/gnulinux/encrypted_debian.html) ! The
+'**grub.cfg**' supports and defaults to this option.
+
+## Recommended reading
+
+[https://www.coreboot.org/](https://www.coreboot.org/)<br>
+[https://flashrom.org/Flashrom](https://flashrom.org/Flashrom)<br>
+[https://github.com/boseji/CH341-Store](https://github.com/boseji/CH341-Store)<br>
+[https://libreboot.org/docs/gnulinux/encrypted_debian.html](https://libreboot.org/docs/gnulinux/encrypted_debian.html)<br>
+
diff --git a/include/sidebar.inc.php b/include/sidebar.inc.php
index c43c28e..bd2cad8 100755
--- a/include/sidebar.inc.php
+++ b/include/sidebar.inc.php
@@ -26,5 +26,9 @@ src="/media/header_left.png" alt="Harmonic Flow Logo" /></a>
class=\"active\"";?>><a
href="/blog/Flashing_coreboot_on_a_Lenovo_Thinkpad_X220_with_a_ch341a_USB_programmer_Tutorial.php">coreboot
on Lenovo X220</a></li>
+ <li<?php if($current_page=="misc-coreboot-gigabyte-ga-g41m-es2l") echo"
+ class=\"active\"";?>><a
+ href="/blog/Flashing_coreboot_on_Gigabyte_GA_G41M_ES2L_with_a_ch341a_USB_programmer_Tutorial.php">coreboot
+ on GA-G41M-ES2L</a></li>
</ul>
</div>
diff --git a/media/gigabyte-ga-g41m-es2l/01-prerequisites.jpg b/media/gigabyte-ga-g41m-es2l/01-prerequisites.jpg
new file mode 100644
index 0000000..ccd0d1a
--- /dev/null
+++ b/media/gigabyte-ga-g41m-es2l/01-prerequisites.jpg
Binary files differ
diff --git a/media/gigabyte-ga-g41m-es2l/02-gigabyte-ga-g41m-es2l-internals.jpg b/media/gigabyte-ga-g41m-es2l/02-gigabyte-ga-g41m-es2l-internals.jpg
new file mode 100644
index 0000000..127823b
--- /dev/null
+++ b/media/gigabyte-ga-g41m-es2l/02-gigabyte-ga-g41m-es2l-internals.jpg
Binary files differ
diff --git a/media/gigabyte-ga-g41m-es2l/03-ch341a-programmer-connected.jpg b/media/gigabyte-ga-g41m-es2l/03-ch341a-programmer-connected.jpg
new file mode 100644
index 0000000..fbbb9bd
--- /dev/null
+++ b/media/gigabyte-ga-g41m-es2l/03-ch341a-programmer-connected.jpg
Binary files differ
diff --git a/media/gigabyte-ga-g41m-es2l/dejavusansmono.pf2 b/media/gigabyte-ga-g41m-es2l/dejavusansmono.pf2
new file mode 100644
index 0000000..9ba557e
--- /dev/null
+++ b/media/gigabyte-ga-g41m-es2l/dejavusansmono.pf2
Binary files differ
diff --git a/media/gigabyte-ga-g41m-es2l/grub.cfg b/media/gigabyte-ga-g41m-es2l/grub.cfg
new file mode 100644
index 0000000..c63b34c
--- /dev/null
+++ b/media/gigabyte-ga-g41m-es2l/grub.cfg
@@ -0,0 +1,129 @@
+# Harmonic Flow's GRUB Configuration --- Use ThinkPads with Coreboot Firmware.
+# Modules 'cbfs' and 'normal' are supposed to be already loaded,
+# as well as its dependencies: terminal crypto extcmd boot gettext
+
+# Prefix --- The location of the "/boot/grub" directory as an absolute file name.
+set prefix=(memdisk)/boot/grub
+
+# Load Modules --- Load selected modules which are not loaded due
+# to dependencies and which have probably not been pre-loaded.
+insmod nativedisk
+insmod luks
+insmod lvm
+insmod ahci
+insmod ohci
+insmod uhci
+insmod ehci
+insmod part_msdos
+insmod part_gpt
+insmod fat
+insmod ext2
+insmod usbms
+insmod usb_keyboard
+insmod usbserial_usbdebug
+insmod syslinuxcfg
+insmod cryptodisk
+#insmod jpeg
+
+# Desktop Boards --- Let's load additional modules:
+insmod at_keyboard
+insmod pata
+
+# Set Environment
+set gfxpayload=keep
+set pager=1
+set default=0
+set timeout_style="menu"
+set timeout=5
+#set color_highlight=white/green
+#set color_normal=light-gray/black
+
+# Terminal Settings
+terminal_input --append at_keyboard
+terminal_output --append cbmemc
+terminal_output --append gfxterm
+
+# VESA Framebuffer Settings
+#background_image (cbfsdisk)/background.jpg
+loadfont dejavusansmono
+
+# Keymap --- several options available, adapt to your needs:
+# us gb de be nl it es pt fr tr ro bg pl cz hu se dk fi
+# us_intl us_dvorak ca_fr tr_f ch_de ch_fr sk_qwerty fr_latin9 de_nodeadkeys
+keymap se
+
+# GRUB Functions and Menu Options --- borrowed from the Libreboot Project
+function try_user_config {
+ set root="${1}"
+ for dir in boot grub grub2 boot/grub boot/grub2; do
+ for name in '' autoboot_ libreboot_ coreboot_; do
+ if [ -f /"${dir}"/"${name}"grub.cfg ]; then
+ unset superusers
+ configfile /"${dir}"/"${name}"grub.cfg
+ fi
+ done
+ done
+}
+function search_grub {
+ for i in 0 1; do
+ # raw devices
+ try_user_config "(${1}${i})"
+ for part in 1 2 3 4 5; do
+ # MBR/GPT partitions
+ try_user_config "(${1}${i},${part})"
+ done
+ done
+}
+function try_isolinux_config {
+ set root="${1}"
+ for dir in '' /boot; do
+ if [ -f "${dir}"/isolinux/isolinux.cfg ]; then
+ syslinux_configfile -i "${dir}"/isolinux/isolinux.cfg
+ elif [ -f "${dir}"/syslinux/syslinux.cfg ]; then
+ syslinux_configfile -s "${dir}"/syslinux/syslinux.cfg
+ fi
+ done
+}
+function search_isolinux {
+ for i in 0 1; do
+ # raw devices
+ try_isolinux_config "(${1}${i})"
+ for part in 1 2 3 4 5; do
+ # MBR/GPT partitions
+ try_isolinux_config "(${1}${i},${part})"
+ done
+ done
+}
+menuentry '[o] Load OS Encrypted /boot.. (default settings)' --hotkey='o' {
+ cryptomount -a
+ set root='lvm/matrix-rootvol'
+ linux /vmlinuz root=/dev/mapper/matrix-rootvol cryptdevice=/dev/mapper/matrix-rootvol:root
+ initrd /initrd.img
+}
+menuentry '[i] Load OS Encrypted /boot.. (with iomem=relaxed) ' --hotkey='i' {
+ cryptomount -a
+ set root='lvm/matrix-rootvol'
+ linux /vmlinuz root=/dev/mapper/matrix-rootvol cryptdevice=/dev/mapper/matrix-rootvol:root iomem=relaxed
+ initrd /initrd.img
+}
+menuentry '[g] Search GRUB2 Configuration (AHCI)' --hotkey='g' {
+ search_grub ahci
+}
+menuentry '[s] Search GRUB2 Configuration (USB)' --hotkey='s' {
+ search_grub usb
+}
+menuentry '[u] Search ISOLINUX Menu (USB)' --hotkey='u' {
+ search_isolinux usb
+}
+menuentry '[a] Search ISOLINUX Menu (AHCI)' --hotkey='a' {
+ search_isolinux ahci
+}
+menuentry '[d] Search ISOLINUX Menu (CD/DVD)' --hotkey='d' {
+ try_isolinux_config ahci1
+}
+menuentry '[p] Poweroff' --hotkey='p' {
+ halt --no-apm
+}
+menuentry '[r] Reboot' --hotkey='r' {
+ reboot
+}