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.

275 lines
13 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. ### release images to choose from
  9. We release multiple different, but _very similar_ images you can choose from.
  10. They all should work on all versions of the X230/X230T. These are the
  11. differences; (xxxxxxxxxx stands for random characters in the filename):
  12. * `x230_coreboot_seabios_xxxxxxxxxx_top.rom` includes the _proprietary_
  13. [VGA BIOS](https://en.wikipedia.org/wiki/Video_BIOS) from [Intel](https://www.intel.com/content/www/us/en/intelligent-systems/intel-embedded-graphics-drivers/faq-bios-firmware.html)
  14. which is non-free software. It is executed in "secure" mode.
  15. * `x230_coreboot_seabios_free_xxxxxxxxxx_top.rom` includes the
  16. [VGA BIOS](https://en.wikipedia.org/wiki/Video_BIOS)
  17. [SeaVGABIOS](https://www.seabios.org/SeaVGABIOS) which is free software.
  18. While technically more interesting, visually this is currently not as
  19. beautiful:
  20. * The [bootspash image is not shown](https://github.com/merge/skulls/issues/59).
  21. * Early boot console messages (after your HDD's bootloader has started a kernel) might be [missing](https://github.com/merge/skulls/issues/46).
  22. ## table of contents
  23. * [TL;DR](#tldr)
  24. * [First-time installation](#first-time-installation)
  25. * [Updating](#updating)
  26. * [Moving to Heads](#moving-to-heads)
  27. * [Why does this work](#why-does-this-work)
  28. * [How to rebuild](#how-to-reproduce-the-release-images)
  29. ## TL;DR
  30. 1. run `sudo ./x230_before_first_install.sh` on your current X230 Linux system
  31. 2. Power down, remove the battery. Remove the keyboard and palmrest. Connect
  32. a hardware flasher to an external PC (or a Raspberry Pi with a SPI 8-pin chip clip
  33. can directly be used), and run
  34. `sudo ./external_install_bottom.sh` on the lower chip
  35. and `sudo ./external_install_top.sh` on the top chip of the two.
  36. 3. For updating later, run `./x230_skulls.sh`. No need to disassemble.
  37. And always use the latest [released](https://github.com/merge/coreboot-x230/releases)
  38. package. This will be tested. The git master
  39. branch is _not_ meant to be stable. Use it for testing only.
  40. ## First-time installation
  41. #### before you begin
  42. Before starting, run Linux on your X230, install `dmidecode` and run
  43. `sudo ./x230_before_first_install.sh`. It simply prints system information and
  44. helps you to be up to date.
  45. Also make sure you have the latest skulls-x230 package release by running `./upgrade.sh`.
  46. #### original BIOS update / EC firmware (optional)
  47. Before flashing coreboot, consider doing one original Lenovo upgrade process
  48. in case you're not running the latest version. This is not supported anymore,
  49. once you're running coreboot (You'd have to manually flash back your backup
  50. images first, see later chapters).
  51. Also, this updates the BIOS _and_ Embedded Controller (EC) firmware. The EC
  52. is not updated anymore, when running coreboot. The latest EC version is 1.14
  53. and that's unlikely to change.
  54. In case you're not running the latest BIOS version, either
  55. * use [the latest original CD](https://support.lenovo.com/at/en/downloads/ds029188) and burn it, or
  56. * use the same, only with a patched EC firmware that allows using any aftermarket-battery:
  57. By default, only original Lenovo batteries are allowed.
  58. Thanks to [this](http://zmatt.net/unlocking-my-lenovo-laptop-part-3/)
  59. [project](https://github.com/eigenmatt/mec-tools) we can use Lenovo's bootable
  60. upgrade image, change it and create a bootable _USB_ image, with an EC update
  61. that allows us to use any 3rd party aftermarket battery:
  62. sudo apt-get install build-essential git mtools libssl-dev
  63. git clone https://github.com/hamishcoleman/thinkpad-ec && cd thinkpad-ec
  64. make patch_disable_keyboard clean
  65. make patch_enable_battery clean
  66. make patched.x230.img
  67. That's it. You can create a bootable USB stick: `sudo dd if=patched.x230.img of=/dev/sdx`
  68. and boot from it. Alternatively, burn `patched.x230.iso` to a CD. And make sure
  69. you have "legacy" boot set, not "UEFI" boot.
  70. #### preparation: required hardware
  71. * An 8 Pin SOIC Clip, for example from
  72. [Pomona electronics](https://www.pomonaelectronics.com/products/test-clips/soic-clip-8-pin)
  73. (for availability, check
  74. [aliexpress](https://de.aliexpress.com/item/POMONA-SOIC-CLIP-5250-8pin-eeprom-for-tacho-8pin-cable-for-pomana-soic-8pin/32814247676.html) or
  75. [elsewhere](https://geizhals.eu/?fs=pomona+test+clip+5250))
  76. or alternatively hooks like
  77. [E-Z-Hook](http://catalog.e-z-hook.com/viewitems/test-hooks/e-z-micro-hooks-single-hook-style)
  78. * 6 [female](https://electronics.stackexchange.com/questions/37783/how-can-i-create-a-female-jumper-wire-connector)
  79. [jumper wires](https://en.wikipedia.org/wiki/Jump_wire) like
  80. [these](https://geizhals.eu/jumper-cable-female-female-20cm-a1471094.html)
  81. to connect the clip to a hardware flasher (if not included with the clip)
  82. * a hardware flasher
  83. [supported by flashrom](https://www.flashrom.org/Flashrom/0.9.9/Supported_Hardware#USB_Devices), see below for the examples we support
  84. #### open up the X230
  85. Remove the 7 screws of your X230 to remove the keyboard (by pushing it towards the
  86. screen before lifting) and the palmrest. You'll find the chips using the photo
  87. below. This is how the SPI connection looks like on both of the X230's chips:
  88. Screen (furthest from you)
  89. ______
  90. MOSI 5 --| |-- 4 GND
  91. CLK 6 --| |-- 3 N/C
  92. N/C 7 --| |-- 2 MISO
  93. VCC 8 --|______|-- 1 CS
  94. Edge (closest to you)
  95. ... choose __one of the following__ supported flashing hardware examples:
  96. #### Hardware Example: Raspberry Pi 3
  97. A Raspberry Pi can directly be a flasher through it's I/O pins, see below.
  98. Use a test clip or hooks, see [required hardware](#preparation-required-hardware).
  99. On the RPi we run [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
  100. and have the following setup:
  101. * Connect to the console: Either
  102. * connect a screen and a keyboard, or
  103. * Use the [Serial connection](https://elinux.org/RPi_Serial_Connection) using a
  104. USB-to-serial cable (like [Adafruit 954](http://www.adafruit.com/products/954),
  105. [FTDI TTL-232R-RPI](http://www.ftdichip.com/Products/Cables/RPi.htm) or
  106. [others](https://geizhals.eu/usb-to-ttl-serial-adapter-cable-a1461312.html)) and
  107. picocom (`picocom -b 115200 /dev/ttyUSB0`) or minicom
  108. * in the SD Cards's `/boot/config.txt` file `enable_uart=1` and `dtparam=spi=on`
  109. * [For flashrom](https://www.flashrom.org/RaspberryPi) we put `spi_bcm2835`
  110. and `spidev` in /etc/modules
  111. * [Connect to a wifi](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)
  112. or ethernet to `sudo apt-get install flashrom`
  113. * connect the Clip to the Raspberry Pi 3 (there are
  114. [prettier images](https://github.com/splitbrain/rpibplusleaf) too):
  115. Edge of pi (furthest from you)
  116. (UART)
  117. L GND TX RX CS
  118. E | | | |
  119. F +---------------------------------------------------------------------------------+
  120. T | x x x x x x x x x x x x x x x x x x x x |
  121. | x x x x x x x x x x x x x x x x x x x x |
  122. E +----------------------------------^---^---^---^-------------------------------^--+
  123. D | | | | |
  124. G 3.3V MOSIMISO| GND
  125. E (VCC) CLK
  126. Body of Pi (closest to you)
  127. ![Raspberry Pi at work](rpi_clip.jpg)
  128. Now copy the Skulls release tarball over to the Rasperry Pi and
  129. [continue](#unpack-the-skulls-release-archive) on the Pi.
  130. We flash at low speeds. Unlocking the bottom chip with its two reads, one write and one verify step usually takes approximately one hour in total.
  131. #### Hardware Example: CH341A based
  132. The CH341A from [Winchiphead](http://www.wch.cn/), a USB interface chip,
  133. is used by some cheap memory programmers.
  134. The one we describe can be bought at
  135. [aliexpress](http://www.aliexpress.com/item/Free-Shipping-CH341A-24-25-Series-EEPROM-Flash-BIOS-DVD-USB-Programmer-DVD-programmer-router-Nine/32583059603.html),
  136. but it's available [elsewhere](https://geizhals.eu/?fs=ch341a) too.
  137. Also, we don't use the included 3,3V power output (provides too little power),
  138. but a separate power supply. If you don't have any, consider getting a AMS1117
  139. 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)).
  140. * Leave the P/S Jumper connected (programmer mode, 1a86:5512 USB device)
  141. * Connect 3,3V from your external supply to the Pomona clip's (or hook) VCC
  142. * Connect GND from your external supply to GND on your CH341A programmer
  143. * Connect your clip or hooks to the rest of the programmer's SPI pins
  144. * Connect the programmer (and power supply, if USB) to your PC's USB port
  145. ![ch341a programmer with extra USB power supply](ch341a.jpg)
  146. #### unpack the Skulls release archive
  147. tar -xf skulls-x230-<version>.tar.xz
  148. cd skulls-x230-<version>
  149. #### ifd unlock and me_cleaner: the 8MB chip
  150. The [Intel Management Engine](https://en.wikipedia.org/wiki/Intel_Management_Engine)
  151. resides on the 8MB chip (at the bottom, closer to you).
  152. We don't need to touch it for coreboot-upgrades in the future, but to
  153. enable internal flashing, we need to unlock it once, and remove the Management
  154. Engine for
  155. [security reasons](https://en.wikipedia.org/wiki/Intel_Management_Engine#Security_vulnerabilities):
  156. sudo ./external_install_bottom.sh -m -k <backup-file-to-create>
  157. That's it. Keep the backup safe.
  158. Background (just so you know):
  159. * The `-m` option above also runs `me_cleaner -S` before flashing back, see [me_cleaner](https://github.com/corna/me_cleaner).
  160. * The `-l` option will (re-)lock your flash ROM, in case you want to force
  161. yourself (and others) to hardware-flashing.
  162. * Connecting an ethernet cable as a power-source for SPI (instead of the VCC pin)
  163. is not necessary (some other flashing how-to guides mention this).
  164. Setting a fixed (and low) SPI speed for flashrom offeres the same stability.
  165. Our scripts do this for you.
  166. #### First, optional step: Flash the bottom chip
  167. It may make sense to start with connecting your clip to the bottom (at the bottom, closer to you) chip (it has the same pinout than the upper chip). 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).
  168. #### Second, required step: Flash the upper chip
  169. sudo ./external_install_top.sh -k <backup-file-to-create>
  170. Select the image to flash and that's it.
  171. Keep the backup safe, assemble and
  172. turn on the X230. coreboot will do hardware init and start SeaBIOS.
  173. ## Updating
  174. Only the "upper" 4MB chip has to be written.
  175. You can again flash externally, using `external_install_top.sh` just like the
  176. first time, see above.
  177. Instead you can run the update directly on your X230
  178. using Linux. That's of course very convenient - just install flashrom from your
  179. Linux distribution - but according to the
  180. [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html)
  181. this is very dangerous:
  182. 1. boot Linux with the `iomem=relaxed` boot parameter (for example in /etc/default/grub `GRUB_CMDLINE_LINUX_DEFAULT`)
  183. 2. [download](https://github.com/merge/skulls/releases) the latest Skulls release tarball and unpack it
  184. 3. run `sudo ./x230_skulls.sh` and choose the image to flash.
  185. ## Moving to Heads
  186. [Heads](http://osresearch.net/) is an alternative BIOS system with advanced
  187. security features. It's more complicated to use though. When having Skulls
  188. installed, installing Heads is as easy as updating Skulls. You can directly
  189. start using it:
  190. * [build Heads](https://github.com/osresearch/heads)
  191. * boot Linux with the `iomem=relaxed` boot parameter
  192. * copy Heads' 12M image file `build/x230/coreboot.rom` to Skulls' x230 directory
  193. * run `sudo ./x230_heads.sh`
  194. That's it. Heads is a completely different project. Please read the
  195. [documentation](http://osresearch.net/) for how to use it and report bugs
  196. [over there](https://github.com/osresearch/heads/issues)
  197. Switching back to Skulls is the same as [updating](#updating). Just run
  198. `./x230_skulls.sh`.
  199. ## Why does this work?
  200. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  201. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  202. one holds the rest that you can [modify yourself once](#first-time-installation),
  203. if you like, but strictly speaking, you
  204. [don't need to touch it at all](https://www.coreboot.org/Board:lenovo/x230#Building_Firmware).
  205. What's this "rest"?
  206. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.
  207. Read the [coreboot documentation](https://doc.coreboot.org/mainboard/lenovo/xx30_series.html)
  208. for more details.
  209. ## how to reproduce the release images
  210. * `git clone https://github.com/merge/skulls`
  211. * `git checkout <VERSION>` for the release you want to build
  212. * `cd skulls/x230`
  213. * `./build.sh` and choose the configuration you want to build