A new post titled "2015-08-21 Librem 13: Weekly Progress Update" has been published on the coreboot blog. Find the full post at http://blogs.coreboot.org/blog/2015/08/24/2015-08-21-librem-13-weekly-progress-update/

<p>This post covers the <a href="https://puri.sm/librem-13/">Librem 13</a> engineering considerations around writing to the SPI flash chip, and how that affects coreboot development. This builds on <a href="http://blogs.coreboot.org/blog/2015/08/14/2015-08-14-librem-13-weekly-progress-update/">last week’s notes</a> on the low level I/O for debugging coreboot builds. As always, email questions or comments to: <em>larry.moberg@puri.sm</em>.</p>
<p>The BIOS flash on the Librem 13 is an 8 MiB chip in a SOP-8 package. The EC firmware is located on a separate 64 KiB chip. <a href="https://i.imgur.com/WmKq3Om.jpg">This link</a> can be used to locate the chips on your mainboard: the BIOS flash is halfway down, near the CPU heatpipe. The EC flash is at the bottom just below the DDR3L module.</p>
<p>Even without any patches specifically for the Librem 13, <a href="http://flashrom.org/">flashrom</a> can flawlessly read its BIOS flash because it supports the PCH. Unless you write outside the BIOS region, you will not encounter any problems using flashrom to update your BIOS.</p>
<p><em>Please don’t update the Intel Firmware Descriptor or ME region just yet</em>–all the IFD bits are marked read/write and flashrom is happy to execute a write to that region. The issue arises because the ME writes asynchronously to the ME region. A collision of flashrom and ME writes will corrupt the ME region and may brick the laptop. Purism intends to provide an unlocked ME that respects your freedom, so look for an update on the <a href="http://puri.sm/posts/">purism blog</a>.</p>
<h4>In-System Programming The BIOS Flash</h4>
<p>The BIOS can be written and verified using a SOP-8 clip after closing the two sides of jumper J1 to assert the PCH RSMRST# pin. <em>Warning: reflashing the BIOS risks bricking the laptop until in-system programming and/or soldering a new BIOS chip restores the BIOS to a good state.<br />
</em></p>
<h4>EC Flash</h4>
<p>The KB3930 datasheet, section 3.1 “Hardware Trap,” gives the method for programming the EC flash:</p>
<ol>
<li>Disconnect the battery and the A/C power so that the EC is fully powered down.</li>
<li>Pull GPIO23/TP_ISP (pin 42) to GND. Note the internal 40K-ohm pull-up resistor.</li>
<li>Connect the A/C power supply to the board. The EC is now powered up.</li>
<li>TP_ISP sets CS#, SPI_CLK, MISO, and MOSI lines “High-Z”.</li>
<li>Connect a SOP-8 clip and flash programmer and flash the EC firmware.</li>
</ol>
<p>It should be noted fine-pitch soldering is required to connect to pin 42 on the EC. The KB3930 also supports firmware updates via software. In the interest of all users’ privacy and security, <a href="https://puri.sm/wp-content/uploads/2015/08/librem13v1-ec-firmware.zip" rel="attachment wp-att-1510">here is a listing</a> of the 8051 opcodes for the current Librem 13 EC firmware.</p>
<h4>EC Firmware Listing Notes</h4>
<p>This listing is still incomplete. Here are some notes:</p>
<ol>
<li>KB3930-specific Special Function Registers (SFR), SFR bits, and interrupt vectors are labelled like in the datasheet.</li>
<li>Besides the jump tables and switch tables, there is some 8051 code not listed as code. It appears to be unreachable, though in time the execution path to reach these sections may be found.</li>
<li>No A5 opcode. Some 8051 implementations add this opcode, but the KB3930 uses a vanilla 8051 architecture.</li>
<li><em>This is not Free Software.</em> Users should have the ability to verify their shipped firmware against this listing but Purism’s goal is to provide a Free Software implementation of the EC firmware.</li>
</ol>
<h3>Conclusions</h3>
<p>This post covers the steps for coreboot development and recovery. Fortunately, the EC firmware is not shared with the BIOS or ME blob, which makes flashrom’s job easier.</p>
<p>BIOS development is hard. One of the major challenges facing BIOS developers is a lack of accurate, comprehensive documentation for all the hardware coreboot interacts with. The “elephant in the room,” for an Intel-based laptop, is the Management Engine.</p>