You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
14 KiB

6 years ago
  1. # Skulls - [Thinkpad X230](https://pcsupport.lenovo.com/en/products/laptops-and-netbooks/thinkpad-x-series-laptops/thinkpad-x230) and X230T
  2. ![seabios_bootmenu](front.jpg)
  3. ## Latest release
  4. Get it from our [release page](https://github.com/merge/coreboot-x230/releases)
  5. * __coreboot__: We take coreboot's master branch at the time we build a release image.
  6. * __microcode update__: revision `20` from 2018-04-10 (includes mitigations for Spectre Variant 3a and 4)
  7. * __SeaBIOS__: version [1.12.0](https://seabios.org/Releases) from 2018-11-17
  8. ## Table of contents
  9. * [TL;DR](#tldr)
  10. * [First-time installation](#first-time-installation)
  11. * [Updating](#updating)
  12. * [Moving to Heads](#moving-to-heads)
  13. * [Why does this work](#why-does-this-work)
  14. * [How to rebuild](#how-to-reproduce-the-release-images)
  15. ## TL;DR
  16. 1. If your Thinkpad is already running linux: run `sudo ./x230_before_first_install.sh` on it
  17. 2. Power down, remove the battery. Remove the keyboard and palmrest.
  18. 3. Connect a hardware flasher to an external PC (or a Raspberry Pi with a SPI 8-pin chip clip
  19. can directly be used)
  20. 4. Run `sudo ./external_install_bottom.sh` on the lower chip
  21. 5. Run `sudo ./external_install_top.sh` on the top chip of the two
  22. 6. Optionally: For updating later, run `./x230_skulls.sh`. No need to disassemble.
  23. And always use the latest [released](https://github.com/merge/coreboot-x230/releases)
  24. package. This will be tested. The git master branch is _not_ meant to be stable. Use it for testing only.
  25. ## First-time installation
  26. ### If you are still on Windows and Lenovo BIOS
  27. Before flashing coreboot, consider doing one original Lenovo upgrade process
  28. in case you're not running the latest version. This is not supported anymore,
  29. once you're running coreboot (You'd have to manually flash back your backup
  30. images first, see later chapters).
  31. Check the [Lenovo Support site (which is quite good and actually helpful)](https://pcsupport.lenovo.com/de/en/products/laptops-and-netbooks/thinkpad-x-series-laptops/thinkpad-x230) and e.g. run the _Lenovo System Update for Windows_ to check for old BIOS, EC- or battery-firmware or other updateable firmwar.
  32. Also, this updates the BIOS (latest 2.74) _and_ Embedded Controller (EC) firmware. The EC
  33. is not updated anymore, when running coreboot. The latest EC version is 1.14
  34. and that's unlikely to change.
  35. In case you're not running the latest BIOS version, either
  36. * use [the latest original CD](https://support.lenovo.com/at/en/downloads/ds029188) and burn it, or
  37. * use the same, only with a patched EC firmware that allows using any aftermarket-battery:
  38. By default, only original Lenovo batteries are allowed.
  39. Thanks to [this](http://zmatt.net/unlocking-my-lenovo-laptop-part-3/)
  40. [project](https://github.com/eigenmatt/mec-tools) we can use Lenovo's bootable
  41. upgrade image, change it and create a bootable _USB_ image, with an EC update
  42. that allows us to use any 3rd party aftermarket battery:
  43. sudo apt-get install build-essential git mtools libssl-dev
  44. git clone https://github.com/hamishcoleman/thinkpad-ec && cd thinkpad-ec
  45. make patch_disable_keyboard clean
  46. make patch_enable_battery clean
  47. make patched.x230.img
  48. That's it. You can create a bootable USB stick: `sudo dd if=patched.x230.img of=/dev/sdx`
  49. and boot from it. Alternatively, burn `patched.x230.iso` to a CD. And make sure
  50. you have "legacy" boot set, not "UEFI" boot.
  51. ### Optionally: If your Thinkpad is on Linux already
  52. Before starting, run Linux on your X230, install `dmidecode` and run
  53. `sudo ./x230_before_first_install.sh`. It simply prints system information and
  54. helps you to be up to date.
  55. Also make sure you have the latest skulls-x230 package release by running `./upgrade.sh`.
  56. ### Preparation: required hardware
  57. * An 8 Pin SOIC Clip, for example from
  58. [Pomona electronics](https://www.pomonaelectronics.com/products/test-clips/soic-clip-8-pin)
  59. (for availability, check
  60. [aliexpress](https://de.aliexpress.com/item/POMONA-SOIC-CLIP-5250-8pin-eeprom-for-tacho-8pin-cable-for-pomana-soic-8pin/32814247676.html) or
  61. [elsewhere](https://geizhals.eu/?fs=pomona+test+clip+5250))
  62. or alternatively hooks like
  63. [E-Z-Hook](http://catalog.e-z-hook.com/viewitems/test-hooks/e-z-micro-hooks-single-hook-style)
  64. * 6 [female](https://electronics.stackexchange.com/questions/37783/how-can-i-create-a-female-jumper-wire-connector)
  65. [jumper wires](https://en.wikipedia.org/wiki/Jump_wire) like
  66. [these](https://geizhals.eu/jumper-cable-female-female-20cm-a1471094.html)
  67. to connect the clip to a hardware flasher (if not included with the clip)
  68. * a hardware flasher
  69. [supported by flashrom](https://www.flashrom.org/Flashrom/0.9.9/Supported_Hardware#USB_Devices), see below for the examples we support
  70. There are plenty of cheap chinese SOIC-clips, their build-quality often is reported to be problematic. Consider getting one of the above mentioned brand clips.
  71. ### Open up the X230
  72. Remove the 7 screws of your X230 to remove the keyboard (by pushing it towards the
  73. screen before lifting) and the palmrest. You'll find the chips using the photo
  74. below. This is how the SPI connection looks like on both of the X230's chips:
  75. Screen (furthest from you)
  76. ______
  77. MOSI 5 --| |-- 4 GND
  78. CLK 6 --| |-- 3 N/C
  79. N/C 7 --| |-- 2 MISO
  80. VCC 8 --|______|-- 1 CS
  81. Edge (closest to you)
  82. N/C = nothin connected
  83. ... choose __one of the following__ supported flashing hardware examples:
  84. ### Option 1: Raspberry Pi 3
  85. A Raspberry Pi can directly be a flasher through it's I/O pins, see below.
  86. Use a test clip or hooks, see [required hardware](#preparation-required-hardware).
  87. On the RPi we run [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
  88. and have the following setup:
  89. * Connect to the console: Either
  90. * connect a screen and a keyboard, or
  91. * Use the [Serial connection](https://elinux.org/RPi_Serial_Connection) using a
  92. USB-to-serial cable (like [Adafruit 954](http://www.adafruit.com/products/954),
  93. [FTDI TTL-232R-RPI](http://www.ftdichip.com/Products/Cables/RPi.htm) or
  94. [others](https://geizhals.eu/usb-to-ttl-serial-adapter-cable-a1461312.html)) and
  95. picocom (`picocom -b 115200 /dev/ttyUSB0`) or minicom
  96. * in the SD Cards's `/boot/config.txt` file `enable_uart=1` and `dtparam=spi=on`
  97. * [For flashrom](https://www.flashrom.org/RaspberryPi) we put `spi_bcm2835`
  98. and `spidev` in /etc/modules
  99. * [Connect to a wifi](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)
  100. or ethernet to `sudo apt-get install flashrom`
  101. * connect the Clip to the Raspberry Pi 3 (there are
  102. [prettier images](https://github.com/splitbrain/rpibplusleaf) too):
  103. Edge of pi (furthest from you)
  104. (UART)
  105. L GND CS
  106. E | |
  107. F +---------------------------------------------------------------------------------+
  108. T | x x x x x x x x x x x x x x x x x x x x |
  109. | x x x x x x x x x x x x x x x x x x x x |
  110. E +----------------------------------^---^---^---^-------------------------------^--+
  111. D | | | |
  112. G 3.3V MOSIMISO|
  113. E (VCC) CLK
  114. Body of Pi (closest to you)
  115. ![Raspberry Pi at work](rpi_clip.jpg)
  116. Now copy the Skulls release tarball over to the Rasperry Pi and
  117. [continue](#unpack-the-skulls-release-archive) on the Pi.
  118. ### Option 2: CH341A based
  119. The CH341A from [Winchiphead](http://www.wch.cn/), a USB interface chip,
  120. is used by some cheap memory programmers.
  121. The one we describe can be bought at
  122. [aliexpress](http://www.aliexpress.com/item/Free-Shipping-CH341A-24-25-Series-EEPROM-Flash-BIOS-DVD-USB-Programmer-DVD-programmer-router-Nine/32583059603.html),
  123. but it's available [elsewhere](https://geizhals.eu/?fs=ch341a) too.
  124. Also, we don't use the included 3,3V power output (provides too little power),
  125. but a separate power supply. If you don't have any, consider getting a AMS1117
  126. based supply for a second USB port (like [this](https://de.aliexpress.com/item/1PCS-AMS1117-3-3V-Mini-USB-5V-3-3V-DC-Perfect-Power-Supply-Module/32785334595.html) or [this](https://www.ebay.com/sch/i.html?_nkw=ams1117+usb)).
  127. * Leave the P/S Jumper connected (programmer mode, 1a86:5512 USB device)
  128. * Connect 3,3V from your external supply to the Pomona clip's (or hook) VCC
  129. * Connect GND from your external supply to GND on your CH341A programmer
  130. * Connect your clip or hooks to the rest of the programmer's SPI pins
  131. * Connect the programmer (and power supply, if USB) to your PC's USB port
  132. ![ch341a programmer with extra USB power supply](ch341a.jpg)
  133. ### Side note
  134. Connecting an ethernet cable as a power-source for SPI (instead of the VCC pin)
  135. is not necessary (some other flashing how-to guides mention this).
  136. Setting a fixed (and low) SPI speed for flashrom offeres the same stability.
  137. Our scripts do this for you.
  138. I checked around on excactly when and how one should connect the clip. There has been no clear advice, it seemed to be safest to first connect all cables between the flashing device and the clip, and once correctly configured, connect the clip to the chip.
  139. ## Get and unpack the Skulls release archive
  140. After choosing one flasher-option [download](https://github.com/merge/skulls/releases) the latest release and untar it:
  141. tar -xf skulls-x230-<version>.tar.xz
  142. cd skulls-x230-<version>
  143. Make sure to verify the checksum with e.g.:
  144. sha256sum skulls-x230-0.1.0.tar.xz anc compare this to the [checksum](https://github.com/merge/skulls/releases/download/0.1.0/skulls-x230-0.1.0.tar.xz.sha256)
  145. ### Side note
  146. Flashing with these low speeds takes time. Be patient. E.g. unlocking the bottom chip with its two reads, one write and one verify step usually takes one hour in total. Again, be patient!
  147. ## First, optional step: Connect to the bottom chip
  148. There are a few reasons why you may start with connecting your clip to the bottom (at the bottom, closer to you) chip (it has the same pinout than the upper chip):
  149. - You may want to enable in system updates in the future. The advantage is that you can update and change whatever you decide to flash in the upper chip. The disadvantage is that any software can flash you BIOS with this setting. Choose wisely (Heads - see below - may be of use here).
  150. - You may want to neuter the [Intel Management Engine](https://en.wikipedia.org/wiki/Intel_Management_Engine) for
  151. [security reasons](https://en.wikipedia.org/wiki/Intel_Management_Engine#Security_vulnerabilities)
  152. - You simply may want to backup the firmware in this chip.
  153. If you don't want to any of this skip to the upper chip. Else choose the correct command line options here
  154. sudo ./external_install_bottom.sh -m -k <backup-file-to-create>
  155. * The `-m` option above also runs `me_cleaner -S` before flashing back, see [me_cleaner](https://github.com/corna/me_cleaner).
  156. * The `-l` option will (re-)lock your flash ROM, in case you want to force
  157. yourself (and others) to hardware-flashing. Unlocking is standard if you don't specify this.
  158. * The `-k` creates a backup-file if two reads succeeded and produced the same checksum.
  159. #### Second, the main step: "Butter bei die Fische"
  160. The upper- or top-chip (the one nearer to the display) houses the BIOS to be replaced. If you are finished with the bottom-chip (or you decided no to touch it) connect the clip in the same configuration to the top-chip. Then run:
  161. sudo ./external_install_top.sh -k <backup-file-to-create>
  162. Select the image to flash and that's it. The image named "free" includes
  163. [SeaVGABIOS](https://www.seabios.org/SeaVGABIOS) instead of
  164. [Intel's VGA Bios](https://www.intel.com/content/www/us/en/intelligent-systems/intel-embedded-graphics-drivers/faq-bios-firmware.html).
  165. Keep the backup safe, assemble and turn on the X230. coreboot will do hardware init and start SeaBIOS.
  166. You are done, everything below is optional. Enjoy your liberated Thinkpad!
  167. ## Updating
  168. Two possibilities:
  169. If you unlocked the bottom chip (see above) then you can flash in place:
  170. That's of course very convenient - just install flashrom from your
  171. Linux distribution - but according to the
  172. [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html)
  173. this is very dangerous:
  174. 1. boot Linux with the `iomem=relaxed` boot parameter (for example in /etc/default/grub `GRUB_CMDLINE_LINUX_DEFAULT`)
  175. 2. [download](https://github.com/merge/skulls/releases) the latest Skulls release tarball and unpack it
  176. 3. run `sudo ./x230_skulls.sh` and choose the image to flash.
  177. If you decided against flashing in place, just repeat the steps for the top-chip:
  178. You can again flash externally, using `external_install_top.sh` just like the
  179. first time, see above.
  180. ## Moving to Heads
  181. [Heads](http://osresearch.net/) is an alternative BIOS system with advanced
  182. security features. It's more complicated to use though. When having Skulls
  183. installed, installing Heads is as easy as updating Skulls. You can directly
  184. start using it:
  185. * [build Heads](https://github.com/osresearch/heads)
  186. * boot Linux with the `iomem=relaxed` boot parameter
  187. * copy Heads' 12M image file `build/x230/coreboot.rom` to Skulls' x230 directory
  188. * run `sudo ./x230_heads.sh`
  189. That's it. Heads is a completely different project. Please read the
  190. [documentation](http://osresearch.net/) for how to use it and report bugs
  191. [over there](https://github.com/osresearch/heads/issues)
  192. Switching back to Skulls is the same as [updating](#updating). Just run
  193. `./x230_skulls.sh`.
  194. ## Why does this work?
  195. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  196. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  197. one holds the rest that you can [modify yourself once](#flashing-for-the-first-time),
  198. if you like, but strictly speaking, you
  199. [don't need to touch it at all](https://www.coreboot.org/Board:lenovo/x230#Building_Firmware).
  200. What's this "rest"?
  201. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.
  202. ## how to reproduce the release images
  203. * `git clone https://github.com/merge/skulls`
  204. * rename one of the included config files to `config-xxxxxxxxxx`.
  205. * The x230 directory's `./build.sh` should produce the exact corresponding release image file.