Board:lenovo/x200: Difference between revisions

From coreboot
Jump to navigation Jump to search
No edit summary
(Remove outdated information)
 
(43 intermediate revisions by 11 users not shown)
Line 3: Line 3:
Works:
Works:
* USB
* USB
* USB Debug (on the right port near the ThinkPad Logo)
* Audio (internal speakers, internal mic, headphones, external mic)
* Audio (internal speakers, internal mic, headphones, external mic)
* WLAN (first minipcie slot)
* WLAN (first minipcie slot)
Line 23: Line 24:
* suspend to RAM (S3)
* suspend to RAM (S3)
* Expresscard slot (including hotplug)
* Expresscard slot (including hotplug)
* Wake on LID, wake on Fn.
* Dock
* Digitizer on x200t variant
* Modem


Untested:
== X200S and X200 Tablet ==
* Modem (probably works)
* dock (probably doesn't work)
* digitizer on x200t variant (probably doesn't work)


Both the X200S and X200 Tablet use a WSON-8 package for the flash chip. This has the same pinout as a SOIC-8 flash chip, but you will need to solder some (very thin) wires to a pin header since no clips are available for this type of connection.


== proprietary components status ==
[https://www.coreboot.org/File:X200T_spiflash.jpg Location on motherboard] [http://libreboot.org/docs/install/images/x200/wson_soldered.jpg Here is an example]
* CPU Microcode
* VGA option rom (optional): you need it if you want graphics
* ME(Management Engine) => you do not have to touch it(just leave it where it is)
* EC(Embedded Controller) => you do not have to touch it(just leave it where it is)


== Flashing ==
Regular X200 laptops will use either a SOIC-8 or SOIC-16 connection (recommended for average users, who most likely do not want to solder).
First flashing needs to be external. I use buspirate and pomona clip


Flash in X200 is divided roughly in 4 parts:
== Proprietary components status ==
* CPU microcode (optional) <small><see '''note 1'''></small>
* VGA option rom (optional) => You need it if you want graphics in SeaBIOS but most payloads should work without it (text mode <small><see '''note 2'''></small> or corebootfb mode)
* ME (Management Engine) (optional) => Can be removed by using a modified flash descriptor (see notes below about the ich9gen utility)
* EC (Embedded Controller) => You do not have to touch it (just leave it where it is)


* Descriptor (12K)
'''<small>note 1:</small>'''
* ME firmware (6M-12K)
 
* Rewriteable flash (2M-128K)
VT-x (hardware-assisted virtualization) stops working without microcode updates.
* Locked bootblock (128K)
The laptop will randomly and sporadically crash without microcode updates. The conditions under which these crashes occur at currently not known.
 
== Dumping the original firmware ==
First flashing needs to be external. phcoder used the buspirate and a pomona 5252 clip (SOIC-16). For SOIC-8 flash chips, you can use the Pomona 5250.
 
Unless modified (through the descriptor), the X200 flash as shipped by Lenovo is divided in 5 parts.
 
For systems with the 8MiB flash chip:
 
* Descriptor (4K) - first region
* ME (also includes AMT) (6100K) - 2nd region
* Gbe (8K) - 3rd region
* Platform (32K) - 4th region
* BIOS (2M) - 5th region
 
For systems with the 4MiB flash chip:
 
* Descriptor (4K) - first region
* ME (no AMT) (2004K) - 2nd region
* Gbe (8K) - 3rd region
* Platform (32K) - 4th region
* BIOS (2M) - 5th region
 
Flash chip sizes can be identified through flashrom. Generally, the following is true:
 
* SOIC-8  = 4MiB (rare on these machines)
* SOIC-16 = 8MiB (common on these machines)


<gallery>
<gallery>
[[File:X200.jpg]]
File:X200.jpg
[[File:X200_chip.jpg]]
File:X200_chip.jpg
[[File:X200_clip.jpg]]
File:X200_clip.jpg
</gallery>
</gallery>


Descriptor and bootblock are read-only. ME firmware is not readable.
The descriptor and ME regions are read-only. ME firmware is not readable.
Rewriteable region can be rewritten easily with flashrom.


For coreboot we need to preserve descriptor and ME firmware while overwriting
All regions are re-writeable with an external SPI flasher, and the descriptor can be modified to unlock these regions (see notes about ich9gen below) for Host CPU / BIOS.
rewriteable region and bootblock. To achieve this there are 2 ways:


* External flasher.
For coreboot we need to preserve at least the descriptor and Gbe regions while overwriting the flash chip contents. To achieve this there are 2 ways:
* Unlock bootblock


For the first one proceeds as follows:
* External flasher (most reliable method known at this time).
* Turn off your laptop, remove battery and AC adapter.
* Unlock bootblock (method unknown at this time)
 
For the first method, proceed as follows:
* Turn off your laptop
* Remove the battery and AC adapter.
* Remove the keyboard.
* Remove the keyboard.
* Connect your external SPI flasher to the SPI chip which is under palmrest,
* Connect your external SPI flasher to the SPI chip which is underneath the palmrest, around the position of the trackpoint under a protective layer.  
around the position of trackpoint under protective layer.  
 
Depending on the flasher that you use, you may need a separate +/- 3.3V DC power source (make sure not to feed any more than this).
phcoder used the buspirate and for 3.3V DC he used an ATX PSU.
 
The pinout is as follows (colours are based on the buspirate):


I recommend using SOIC-16 clip. Depending on the flasher you use, you may have to use separate
3.3V source. Make sure not to feed more than 3.3V ot the chip. I used
buspirate as flasher and 3.3V power lines from ATX PSU.
The pinout is as follows, the colors are buspirate colors
   ===  front (display) ====
   ===  front (display) ====
   NC              -      - MISO (black)
   NC              -      - MISO (black)
Line 78: Line 107:
   NC              -      - NC
   NC              -      - NC
   NC              -      - NC
   NC              -      - NC
   MOSI (gray)    -      - 3.3V (red)
   MOSI (gray)    -      - +3.3V (red)
   violet (SCLK)  -      - NC
   violet (SCLK)  -      - NC
   ===  back (palmrest) ===
   ===  back (palmrest) ===
 
+3.3v (red) must ONLY be connected once the clip is connected, and make sure that the -3.3v is also connected beforehand.
NEVER connect +3.3v (red) prior to the other connections on your flash chip / programmer.


* I wasn't able to eliminate interference in my setup (you may have better luck), so it worked only on 30kHz. Adding battery increased quality somewhat. Read the flash. Twice. Compare the files to be sure. Save a copy of it on
* phcoder wasn't able to eliminate interference in his setup (you may have better luck), so it worked only on 30kHz; adding a battery increased the quality slightly. Read the flash twice, and compare (sha512sum) the files to be sure. Save a copy of the dump onto
external media. Due to interference I reread it 10 times, 2 were corrupted.
external media. Due to interference it had to be read about 10 times, 2 of which were corrupted.
  flashrom -p <yourprogrammer> -r flash.bin
  flashrom -p <yourprogrammer> -r flash.bin
  flashrom -p <yourprogrammer> -r flash2.bin
  flashrom -p <yourprogrammer> -r flash2.bin
  diff flash.bin flash2.bin
  diff flash.bin flash2.bin


An alternative flashing guide (uses BeagleBone Black instead of Bus Pirate for faster, more reliable flashing) can be found at the libreboot website:
[http://libreboot.org/docs/install/x200_external.html Flashing the X200 with a BBB]


See also [http://flashrom.org/ISP In-System Programming]
See also [http://flashrom.org/ISP In-System Programming]


== Flashing your coreboot ROM image ==
You cannot simply build the image and flash it, without first including several other "regions" that are discussed below.
The easiest way to handle the non-coreboot blobs that need to be present on flash is by using flashrom 1.0 or later.
=== With ME firmware updates/AMT ===
With flashrom 1.0 or later you don't need to extract any blob from the vendor image, you can just leave them where they are, which is highly recommended!
First of all make a backup with your external programmer and verify it be a proper image.
<pre>
flashrom -p "external_programmer" -r vendor.rom && flashrom -p "external_programmer" -v vendor.rom
</pre>
After having successfully made a backup of you vendor firmware it is time to flash the coreboot image you build:
<pre>
flashrom -p "external_programmer" -w coreboot.rom --ifd --image bios --noverify-all
</pre>
and done!
To update the coreboot image later on do the following:
<pre>
flashrom -p internal -w coreboot.rom --ifd --image bios
</pre>
=== Without ME firmware updates/AMT ===
On this hardware it is possible to ommit the ME firmware updates while still using the Intel firmware descriptor + GBE region.
This make it possible to use the flash region the ME used for bios region, allowing for much larger payloads (useful for Linux payloads).
This requires the use a modified descriptor and moving things around a bit.
First of all make a backup with your external programmer and verify it be a proper image.
<pre>
flashrom -p "external_programmer" -r vendor.rom && flashrom -p "external_programmer" -v vendor.rom
</pre>
There is a tool to generate a modified flash descriptor: 'blobtool'
go to util/blobtool:
<pre>
make
./blobtool ifd-x200.spec ifd-x200.set ifd.bin
</pre>
if your flash is not 8M modify ifd-x200.set
e.g. 4M
<pre>
diff --git a/util/blobtool/ifd-x200.set b/util/blobtool/ifd-x200.set
index 255eb88b70..25ae281906 100644
--- a/util/blobtool/ifd-x200.set
+++ b/util/blobtool/ifd-x200.set
@@ -35,7 +35,7 @@
        "flmap2_msl" = 0x1,
        "flmap2_reserved" = 0x0,
-      "flcomp_density1" = 0x4,
+      "flcomp_density1" = 0x3,
        "flcomp_density2" = 0x2,
        "flcomp_reserved0" = 0x0,
        "flcomp_reserved1" = 0x0,
@@ -56,7 +56,7 @@
        "flreg0_reserved1" = 0x0,
        "flreg1_base" = 0x3,
        "flreg1_reserved0" = 0x0,
-      "flreg1_limit" = 0x7ff,
+      "flreg1_limit" = 0x3ff,
        "flreg1_reserved1" = 0x0,
        "flreg2_base" = 0x1fff,
        "flreg2_reserved0" = 0x0,
</pre>
or for 16M flash
<pre>
diff --git a/util/blobtool/ifd-x200.set b/util/blobtool/ifd-x200.set
index 255eb88b70..bbcb159616 100644
--- a/util/blobtool/ifd-x200.set
+++ b/util/blobtool/ifd-x200.set
@@ -35,7 +35,7 @@
        "flmap2_msl" = 0x1,
        "flmap2_reserved" = 0x0,
-      "flcomp_density1" = 0x4,
+      "flcomp_density1" = 0x5,
        "flcomp_density2" = 0x2,
        "flcomp_reserved0" = 0x0,
        "flcomp_reserved1" = 0x0,
@@ -56,7 +56,7 @@
        "flreg0_reserved1" = 0x0,
        "flreg1_base" = 0x3,
        "flreg1_reserved0" = 0x0,
-      "flreg1_limit" = 0x7ff,
+      "flreg1_limit" = 0x1fff,
        "flreg1_reserved1" = 0x0,
        "flreg2_base" = 0x1fff,
        "flreg2_reserved0" = 0x0,
</pre>
Now let's start by flashing this descriptor.
It first needs some padding since as of writing flashrom still needs image that match the whole flash size even if only a
region is flashed.
modify '8' in the command to create your flash by your flash size in MB.
<pre>
dd if=/dev/zero of=padding.bin bs=$((8 * 1024 * 1024 - 4096)) count=1
cat ifd.bin padding.bin > ifd_8M.bin
flashrom -p "external_programmer" -w ifd_8M.bin --ifd --image fd --noverify-all
</pre>
Given that the GBE region is a different offset compared to vendor, we need to move it around too.
First extract it from the vendor image:
<pre>
ifdtool vendor.rom -x
</pre>
Now inject the GBE region into the previously created ifd_8M.bin and flash it to the SPI flash.
<pre>
ifdtool -i GBE:flashregion_3_gbe.bin ifd_8M.bin
flashrom -p "external_programmer" -w ifd_8M.bin.new --ifd --image gbe --noverify-all
</pre>
Now finally we can flash our coreboot image. Notice that when building coreboot CONFIG_CBFS_SIZE can now
be safely set to 0x7fd000 (8 * 1024 * 1024 - 4096 - 8192) for 8M flash to make a maximal use of the available flash:
<pre>
flashrom -p "external_programmer" -w coreboot.rom --ifd --image bios --noverify-all
</pre>
On future coreboot updates (no need for external programmer now) simply never touch the other regions again:
<pre>
flashrom -p internal -w coreboot.rom --ifd --image bios
</pre>
== Internal flashing ==
Once coreboot is installed and running, internal flashing should be easier.
Either generate a layout using ifdtool to only flash the bios region, or use flashrom 1.0 or later to read the layout from the Firmware Descriptor on flash.
Flashrom 1.0 or newer:
<pre>
flashrom -p internal -w coreboot.rom --ifd -i bios
</pre>
On older flashrom:
<pre>
flashrom -p internal -r old_coreboot.rom
ifdtool old_coreboot.rom -f layout
flashrom -p internal -w coreboot.rom -l layout -i bios
</pre>
=== Other flashrom patches (optional) ===
Most X200 laptops use one of the Macronix flash chips. Those chips will be detected several times, forcing you to use the -c parameter for selecting a flash chip.
One easy and permanent way to avoid this is to remove those definitions that are redundant to you (this method is inappropriate for upstream).
Apply the following patch to flashchips.c: [http://paste.debian.net/141086/ for purging redundant flash chip definitions]
== Thermal throttling adjustment ==
To adjust threshold of thermal throttling on x200 change critical temperatures of individual ThermalZones inside <code>src/ec/lenovo/h8/acpi/thermal.asl</code>.
C2K function stands for Celsius to Kelvin
== Get version of EC firmware ==
To get firmware version of EC running on x200 running coreboot run
<code>grep 'at EC' /proc/asound/cards</code>
Sample output:
<code>ThinkPad Console Audio Control at EC reg 0x30, fw 7WHT19WW-3.6</code>
7WHT19WW corresponds to 1.06 running on x200t, which can be found out by just searching 7WHT19WW in search engine of choice
== Increase amount of preallocated ram for integrated graphics ==
The default amount of vram is set to 32MB. Some applications using the integrated graphic device can perform a lot better if this increased.
This is often the case for games and video decoding using VAAPI.
In order to change CMOS defaults, you will need '''nvramtool''':
<syntaxhighlight lang="bash" inline>cd util/nvramtool/
make
mv nvramtool ../../nvramtool
cd ../../
</syntaxhighlight>
The VGA shared RAM can be increased to 128MB, 256MB or 352MB by running as root:
<syntaxhighlight lang="bash" inline>./nvramtool -w gfx_uma_size=128M</syntaxhighlight>
or
<syntaxhighlight lang="bash" inline>./nvramtool -w gfx_uma_size=256M</syntaxhighlight>
or
<syntaxhighlight lang="bash" inline>./nvramtool -w gfx_uma_size=352M</syntaxhighlight>
If you want this to be the default (fallback value if nvram is invalid) on your device:
<syntaxhighlight lang="bash" inline>./nvramtool -C build/coreboot.rom -w gfx_uma_size=128M</syntaxhighlight>
and flash that build/coreboot.rom
== Tips and trick (not necessarily coreboot related) ==
=== Recalibrate batteries ===
The EC (embedded controller) has the possibility to recalibrate batteries, the primary battery inside the laptop. To achieve this, plug the computer to AC and do the following to have the EC fully empty the battery:
First of all build ectool in util/ectool. If you want to calibrate the primary battery, run:
<syntaxhighlight lang="bash" inline>./ectool -w 0x23 -z 0x07</syntaxhighlight>
For the secondary battery (not present on this device, only on x301, t400, t500) execute:
<syntaxhighlight lang="bash" inline>./ectool -w 0x23 -z 0x08</syntaxhighlight>
Now wait a few hours while the battery fully discharges and charges back up.
[https://ticket.coreboot.org/issues/156 This could also be implemented in ACPI such that this can be achieved with the tpacpi-bat tools.]
=== Sensors mapping ===
{| class="wikitable"
!|sensor||X200||X200s||X200t
|-
|temp1
|colspan="3" style="text-align: center;" | CPU die
|-
|temp2
|colspan="3" style="text-align: center;" | Between mPCIe sockets
|-
|temp4
|colspan="3" style="text-align: center;" | CPU buck converter
|-
|temp5
|colspan="3" style="text-align: center;" | Battery¹
|-
|temp7
|colspan="3" style="text-align: center;" | Battery¹
|-
|temp9 ||SO-DIMM (other side of board)||?||ExpressCard
|-
|temp10² ||ExpressCard||?||SO-DIMM (other side of board)
|}
¹ Each battery seems to have different mapping on those. On X200T with 8 cell battery it seems to correspond to two 3-pin sensors on FETs, but 4 cell batteries only have one such sensor/fuse.
² On-die temperature sensor of MAX6694


* Recover descriptor and me firmare:
== Research ==
  dd if=flash.bin of=coreboot/3rdparty/mainboard/lenovo/x200/descriptor.bin \
* [[Board:lenovo/x200/internal_flashing_research| Research to get more details on the BIOS updates mecanism]]
    count=12288 bs=1M iflag=count_bytes
  dd if=flash.bin of=coreboot/3rdparty/mainboard/lenovo/x200/me.bin \
    skip=12288 count=6279168 bs=1M iflag=count_bytes,skip_bytes
* Compile coreboot
* Flash the resulting build/coreboot.rom. If it fails due to interference, try again, and again. It took me ~10 times.

Latest revision as of 15:31, 29 May 2018

Status

Thanks for your interest in Lenovo X200 port. Works:

  • USB
  • USB Debug (on the right port near the ThinkPad Logo)
  • Audio (internal speakers, internal mic, headphones, external mic)
  • WLAN (first minipcie slot)
  • WWAN (second minipcie slot)
  • UWB (third minipcie slot)
  • SD card slot
  • LAN
  • Battery and AC indicator
  • Thermal
  • EEPROM
  • Linux (through GRUB-as-payload)
  • trackpoint
  • keyboard
  • Bluetooth
  • LID
  • Video (internal panel and VGA)
  • Hotkeys
  • Fingerprint reader.
  • Windows (through GRUB-as-payload loading SeaBIOS image from disk; you have to use extracted VGA blob, dumped from memory isn't good enough)
  • suspend to RAM (S3)
  • Expresscard slot (including hotplug)
  • Wake on LID, wake on Fn.
  • Dock
  • Digitizer on x200t variant
  • Modem

X200S and X200 Tablet

Both the X200S and X200 Tablet use a WSON-8 package for the flash chip. This has the same pinout as a SOIC-8 flash chip, but you will need to solder some (very thin) wires to a pin header since no clips are available for this type of connection.

Location on motherboard Here is an example

Regular X200 laptops will use either a SOIC-8 or SOIC-16 connection (recommended for average users, who most likely do not want to solder).

Proprietary components status

  • CPU microcode (optional) <see note 1>
  • VGA option rom (optional) => You need it if you want graphics in SeaBIOS but most payloads should work without it (text mode <see note 2> or corebootfb mode)
  • ME (Management Engine) (optional) => Can be removed by using a modified flash descriptor (see notes below about the ich9gen utility)
  • EC (Embedded Controller) => You do not have to touch it (just leave it where it is)

note 1:

VT-x (hardware-assisted virtualization) stops working without microcode updates. The laptop will randomly and sporadically crash without microcode updates. The conditions under which these crashes occur at currently not known.

Dumping the original firmware

First flashing needs to be external. phcoder used the buspirate and a pomona 5252 clip (SOIC-16). For SOIC-8 flash chips, you can use the Pomona 5250.

Unless modified (through the descriptor), the X200 flash as shipped by Lenovo is divided in 5 parts.

For systems with the 8MiB flash chip:

  • Descriptor (4K) - first region
  • ME (also includes AMT) (6100K) - 2nd region
  • Gbe (8K) - 3rd region
  • Platform (32K) - 4th region
  • BIOS (2M) - 5th region

For systems with the 4MiB flash chip:

  • Descriptor (4K) - first region
  • ME (no AMT) (2004K) - 2nd region
  • Gbe (8K) - 3rd region
  • Platform (32K) - 4th region
  • BIOS (2M) - 5th region

Flash chip sizes can be identified through flashrom. Generally, the following is true:

  • SOIC-8 = 4MiB (rare on these machines)
  • SOIC-16 = 8MiB (common on these machines)

The descriptor and ME regions are read-only. ME firmware is not readable.

All regions are re-writeable with an external SPI flasher, and the descriptor can be modified to unlock these regions (see notes about ich9gen below) for Host CPU / BIOS.

For coreboot we need to preserve at least the descriptor and Gbe regions while overwriting the flash chip contents. To achieve this there are 2 ways:

  • External flasher (most reliable method known at this time).
  • Unlock bootblock (method unknown at this time)

For the first method, proceed as follows:

  • Turn off your laptop
  • Remove the battery and AC adapter.
  • Remove the keyboard.
  • Connect your external SPI flasher to the SPI chip which is underneath the palmrest, around the position of the trackpoint under a protective layer.

Depending on the flasher that you use, you may need a separate +/- 3.3V DC power source (make sure not to feed any more than this). phcoder used the buspirate and for 3.3V DC he used an ATX PSU.

The pinout is as follows (colours are based on the buspirate):

 ===  front (display) ====
 NC              -       - MISO (black)
 ground (brown)  -       - CS (white)
 NC              -       - NC
 NC              -       - NC
 NC              -       - NC
 NC              -       - NC
 MOSI (gray)     -       - +3.3V (red)
 violet (SCLK)   -       - NC
 ===  back (palmrest) ===
 

+3.3v (red) must ONLY be connected once the clip is connected, and make sure that the -3.3v is also connected beforehand.

NEVER connect +3.3v (red) prior to the other connections on your flash chip / programmer.

  • phcoder wasn't able to eliminate interference in his setup (you may have better luck), so it worked only on 30kHz; adding a battery increased the quality slightly. Read the flash twice, and compare (sha512sum) the files to be sure. Save a copy of the dump onto

external media. Due to interference it had to be read about 10 times, 2 of which were corrupted.

flashrom -p <yourprogrammer> -r flash.bin
flashrom -p <yourprogrammer> -r flash2.bin
diff flash.bin flash2.bin

An alternative flashing guide (uses BeagleBone Black instead of Bus Pirate for faster, more reliable flashing) can be found at the libreboot website: Flashing the X200 with a BBB

See also In-System Programming

Flashing your coreboot ROM image

You cannot simply build the image and flash it, without first including several other "regions" that are discussed below.

The easiest way to handle the non-coreboot blobs that need to be present on flash is by using flashrom 1.0 or later.

With ME firmware updates/AMT

With flashrom 1.0 or later you don't need to extract any blob from the vendor image, you can just leave them where they are, which is highly recommended!

First of all make a backup with your external programmer and verify it be a proper image.

flashrom -p "external_programmer" -r vendor.rom && flashrom -p "external_programmer" -v vendor.rom

After having successfully made a backup of you vendor firmware it is time to flash the coreboot image you build:

flashrom -p "external_programmer" -w coreboot.rom --ifd --image bios --noverify-all

and done!

To update the coreboot image later on do the following:

flashrom -p internal -w coreboot.rom --ifd --image bios

Without ME firmware updates/AMT

On this hardware it is possible to ommit the ME firmware updates while still using the Intel firmware descriptor + GBE region. This make it possible to use the flash region the ME used for bios region, allowing for much larger payloads (useful for Linux payloads). This requires the use a modified descriptor and moving things around a bit.

First of all make a backup with your external programmer and verify it be a proper image.

flashrom -p "external_programmer" -r vendor.rom && flashrom -p "external_programmer" -v vendor.rom

There is a tool to generate a modified flash descriptor: 'blobtool' go to util/blobtool:

make
./blobtool ifd-x200.spec ifd-x200.set ifd.bin

if your flash is not 8M modify ifd-x200.set e.g. 4M

diff --git a/util/blobtool/ifd-x200.set b/util/blobtool/ifd-x200.set
index 255eb88b70..25ae281906 100644
--- a/util/blobtool/ifd-x200.set
+++ b/util/blobtool/ifd-x200.set
@@ -35,7 +35,7 @@
        "flmap2_msl" = 0x1,
        "flmap2_reserved" = 0x0,
 
-       "flcomp_density1" = 0x4,
+       "flcomp_density1" = 0x3,
        "flcomp_density2" = 0x2,
        "flcomp_reserved0" = 0x0,
        "flcomp_reserved1" = 0x0,
@@ -56,7 +56,7 @@
        "flreg0_reserved1" = 0x0,
        "flreg1_base" = 0x3,
        "flreg1_reserved0" = 0x0,
-       "flreg1_limit" = 0x7ff,
+       "flreg1_limit" = 0x3ff,
        "flreg1_reserved1" = 0x0,
        "flreg2_base" = 0x1fff,
        "flreg2_reserved0" = 0x0,

or for 16M flash

diff --git a/util/blobtool/ifd-x200.set b/util/blobtool/ifd-x200.set
index 255eb88b70..bbcb159616 100644
--- a/util/blobtool/ifd-x200.set
+++ b/util/blobtool/ifd-x200.set
@@ -35,7 +35,7 @@
        "flmap2_msl" = 0x1,
        "flmap2_reserved" = 0x0,
 
-       "flcomp_density1" = 0x4,
+       "flcomp_density1" = 0x5,
        "flcomp_density2" = 0x2,
        "flcomp_reserved0" = 0x0,
        "flcomp_reserved1" = 0x0,
@@ -56,7 +56,7 @@
        "flreg0_reserved1" = 0x0,
        "flreg1_base" = 0x3,
        "flreg1_reserved0" = 0x0,
-       "flreg1_limit" = 0x7ff,
+       "flreg1_limit" = 0x1fff,
        "flreg1_reserved1" = 0x0,
        "flreg2_base" = 0x1fff,
        "flreg2_reserved0" = 0x0,

Now let's start by flashing this descriptor. It first needs some padding since as of writing flashrom still needs image that match the whole flash size even if only a region is flashed.

modify '8' in the command to create your flash by your flash size in MB.

dd if=/dev/zero of=padding.bin bs=$((8 * 1024 * 1024 - 4096)) count=1
cat ifd.bin padding.bin > ifd_8M.bin
flashrom -p "external_programmer" -w ifd_8M.bin --ifd --image fd --noverify-all

Given that the GBE region is a different offset compared to vendor, we need to move it around too. First extract it from the vendor image:

ifdtool vendor.rom -x

Now inject the GBE region into the previously created ifd_8M.bin and flash it to the SPI flash.

ifdtool -i GBE:flashregion_3_gbe.bin ifd_8M.bin
flashrom -p "external_programmer" -w ifd_8M.bin.new --ifd --image gbe --noverify-all

Now finally we can flash our coreboot image. Notice that when building coreboot CONFIG_CBFS_SIZE can now be safely set to 0x7fd000 (8 * 1024 * 1024 - 4096 - 8192) for 8M flash to make a maximal use of the available flash:

flashrom -p "external_programmer" -w coreboot.rom --ifd --image bios --noverify-all

On future coreboot updates (no need for external programmer now) simply never touch the other regions again:

flashrom -p internal -w coreboot.rom --ifd --image bios

Internal flashing

Once coreboot is installed and running, internal flashing should be easier.

Either generate a layout using ifdtool to only flash the bios region, or use flashrom 1.0 or later to read the layout from the Firmware Descriptor on flash.

Flashrom 1.0 or newer:

flashrom -p internal -w coreboot.rom --ifd -i bios

On older flashrom:

flashrom -p internal -r old_coreboot.rom
ifdtool old_coreboot.rom -f layout
flashrom -p internal -w coreboot.rom -l layout -i bios


Other flashrom patches (optional)

Most X200 laptops use one of the Macronix flash chips. Those chips will be detected several times, forcing you to use the -c parameter for selecting a flash chip.

One easy and permanent way to avoid this is to remove those definitions that are redundant to you (this method is inappropriate for upstream).

Apply the following patch to flashchips.c: for purging redundant flash chip definitions

Thermal throttling adjustment

To adjust threshold of thermal throttling on x200 change critical temperatures of individual ThermalZones inside src/ec/lenovo/h8/acpi/thermal.asl.

C2K function stands for Celsius to Kelvin

Get version of EC firmware

To get firmware version of EC running on x200 running coreboot run

grep 'at EC' /proc/asound/cards

Sample output:

ThinkPad Console Audio Control at EC reg 0x30, fw 7WHT19WW-3.6

7WHT19WW corresponds to 1.06 running on x200t, which can be found out by just searching 7WHT19WW in search engine of choice

Increase amount of preallocated ram for integrated graphics

The default amount of vram is set to 32MB. Some applications using the integrated graphic device can perform a lot better if this increased. This is often the case for games and video decoding using VAAPI.

In order to change CMOS defaults, you will need nvramtool: <syntaxhighlight lang="bash" inline>cd util/nvramtool/ make mv nvramtool ../../nvramtool cd ../../ </syntaxhighlight>

The VGA shared RAM can be increased to 128MB, 256MB or 352MB by running as root:

<syntaxhighlight lang="bash" inline>./nvramtool -w gfx_uma_size=128M</syntaxhighlight> or <syntaxhighlight lang="bash" inline>./nvramtool -w gfx_uma_size=256M</syntaxhighlight> or <syntaxhighlight lang="bash" inline>./nvramtool -w gfx_uma_size=352M</syntaxhighlight>

If you want this to be the default (fallback value if nvram is invalid) on your device: <syntaxhighlight lang="bash" inline>./nvramtool -C build/coreboot.rom -w gfx_uma_size=128M</syntaxhighlight> and flash that build/coreboot.rom

Tips and trick (not necessarily coreboot related)

Recalibrate batteries

The EC (embedded controller) has the possibility to recalibrate batteries, the primary battery inside the laptop. To achieve this, plug the computer to AC and do the following to have the EC fully empty the battery: First of all build ectool in util/ectool. If you want to calibrate the primary battery, run: <syntaxhighlight lang="bash" inline>./ectool -w 0x23 -z 0x07</syntaxhighlight> For the secondary battery (not present on this device, only on x301, t400, t500) execute: <syntaxhighlight lang="bash" inline>./ectool -w 0x23 -z 0x08</syntaxhighlight> Now wait a few hours while the battery fully discharges and charges back up.

This could also be implemented in ACPI such that this can be achieved with the tpacpi-bat tools.

Sensors mapping

sensor X200 X200s X200t
temp1 CPU die
temp2 Between mPCIe sockets
temp4 CPU buck converter
temp5 Battery¹
temp7 Battery¹
temp9 SO-DIMM (other side of board) ? ExpressCard
temp10² ExpressCard ? SO-DIMM (other side of board)

¹ Each battery seems to have different mapping on those. On X200T with 8 cell battery it seems to correspond to two 3-pin sensors on FETs, but 4 cell batteries only have one such sensor/fuse.

² On-die temperature sensor of MAX6694

Research