Tyler Cipriani: pages tagged coreboot
Tyler Cipriani
https://tylercipriani.com/tags/coreboot/
Tyler Cipriani
ikiwiki
2019-02-21T20:59:13Z
Coreboot on the ThinkPad X220 with a Raspberry Pi
https://tylercipriani.com/blog/2016/11/13/coreboot-on-the-thinkpad-x220-with-a-raspberry-pi/
Tyler Cipriani
<a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike License</a>
Copyright © 2017 Tyler Cipriani
2019-02-21T20:59:13Z
2016-11-13T00:00:00Z
<p>My work laptop is terrible. About a year and a half ago, when I started my current gig, I received an Asus Zenbook that has been the bane of my existence ever since. First, it is impossible to work outside on this shiny monstrosity: all you see is your own dumb face squinting back at you, slightly obscured by very noticeable fingerprints from its mirror-like screen. Why are there fingerprints on the screen? Because, oh yeah, it’s a terrible touchscreen for no real reason. While the keyboard is serviceable, it is far from being a joy to use. There are no physical mouse buttons which, on a Linux install, means I’m forever flailing, trying to get middle-click paste to work (LPT: I setup an <code>xdotool</code> shortcut to paste – doesn’t work in Emacs though…). The Asus has also succumb to the Apple-esque use of dongles to replace all necessary ports (like Ethernet, FFS).</p>
<p>The final straw for this ridiculous machine was, for a reason that is beyond me, UEFI occasionally loses track of the boot drives and (although you can still <em>see</em>(!) the <code>.efi</code> file on disk via the UEFI interface) it won’t let you add it as a boot drive until you’ve sweated enough and/or there is a sufficiently powerful cosmic ray to flip the bits necessary to allow you to continue your life. This problem pretty much killed my productivity at my last offsite – as a result I decided to drop $500 and get a refurb ThinkPad X220 with more RAM and a bigger SSD than the ($1800) Zenbook.</p>
<section id="x-series-thinkpads-are-niiiiice" class="level2">
<h2>X-Series ThinkPads are niiiiice <a href="https://tylercipriani.com/tags/coreboot/#x-series-thinkpads-are-niiiiice">¶</a></h2>
<p>I have been using a ThinkPad X230t for the past 3 years, and, although the tablet is a little bulky, it has been everything I need in a work laptop – matte screen, physical buttons for all the things, an Ethernet port – it’s basically <em>not</em> an unbelievably stupid laptop design (which is the bar now, evidently). The X220 I purchased for work is even better – it’s slightly smaller (since it’s not also a Wacom tablet), plus the X220 has a <em>nice</em> keyboard – which – holy shit! – remember when anyone actually cared about laptop keyboards‽</p>
</section>
<section id="i-am-become-hacker-destroyer-of-laptops" class="level2">
<h2>I am become hacker, destroyer of laptops <a href="https://tylercipriani.com/tags/coreboot/#i-am-become-hacker-destroyer-of-laptops">¶</a></h2>
<p>One of the other reasons for buying the X220 is that I’ve heard-tell (A.K.A, did a quick DDG search) that it supports Coreboot (although, sadly, not Libreboot, yet). The actual incantations for flashing the ROM on the X220 are spread over a few sources, with some sizable gaps in process.</p>
<p>I spent the past 2 days pretty lost, flailing in the dark, booting my freshly flashed laptop to a momentary flicker of the green power-light, no fans, nothing, sighing, and compiling again. Now I stand victorious, Debian stable (8.6 as of November 2016) is booting from SeaBIOS.</p>
<p>I kept a lot of notes on the process. Hopefully, these notes save someone some frustration, or make this process a tiny bit more approachable.</p>
<p><strong>Caveat Emptor</strong> – I’m terrible at hardware stuff and writing, so follow these steps at your own peril!</p>
</section>
<section id="things-you-need" class="level2">
<h2>Things you need <a href="https://tylercipriani.com/tags/coreboot/#things-you-need">¶</a></h2>
<ul>
<li>Lonovo ThinkPad X220</li>
<li><a href="https://www.adafruit.com/products/954">USB to TTY Serial Cable</a></li>
<li><a href="https://www.amazon.com/gp/product/B01CD5VC92/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1">Raspberry Pi 3 Model B</a></li>
<li><a href="https://www.amazon.com/gp/product/B00HHH65T4/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1">Pomona SOIC8 5250 Test Clip</a></li>
<li>8x <a href="https://www.adafruit.com/products/266">Female Jumper Wire</a></li>
<li>An HDMI monitor and external keyboard (possibly, you may be able to figure out how to do this without one)</li>
<li>Another computer that will act as your Raspberry Pi terminal via the USB to TTY serial cable (is what I did anyway)</li>
</ul>
<figure>
<img src="https://photos.tylercipriani.com/thumbs/13/0a884ef61214ae613c739a1460245b6da8c506/x220-spi-raspberry-pi-in-screen-1280.jpg" alt="What the whole flashing setup looked like for me X230 -> USB-to-TTY -> Raspberry Pi -> Pomona Clip -> X220" /><figcaption><a href="https://photos.tylercipriani.com/thumbs/13/0a884ef61214ae613c739a1460245b6da8c506/x220-spi-raspberry-pi-in-screen-original.jpg">What the whole flashing setup looked like for me X230 -> USB-to-TTY -> Raspberry Pi -> Pomona Clip -> X220</a></figcaption>
</figure>
</section>
<section id="thinkpad-x220-disassembly" class="level2">
<h2>ThinkPad X220 Disassembly <a href="https://tylercipriani.com/tags/coreboot/#thinkpad-x220-disassembly">¶</a></h2>
<ol type="1">
<li>Remove Keyboard and palmrest (follow <a href="https://support.lenovo.com/us/en/videos/pd022683">Lonovo’s Guide</a>)
<ul>
<li>Power down and remove battery</li>
<li>I removed the keyboard and palm rest in 2 separate steps.</li>
<li>Flip over and remove the 7 screws holding the keyboard and palmrest in place (they all have a picture of a square with 3 buttons [trackpad, I guess] near them).</li>
<li><strong>WARNING</strong> – 2 of these screws are different sizes than the other 5! The ones closest to the front-edge of the laptop are shorter, keep them seperate.</li>
<li>Locations Diagram:</li>
</ul>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb1-1" title="1"> <span class="ex">Bottom</span> of the ThinkPad -- <span class="st">'X'</span> marks screws to be removed</a>
<a class="sourceLine" id="cb1-2" title="2"> <span class="ex">+-----------------------------------------------------------+</span></a>
<a class="sourceLine" id="cb1-3" title="3"> <span class="kw">|</span> <span class="ex">xxxxxxxxxxxx</span> Battery xxxxxxxxxxxxxxxxxxxxxxxxx <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-4" title="4"> <span class="kw">|</span> <span class="ex">xxxxxxxxxxxxx</span> Area xxxxxxxxxxxxxxxxxxxxxxxxxxx <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-5" title="5"> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-6" title="6"> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-7" title="7"> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-8" title="8"> <span class="kw">|</span> <span class="ex">+----X----------------+</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-9" title="9"> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-10" title="10"> <span class="kw">|</span> <span class="kw">|</span> <span class="ex">Memory</span> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-11" title="11"> <span class="kw">|</span> <span class="kw">|</span> <span class="ex">Door</span> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-12" title="12"> <span class="kw">|</span> <span class="ex">X</span> <span class="kw">|</span> <span class="ex">X</span> <span class="kw">|</span> <span class="ex">X</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-13" title="13"> <span class="kw">|</span> <span class="ex">X</span> +---------------------+ <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-14" title="14"> <span class="kw">|</span> <span class="ex">X</span> X <span class="kw">|</span></a>
<a class="sourceLine" id="cb1-15" title="15"> <span class="ex">+-----------------------------------------------------------+</span></a></code></pre></div>
<ul>
<li>Flip it over, push the keyboard back, pull up the tabs near the palmrest.</li>
<li>Rest the removed keyboard on the palmrest and remove ribbon cable from the motherboard.</li>
<li>Flip palmrest up, and click the ribbon cable holding it in place, remove it.</li>
<li>Lift tape on the left side of motherboard covering the chip you’re looking for.</li>
<li>The BIOS chip you are looking for is <strong>right there</strong> – the left-front of the motherboard if the screen is facing you.</li>
</ul></li>
</ol>
<figure>
<img src="https://photos.tylercipriani.com/thumbs/de/8c2006845e8c04acda39da8c1ff39b6330175e/pomona-clip-on-x220-1280.jpg" alt="Pomona 5250 attached to BIOS clip on ThinkPad X220" /><figcaption><a href="https://photos.tylercipriani.com/thumbs/de/8c2006845e8c04acda39da8c1ff39b6330175e/pomona-clip-on-x220-original.jpg">Pomona 5250 attached to BIOS clip on ThinkPad X220</a></figcaption>
</figure>
</section>
<section id="setup-your-pi-as-a-flasher" class="level2">
<h2>Setup Your Pi as a Flasher <a href="https://tylercipriani.com/tags/coreboot/#setup-your-pi-as-a-flasher">¶</a></h2>
<p>Now that you have access to the BIOS chip, you should setup your Raspberry Pi, and attach it to the Pomona 5250 clip via the SPI pins. Unfortunately, you do seem to need a monitor with HDMI to setup the Pi (someone better at Raspberry Pi things may know better).</p>
<p>After the initial setup I was able to switch to using a serial cable interface.</p>
<blockquote>
<p><strong>GIANT HUGE WARNING OF DOOM</strong>: Hook your Pomona clip to your motherboard <strong>ONLY WITH THE BATTERY REMOVED, THE X220 UNPLUGGED, AAAANNDDD THE RASPBERRY PI OFF!!!!</strong> You could probably fry this chip. I don’t actually know, but I was paranoid about it throughout the process. Power on the Raspberry Pi only when you’re certain the Pomona clip is secure.</p>
</blockquote>
<ol type="1">
<li>Download the <a href="https://www.raspberrypi.org/downloads/raspbian/">Raspbian Lite</a> torrent</li>
<li><p>Unzip the rasbian zip file and copy to an sd card</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb2-1" title="1"><span class="fu">dd</span> bs=4M if=rasbian-lite.img of=/dev/<span class="op"><</span>partition of sd card<span class="op">></span></a></code></pre></div></li>
<li><p>Hook up your Raspberry Pi to a monitor and boot</p></li>
<li><p>Change password using <code>passwd</code> (default user/pass: <code>pi</code>/<code>raspberry</code>)</p></li>
<li><p>Setup wifi by editing <code>/etc/wpa_supplicant/wpa_supplicant.conf</code></p>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb3-1" title="1"><span class="va">network=</span><span class="kw">{</span></a>
<a class="sourceLine" id="cb3-2" title="2"> <span class="va">ssid=</span><span class="st">"YOUR_SSID"</span></a>
<a class="sourceLine" id="cb3-3" title="3"> <span class="va">psk=</span><span class="st">"YOUR_PASSWORD"</span></a>
<a class="sourceLine" id="cb3-4" title="4"><span class="kw">}</span></a></code></pre></div></li>
<li><p>Edit <code>/boot/config.txt</code></p>
<div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb4-1" title="1"><span class="va">dtparam=</span>spi=<span class="ex">on</span></a>
<a class="sourceLine" id="cb4-2" title="2"><span class="va">enable_uart=</span>1</a></code></pre></div></li>
<li><p>Now you can reboot and hook to a serial cable:</p>
<p>Serial cable hookup diagram:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb5-1" title="1"> <span class="ex">Edge</span> of pi (furthest from you)</a>
<a class="sourceLine" id="cb5-2" title="2"> <span class="ex">L</span> PWR GND TXD RXD</a>
<a class="sourceLine" id="cb5-3" title="3"> <span class="ex">E</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb5-4" title="4"> <span class="ex">F</span> +----v---------v----v----v-------------------------------------------------------------------------------+</a>
<a class="sourceLine" id="cb5-5" title="5"> <span class="ex">T</span> <span class="kw">|</span> <span class="ex">x</span> x x x x x x x x x x x x x x x x x x x <span class="kw">|</span></a>
<a class="sourceLine" id="cb5-6" title="6"> <span class="kw">|</span> <span class="ex">x</span> x x x x x x x x x x x x x x x x x x x <span class="kw">|</span></a>
<a class="sourceLine" id="cb5-7" title="7"> <span class="ex">E</span> +--------------------------------------------------------------------------------------------------------+</a>
<a class="sourceLine" id="cb5-8" title="8"> <span class="ex">D</span></a>
<a class="sourceLine" id="cb5-9" title="9"> <span class="ex">G</span></a>
<a class="sourceLine" id="cb5-10" title="10"> <span class="ex">E</span></a>
<a class="sourceLine" id="cb5-11" title="11"> <span class="ex">Body</span> of Pi (closest to you)</a></code></pre></div></li>
<li><p>Install all the pre-req software working mostly from github wiki page <a href="https://github.com/bibanon/Coreboot-ThinkPads/wiki/Hardware-Flashing-with-Raspberry-Pi">Hardware Flashing with Raspberry Pi</a></p>
<div class="sourceCode" id="cb6"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb6-1" title="1"><span class="fu">sudo</span> apt-get update <span class="kw">&&</span> <span class="fu">sudo</span> apt-get dist-upgrade <span class="kw">&&</span> <span class="fu">sudo</span> reboot</a>
<a class="sourceLine" id="cb6-2" title="2"><span class="fu">sudo</span> apt-get update <span class="kw">&&</span> <span class="fu">sudo</span> apt-get install libftdi1 libftdi-dev libusb-dev libpci-dev subversion</a>
<a class="sourceLine" id="cb6-3" title="3"><span class="fu">sudo</span> apt-get install build-essential pciutils usbutils libpci-dev libusb-dev libftdi1 libftdi-dev zlib1g-dev subversion</a>
<a class="sourceLine" id="cb6-4" title="4"><span class="fu">svn</span> co svn://flashrom.org/flashrom/trunk flashrom</a>
<a class="sourceLine" id="cb6-5" title="5"><span class="bu">cd</span> flashrom</a>
<a class="sourceLine" id="cb6-6" title="6"><span class="fu">make</span></a>
<a class="sourceLine" id="cb6-7" title="7"><span class="fu">sudo</span> make install</a></code></pre></div>
<p>Add the SPI kernal modules to <code>/etc/modules</code> so they persist between boots.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb7-1" title="1"><span class="fu">sudo</span> modprobe spi_bcm2835</a>
<a class="sourceLine" id="cb7-2" title="2"><span class="fu">sudo</span> modprobe spidev</a></code></pre></div></li>
<li><p>Power down the Pi, Hook your Pi to your Pomona clip, then hook the Pomona clip to the motherboard, and power back up.</p>
<figure>
<img src="https://photos.tylercipriani.com/thumbs/1f/2067e7cd72a601f189c9cd60f17c3ecbac0039/pomona-clip-to-raspberry-pi-1280.jpg" alt="Raspberry Pi 3 attached to ThinkPad X220 Pomona Clip" /><figcaption><a href="https://photos.tylercipriani.com/thumbs/1f/2067e7cd72a601f189c9cd60f17c3ecbac0039/pomona-clip-to-raspberry-pi-original.jpg">Raspberry Pi 3 attached to ThinkPad X220 Pomona Clip</a></figcaption>
</figure>
<p>X220 BIOS Chip pinout</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb8-1" title="1"> <span class="ex">Screen</span> (furthest from you)</a>
<a class="sourceLine" id="cb8-2" title="2"> <span class="ex">__</span></a>
<a class="sourceLine" id="cb8-3" title="3"> <span class="ex">MOSI</span> 5 --<span class="kw">|</span> <span class="kw">|</span><span class="ex">--</span> 4 GND</a>
<a class="sourceLine" id="cb8-4" title="4"> <span class="ex">CLK</span> 6 --<span class="kw">|</span> <span class="kw">|</span><span class="ex">--</span> 3 N/C</a>
<a class="sourceLine" id="cb8-5" title="5"> <span class="ex">N/C</span> 7 --<span class="kw">|</span> <span class="kw">|</span><span class="ex">--</span> 2 MISO</a>
<a class="sourceLine" id="cb8-6" title="6"> <span class="ex">VCC</span> 8 --<span class="kw">|</span><span class="ex">__</span><span class="kw">|</span><span class="ex">--</span> 1 CS</a>
<a class="sourceLine" id="cb8-7" title="7"></a>
<a class="sourceLine" id="cb8-8" title="8"> <span class="ex">Edge</span> (closest to you)</a></code></pre></div>
<p>PI Pinout</p>
<p><strong>WARNING!!!</strong> This is the pinout for the <strong>RASPBERRY PI 3 MODEL B V1.2</strong> it has 40 pins rather than 26</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb9-1" title="1"> <span class="ex">Edge</span> of pi (furthest from you)</a>
<a class="sourceLine" id="cb9-2" title="2"> <span class="ex">L</span> CS</a>
<a class="sourceLine" id="cb9-3" title="3"> <span class="ex">E</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb9-4" title="4"> <span class="ex">F</span> +--------------------------------------------------------------------------------------------------------+</a>
<a class="sourceLine" id="cb9-5" title="5"> <span class="ex">T</span> <span class="kw">|</span> <span class="ex">x</span> x x x x x x x x x x x x x x x x x x x <span class="kw">|</span></a>
<a class="sourceLine" id="cb9-6" title="6"> <span class="kw">|</span> <span class="ex">x</span> x x x x x x x x x x x x x x x x x x x <span class="kw">|</span></a>
<a class="sourceLine" id="cb9-7" title="7"> <span class="ex">E</span> +--------------------------------------------^----^----^----^---------------------------------------^----+</a>
<a class="sourceLine" id="cb9-8" title="8"> <span class="ex">D</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span></a>
<a class="sourceLine" id="cb9-9" title="9"> <span class="ex">G</span> 3.3V MOSI MISO <span class="kw">|</span> <span class="ex">GND</span></a>
<a class="sourceLine" id="cb9-10" title="10"> <span class="ex">E</span> (VCC) <span class="ex">CLK</span></a>
<a class="sourceLine" id="cb9-11" title="11"> <span class="ex">Body</span> of Pi (closest to you)</a></code></pre></div></li>
<li><p>See if <code>flashrom</code> can detect your chipset (if you see <code>No EEPROM/flash device found.</code> double check your connections and the pins for your pi – I realized I had my pins setup as if I were on the 26-GPIO pin Raspberry Pi rather than the 40-GPIO pin model 3)</p>
<blockquote>
<p><strong>NOTE</strong>: 2018-04-06</p>
<p>One person emailed to indicate that the flashrom commands below required setting an <code>spispeed</code>, i.e., <code>sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=512</code></p>
</blockquote>
<div class="sourceCode" id="cb10"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb10-1" title="1"><span class="ex">pi@raspberrypi</span>:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0</a>
<a class="sourceLine" id="cb10-2" title="2"><span class="ex">flashrom</span> v0.9.9-r1954 on Linux 4.4.26-v7+ (armv7l)</a>
<a class="sourceLine" id="cb10-3" title="3"><span class="ex">flashrom</span> is free software, get the source code at https://flashrom.org</a>
<a class="sourceLine" id="cb10-4" title="4"></a>
<a class="sourceLine" id="cb10-5" title="5"><span class="ex">Calibrating</span> delay loop... OK.</a>
<a class="sourceLine" id="cb10-6" title="6"><span class="ex">Found</span> Winbond flash chip <span class="st">"W25Q64.V"</span> (8192 kB, SPI) <span class="ex">on</span> linux_spi.</a>
<a class="sourceLine" id="cb10-7" title="7"><span class="ex">No</span> operations were specified.</a></code></pre></div></li>
<li><p>Read your flashchip and verify that the md5sums match. If the md5sums of your reads don’t match repeat steps 9 and 10 until they do. If they never do, check your wiring with a multimeter (I had to do this at one point).</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb11-1" title="1"><span class="ex">pi@raspberrypi</span>:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0 -r flash01.bin</a>
<a class="sourceLine" id="cb11-2" title="2"><span class="ex">pi@raspberrypi</span>:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0 -r flash02.bin</a>
<a class="sourceLine" id="cb11-3" title="3"><span class="ex">pi@raspberrypi</span>:~$ md5sum flash01.bin flash02.bin</a></code></pre></div></li>
<li><p>Download coreboot on the Pi. Compile and use <code>ifdtool</code> to extract all the needed bits to all the right places in the coreboot <code>blobs</code> directory.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb12-1" title="1"><span class="fu">git</span> clone http://review.coreboot.org/coreboot.git ~/coreboot</a>
<a class="sourceLine" id="cb12-2" title="2"><span class="bu">cd</span> ~/coreboot</a>
<a class="sourceLine" id="cb12-3" title="3"><span class="fu">git</span> submodule update --init --recursive</a>
<a class="sourceLine" id="cb12-4" title="4"><span class="bu">cd</span> ~/coreboot/util/ifdtool</a>
<a class="sourceLine" id="cb12-5" title="5"><span class="fu">make</span></a>
<a class="sourceLine" id="cb12-6" title="6"><span class="fu">sudo</span> make install</a>
<a class="sourceLine" id="cb12-7" title="7"><span class="bu">cd</span> ~</a>
<a class="sourceLine" id="cb12-8" title="8"><span class="ex">ifdtool</span> -x ~/flash01.bin</a>
<a class="sourceLine" id="cb12-9" title="9"><span class="fu">mkdir</span> -p ~/coreboot/3rdparty/blobs/mainboard/lenovo/x220</a>
<a class="sourceLine" id="cb12-10" title="10"><span class="bu">cd</span> ~/coreboot/3rdparty/blobs/mainboard/lenovo/x220</a>
<a class="sourceLine" id="cb12-11" title="11"><span class="fu">mv</span> ~/flashregion_0_flashdescriptor.bin descriptor.bin</a>
<a class="sourceLine" id="cb12-12" title="12"><span class="fu">mv</span> ~/flashregion_2_intel_me.bin me.bin</a>
<a class="sourceLine" id="cb12-13" title="13"><span class="fu">mv</span> ~/flashregion_3_gbe.bin gbe.bin</a></code></pre></div>
<blockquote>
<p><strong>NOTE</strong>: 2017-06-15</p>
<p>Thomas Maulbeck emailed me and mentioned that <code>git submodule update --init --recursive</code> did not populate the <code>3rdparty/blobs</code> directory. It seems that <code>.gitmodules</code> for coreboot has several urls that look in the parent directory for bare git repositories that don’t exist in the setup I’ve described in this post.</p>
<p>Maulbeck was able to work around compilation errors by cloning <code>3rdparty/blobs</code> directly:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb13-1" title="1"><span class="bu">cd</span> ~/coreboot/3rdparty</a>
<a class="sourceLine" id="cb13-2" title="2"><span class="fu">git</span> clone http://review.coreboot.org/p/blobs.git</a></code></pre></div>
<p>If compilation fails with some mention of a missing <code>3rdparty/blobs/cpu/intel/model_206ax/microcode.bin</code> this may be the root cause.</p>
</blockquote></li>
<li><p>Build coreboot on the Pi <a href="https://www.coreboot.org/Build_HOWTO">following the wiki instructions</a></p>
<ul>
<li>configure via (<strong>note</strong> – this is completely cargo-culted bullshit and YMMV…a lot) <code>make nconfig</code></li>
</ul>
<div class="sourceCode" id="cb14"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb14-1" title="1"><span class="ex">general</span></a>
<a class="sourceLine" id="cb14-2" title="2"> <span class="ex">-</span> [*] Compress ramstage with LZMA</a>
<a class="sourceLine" id="cb14-3" title="3"> <span class="ex">-</span> [*] Include coreboot .config file into the ROM image</a>
<a class="sourceLine" id="cb14-4" title="4"> <span class="ex">-</span> [*] Allow use of binary-only repository</a>
<a class="sourceLine" id="cb14-5" title="5"><span class="ex">mainboard</span></a>
<a class="sourceLine" id="cb14-6" title="6"> <span class="ex">-</span> Mainboard vendor (Lenovo)</a>
<a class="sourceLine" id="cb14-7" title="7"> <span class="ex">-</span> Mainboard model (ThinkPad X220)</a>
<a class="sourceLine" id="cb14-8" title="8"> <span class="ex">-</span> ROM chip size (8192 KB (8 MB))</a>
<a class="sourceLine" id="cb14-9" title="9"> <span class="ex">-</span> (0x100000) <span class="ex">Size</span> of CBFS filesystem in ROM</a>
<a class="sourceLine" id="cb14-10" title="10"><span class="ex">chipset</span></a>
<a class="sourceLine" id="cb14-11" title="11"> <span class="ex">-</span> [*] Enable VMX for virtualization</a>
<a class="sourceLine" id="cb14-12" title="12"> <span class="ex">-</span> Include CPU microcode in CBFS (Generate from tree)</a>
<a class="sourceLine" id="cb14-13" title="13"> <span class="ex">-</span> Flash ROM locking on S3 resume (Don<span class="st">'t lock ROM sections on S3 resume)</span></a>
<a class="sourceLine" id="cb14-14" title="14"><span class="st"> - [*] Add Intel descriptor.bin file</span></a>
<a class="sourceLine" id="cb14-15" title="15"><span class="st"> (3rdparty/blobs/mainboard/$(MAINBOARDDIR)/descriptor.bin) Path and filename of the descriptor.bin file</span></a>
<a class="sourceLine" id="cb14-16" title="16"><span class="st"> - [*] Add Intel ME/TXE firmware</span></a>
<a class="sourceLine" id="cb14-17" title="17"><span class="st"> (3rdparty/blobs/mainboard/$(MAINBOARDDIR)/me.bin) Path to management engine firmware</span></a>
<a class="sourceLine" id="cb14-18" title="18"><span class="st"> - [*] Add gigabit ethernet firmware</span></a>
<a class="sourceLine" id="cb14-19" title="19"><span class="st"> (3rdparty/blobs/mainboard/$(MAINBOARDDIR)/gbe.bin) Path to gigabit ethernet firmware</span></a>
<a class="sourceLine" id="cb14-20" title="20"><span class="st">devices</span></a>
<a class="sourceLine" id="cb14-21" title="21"><span class="st"> - [*] Use native graphics initialization</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="st">display</span></a>
<a class="sourceLine" id="cb14-23" title="23"><span class="st"> - (nothing checked)</span></a>
<a class="sourceLine" id="cb14-24" title="24"><span class="st">generic drivers</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="st"> - [*] Support Intel PCI-e WiFi adapters</span></a>
<a class="sourceLine" id="cb14-26" title="26"><span class="st"> - [*] PS/2 keyboard init</span></a>
<a class="sourceLine" id="cb14-27" title="27"><span class="st">console</span></a>
<a class="sourceLine" id="cb14-28" title="28"><span class="st"> - [*] Squelch AP CPUs from early console.</span></a>
<a class="sourceLine" id="cb14-29" title="29"><span class="st"> [*] Show POST codes on the debug console</span></a>
<a class="sourceLine" id="cb14-30" title="30"><span class="st">system tables</span></a>
<a class="sourceLine" id="cb14-31" title="31"><span class="st"> - [*] Generate SMBIOS tables</span></a>
<a class="sourceLine" id="cb14-32" title="32"><span class="st">payload</span></a>
<a class="sourceLine" id="cb14-33" title="33"><span class="st"> - Add a payload (SeaBIOS)</span></a>
<a class="sourceLine" id="cb14-34" title="34"><span class="st"> - SeaBIOS version (master)</span></a>
<a class="sourceLine" id="cb14-35" title="35"><span class="st"> - (3000) PS/2 keyboard controller initialization timeout (milliseconds)</span></a>
<a class="sourceLine" id="cb14-36" title="36"><span class="st"> - [*] Harware init during option ROM execution</span></a>
<a class="sourceLine" id="cb14-37" title="37"><span class="st"> - [*] Include generated option rom that implements legacy VGA BIOS compatibility</span></a>
<a class="sourceLine" id="cb14-38" title="38"><span class="st"> - [*] Use LZMA compression for payloads</span></a>
<a class="sourceLine" id="cb14-39" title="39"><span class="st">debugging</span></a>
<a class="sourceLine" id="cb14-40" title="40"><span class="st"> - (nothing checked)</span></a></code></pre></div>
<blockquote>
<p><strong>NOTE</strong>: 2018-04-06</p>
<p>One person emailed to mention that <code>make nconfig</code> may require a number of dependencies, see the <a href="https://www.coreboot.org/Build_HOWTO#debian">coreboot wiki</a> for a complete list. As of this writing that list reads: <code>apt-get install git build-essential gnat flex bison libncurses5-dev wget zlib1g-dev</code></p>
</blockquote>
<ul>
<li>Compile coreboot!</li>
</ul>
<div class="sourceCode" id="cb15"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb15-1" title="1"><span class="fu">make</span> crossgcc-i386 CPUS=4</a>
<a class="sourceLine" id="cb15-2" title="2"><span class="fu">make</span> iasl</a>
<a class="sourceLine" id="cb15-3" title="3"><span class="fu">make</span></a></code></pre></div>
<blockquote>
<p><strong>EDIT – 2016-11-27</strong> Andreas Sinninger pointed out I was missing the path to the Intel ME/TXE firmware – corrected.</p>
</blockquote></li>
<li><p>FINALLY! Flash your new <code>coreboot.rom</code> to your rom chip:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb16-1" title="1"><span class="ex">pi@raspberrypi</span>:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0 -r flash01.bin</a>
<a class="sourceLine" id="cb16-2" title="2"><span class="ex">pi@raspberrypi</span>:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0 -r flash02.bin</a>
<a class="sourceLine" id="cb16-3" title="3"><span class="ex">pi@raspberrypi</span>:~$ md5sum flash01.bin flash02.bin <span class="co"># if these don't match, stop, turn off the pi, fiddle with the Pomona clip, repeat this step</span></a>
<a class="sourceLine" id="cb16-4" title="4"><span class="ex">pi@raspberrypi</span>:~$ sudo flashrom -p linux_spi:dev=/dev/spidev0.0 -w ~/coreboot/build/coreboot.rom</a></code></pre></div></li>
</ol>
<p>If your laptop boots up to a SeaBIOS screen at this point: you win! If not, don’t despair, you can flash <code>flash01.bin</code> to go back to your old BIOS, or, better yet, keep compiling until it works.</p>
</section>
<section id="resources" class="level2">
<h2>Resources <a href="https://tylercipriani.com/tags/coreboot/#resources">¶</a></h2>
<p>These are some general resources without which my X220 would be a pathetic pile of smashed up silicon by now.</p>
<ul>
<li><a href="https://www.coreboot.org/Board:lenovo/x220">ThinkPad X220 on the coreboot wiki</a></li>
<li><a href="https://github.com/bibanon/Coreboot-ThinkPads/wiki/Hardware-Flashing-with-Raspberry-Pi">GitHub Coreboot-ThinkPad wiki, Hardware Flashing with Raspberry Pi</a></li>
<li><a href="https://blog.noq2.net/corebooting-thinkpad-x230.html">noq2 - Corebooting ThinkPad x230</a></li>
<li><a href="https://www.ericholzbach.net/blog/x230_coreboot/">Eric Holzback - Coreboot on the Lonovo X230</a></li>
</ul>
</section>