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.

247 lines
12 KiB

6 years ago
  1. # Skulls - [Thinkpad X230](https://pcsupport.lenovo.com/en/products/laptops-and-netbooks/thinkpad-x-series-laptops/thinkpad-x230).
  2. ![seabios_bootmenu](front.jpg)
  3. ## Latest release
  4. * This directory's `./build.sh` should produce the exact release image file (from a skulls git checkout).
  5. Get it from our [release page](https://github.com/merge/coreboot-x230/releases)
  6. * __coreboot__: We take coreboot's master branch at the time we build a release image.
  7. * __microcode update__: revision `20` from 2018-04-10 (includes mitigations for Spectre Variant 3a and 4)
  8. * __SeaBIOS__: version [1.11.2](https://seabios.org/Releases) from 2018-06-02
  9. * The only proprietary binary, the VGA BIOS is executed in "secure" mode ([PCI_OPTION_ROM_RUN_YABEL](https://www.coreboot.org/Coreboot_Options))
  10. ## table of contents
  11. * [TL;DR](#tldr)
  12. * [First-time installation](#firsttime-installation)
  13. * [Updating](#updating)
  14. * [Moving to Heads](#moving-to-heads)
  15. * [Why does this work](#why-does-this-work)
  16. ## TL;DR
  17. 1. run `sudo ./x230_before_first_install.sh` on your current X230 Linux system
  18. 2. Power down, remove the battery. Remove the keyboard and palmrest. Connect
  19. a hardware flasher to an external PC (or a Raspberry Pi with a SPI 8-pin chip clip
  20. can directly be used), and run
  21. `sudo ./external_install_bottom.sh` on the lower chip
  22. and `sudo ./external_install_top.sh` on the top chip of the two.
  23. 3. For updating later, run `./x230_skulls.sh`. No need to disassemble.
  24. And always use the latest [released](https://github.com/merge/coreboot-x230/releases)
  25. package. This will be tested. The git master
  26. branch is _not_ meant to be stable. Use it for testing only.
  27. ## First-time installation
  28. #### before you begin
  29. Before starting, run Linux on your X230, install `dmidecode` and run
  30. `sudo ./x230_before_first_install.sh`. It simply prints system information and helps
  31. you find out your RAM voltage. Make sure you have RAM that uses
  32. [1,5V, not 1,35V](https://www.coreboot.org/Intel_Native_Raminit#Sandybridge.2FIvybridge).
  33. Also make sure you have the latest skulls-x230 package release by running `./upgrade.sh`.
  34. #### original BIOS update / EC firmware (optional)
  35. Before flashing coreboot, consider doing one original Lenovo upgrade process
  36. in case you're not running the latest version. This is not supported anymore,
  37. once you're running coreboot (You'd have to manually flash back your backup
  38. images first, see later chapters).
  39. Also, this updates the BIOS _and_ Embedded Controller (EC) firmware. The EC
  40. is not updated anymore, when running coreboot. The latest EC version is 1.14
  41. and that's unlikely to change.
  42. In case you're not running the latest BIOS version, either
  43. * use [the latest original CD](https://support.lenovo.com/at/en/downloads/ds029188) and burn it, or
  44. * use the same, only with a patched EC firmware that allows using any aftermarket-battery:
  45. By default, only original Lenovo batteries are allowed.
  46. Thanks to [this](http://zmatt.net/unlocking-my-lenovo-laptop-part-3/)
  47. [project](https://github.com/eigenmatt/mec-tools) we can use Lenovo's bootable
  48. upgrade image, change it and create a bootable _USB_ image, with an EC update
  49. that allows us to use any 3rd party aftermarket battery:
  50. sudo apt-get install build-essential git mtools libssl-dev
  51. git clone https://github.com/hamishcoleman/thinkpad-ec && cd thinkpad-ec
  52. make patch_disable_keyboard clean
  53. make patch_enable_battery clean
  54. make patched.x230.img
  55. That's it. You can create a bootable USB stick: `sudo dd if=patched.x230.img of=/dev/sdx`
  56. and boot from it. Alternatively, burn `patched.x230.iso` to a CD. And make sure
  57. you have "legacy" boot set, not "UEFI" boot.
  58. #### preparation: required hardware
  59. * An 8 Pin SOIC Clip, for example from
  60. [Pomona electronics](https://www.pomonaelectronics.com/products/test-clips/soic-clip-8-pin)
  61. (for availability, check
  62. [aliexpress](https://de.aliexpress.com/item/POMONA-SOIC-CLIP-5250-8pin-eeprom-for-tacho-8pin-cable-for-pomana-soic-8pin/32814247676.html) or
  63. [elsewhere](https://geizhals.eu/?fs=pomona+test+clip+5250))
  64. or alternatively hooks like
  65. [E-Z-Hook](http://catalog.e-z-hook.com/viewitems/test-hooks/e-z-micro-hooks-single-hook-style)
  66. * 6 [female](https://electronics.stackexchange.com/questions/37783/how-can-i-create-a-female-jumper-wire-connector)
  67. [jumper wires](https://en.wikipedia.org/wiki/Jump_wire) like
  68. [these](https://geizhals.eu/jumper-cable-female-female-20cm-a1471094.html)
  69. to connect the clip to a hardware flasher (if not included with the clip)
  70. * a hardware flasher
  71. [supported by flashrom](https://www.flashrom.org/Flashrom/0.9.9/Supported_Hardware#USB_Devices), see below for the examples we support
  72. #### open up the X230
  73. Remove the 7 screws of your X230 to remove the keyboard (by pushing it towards the
  74. screen before lifting) and the palmrest. You'll find the chips using the photo
  75. below. This is how the SPI connection looks like on both of the X230's chips:
  76. Screen (furthest from you)
  77. ______
  78. MOSI 5 --| |-- 4 GND
  79. CLK 6 --| |-- 3 N/C
  80. N/C 7 --| |-- 2 MISO
  81. VCC 8 --|______|-- 1 CS
  82. Edge (closest to you)
  83. ... choose __one of the following__ supported flashing hardware examples:
  84. #### Hardware Example: 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 TX RX 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| GND
  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. #### Hardware Example: 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 seperate 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://geizhals.eu/1415110251)).
  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. #### unpack the Skulls release archive
  134. mkdir skulls
  135. tar -xf skulls-x230-<version>.tar.xz -C skulls
  136. cd skulls
  137. #### ifd unlock and me_cleaner: the 8MB chip
  138. The [Intel Management Engine](https://en.wikipedia.org/wiki/Intel_Management_Engine)
  139. resides on the 8MB chip (at the bottom, closer to you).
  140. We don't need to touch it for coreboot-upgrades in the future, but to
  141. enable internal flashing, we need to unlock it once, and remove the Management
  142. Engine for
  143. [security reasons](https://en.wikipedia.org/wiki/Intel_Management_Engine#Security_vulnerabilities):
  144. sudo ./external_install_bottom.sh -m -k <backup.bin>
  145. That's it. Keep the backup safe.
  146. Background (just so you know):
  147. * The `-m` option above also runs `me_cleaner -S` before flashing back, see [me_cleaner](https://github.com/corna/me_cleaner).
  148. * The `-l` option will (re-)lock your flash ROM, in case you want to force
  149. yourself (and others) to hardware-flashing.
  150. * Connecting an ethernet cable as a power-source for SPI (instead of the VCC pin)
  151. is not necessary (some other flashing how-to guides mention this).
  152. Setting a fixed (and low) SPI speed for flashrom offeres the same stability.
  153. Our scripts do this for you.
  154. #### BIOS: the 4MB chip
  155. sudo ./external_install_top.sh -i <release-image-file>.rom -k <backup>
  156. That's it. Keep the backup safe, assemble and turn on the X230. coreboot will
  157. do hardware init and start SeaBIOS.
  158. ## Updating
  159. Only the "upper" 4MB chip has to be written.
  160. You can again flash externally, using `external_install_top.sh` just like the
  161. first time, see above.
  162. Instead you can run the update directly on your X230
  163. using Linux. That's of course very convenient - just install flashrom from your
  164. Linux distribution - but according to the
  165. [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html)
  166. this is very dangerous:
  167. 1. boot Linux with the `iomem=relaxed` boot parameter (for example in /etc/default/grub `GRUB_CMDLINE_LINUX_DEFAULT`)
  168. 2. [download](https://github.com/merge/skulls/releases) the latest Skulls release tarball and unpack it
  169. 3. run `sudo ./x230_skulls.sh` for generating all necessary files and instructions
  170. ## Moving to Heads
  171. [Heads](http://osresearch.net/) is an alternative BIOS system with advanced
  172. security features. It's more complicated to use though. When having Skulls
  173. installed, installing Heads is as easy as updating Skulls. You can directly
  174. start using it:
  175. * [build Heads](https://github.com/osresearch/heads)
  176. * boot Linux with the `iomem=relaxed` boot parameter
  177. * copy Heads' 12M image file `build/x230/coreboot.rom` to Skulls' x230 directory
  178. * run `sudo ./x230_heads.sh`
  179. That's it. Heads is a completely different project. Please read the
  180. [documentation](http://osresearch.net/) for how to use it and report bugs
  181. [over there](https://github.com/osresearch/heads/issues)
  182. Switching back to Skulls is the same as [updating](#updating). Just run
  183. `./x230_skulls.sh`.
  184. ## Why does this work?
  185. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  186. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  187. one holds the rest that you can [modify yourself once](#flashing-for-the-first-time),
  188. if you like, but strictly speaking, you
  189. [don't need to touch it at all](https://www.coreboot.org/Board:lenovo/x230#Building_Firmware).
  190. What's this "rest"?
  191. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.