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.

280 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 (config overview and version info)
  4. * Get it from our [release page](https://github.com/merge/coreboot-x230/releases)
  5. * The only proprietary binary, the VGA BIOS is executed in "secure" mode ([PCI_OPTION_ROM_RUN_YABEL](https://www.coreboot.org/Coreboot_Options))
  6. ### coreboot
  7. * We simply take coreboot's current state in it's master branch at the time we build a release image.
  8. That's the preferred way to use coreboot. The git revision we use is always included in the release.
  9. ### Intel microcode
  10. * revision `1f` from 2018-02-07 see package [20180312](https://downloadcenter.intel.com/download/27591) under [Intel's license](LICENSE.microcode)
  11. ### SeaBIOS
  12. * version [1.11.1](https://seabios.org/Releases) from 2018-03-19
  13. ## table of contents
  14. * [TL;DR](#tldr)
  15. * [Flashing for the first time](#flashing-for-the-first-time)
  16. * [How to flash](#how-to-flash)
  17. * [Why does this work](#why-does-this-work)
  18. ## TL;DR
  19. For first-time flashing, remove the keyboard and palmrest, and (using a
  20. Raspberry Pi with a SPI 8-pin chip clip connected), run
  21. `flashrom_rpi_bottom_unlock.sh` on the lower chip
  22. and `flashrom_rpi_top_write.sh` on the top chip of the two.
  23. For updating later, run `prepare_internal_flashing.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. ## Flashing for the first time
  28. * Especially for the first time, you must flash externally. See below for the details
  29. for using a Rapberry Pi, for example.
  30. * Make sure you have RAM that uses 1,5V, not 1,35V. Check the specification of
  31. your RAM module(s).
  32. ### before you begin: original update / EC firmware (optional)
  33. Before flashing coreboot, consider doing one original Lenovo upgrade process
  34. in case you're not running the latest version. This is not supported anymore,
  35. once you're running coreboot (You'd have to manually flash back your backup
  36. images first, see later chapters).
  37. Also, this updates the BIOS _and_ Embedded Controller (EC) firmware. The EC
  38. is not updated anymore, when running coreboot. The latest EC version is 1.14
  39. and that's unlikely to change.
  40. In case you're not running the latest BIOS version, either
  41. * use [the latest original CD](https://support.lenovo.com/at/en/downloads/ds029188) and burn it, or
  42. * use the same, only with a patched EC firmware that allows using any battery:
  43. #### Disable the battery validation check
  44. By default, only original Lenovo batteries are allowed.
  45. Thanks to [this](http://zmatt.net/unlocking-my-lenovo-laptop-part-3/)
  46. [project](https://github.com/eigenmatt/mec-tools) we can use Lenovo's bootable
  47. upgrade image, change it and create a bootable _USB_ image, with an EC update
  48. that allows us to use any 3rd party aftermarket battery:
  49. sudo apt-get install build-essential git mtools libssl-dev
  50. git clone https://github.com/hamishcoleman/thinkpad-ec && cd thinkpad-ec
  51. make patch_disable_keyboard clean
  52. make patch_enable_battery clean
  53. make patched.x230.img
  54. That's it. You can create a bootable USB stick: `sudo dd if=patched.x230.img of=/dev/sdx`
  55. and boot from it. Alternatively, burn `patched.x230.iso` to a CD. And make sure
  56. you have "legacy" boot set, not "UEFI" boot.
  57. ### preparation: required hardware
  58. * An 8 Pin SOIC Clip, for example from
  59. [Pomona electronics](https://www.pomonaelectronics.com/products/test-clips/soic-clip-8-pin)
  60. or alternatively hooks, for example from
  61. [E-Z-Hook](http://catalog.e-z-hook.com/viewitems/test-hooks/e-z-micro-hooks-single-hook-style)
  62. * 6 [female](https://electronics.stackexchange.com/questions/37783/how-can-i-create-a-female-jumper-wire-connector)
  63. [jumper wires](https://en.wikipedia.org/wiki/Jump_wire) to connect the clip to
  64. a hardware flasher
  65. * a hardware flasher
  66. [supported by flashrom](https://www.flashrom.org/Flashrom/0.9.9/Supported_Hardware#USB_Devices)
  67. but we currently only support using a Raspberry Pi
  68. ### preparation: flashrom chip config
  69. We (or our scripts) use [flashrom](https://flashrom.org/) for flashing. Connect
  70. the programmer to the chip and run
  71. `flashrom -p <your_hardware>` (for [example](#how-to-flash)
  72. `flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128` for the
  73. Raspberry Pi) to let flashrom detect the chip. If `-c` is omitted, the scripts
  74. will run this for you.
  75. It will probably list a few you need to choose from when flashing
  76. (by adding `-c <chipname>`). Please review the chip model for your device.
  77. In case you are unsure what to specify, here's some examples we find out there:
  78. #### 4MB chip
  79. * `MX25L3206E` seems to mostly be in use
  80. #### 8MB chip
  81. * `MX25L6406E/MX25L6408E` is used in [this guide](https://github.com/mfc/flashing-docs/blob/master/walkthrough%20for%20flashing%20heads%20on%20an%20x230.md#neutering-me)
  82. * `MX25L3206E/MX25L3208E` is seen working with various X230 models.
  83. * `EN25QH64` is used sometimes
  84. ### ifd unlock and me_cleaner: the 8MB chip
  85. The Intel Management Engine resides on the 8MB chip (at the bottom, closer to
  86. you). We don't need to touch it
  87. for coreboot-upgrades in the future, but to enable internal flashing, we need
  88. to unlock it once.
  89. We run [ifdtool](https://github.com/coreboot/coreboot/tree/master/util/ifdtool)
  90. and, while we are at it, [me_cleaner](https://github.com/corna/me_cleaner) on it:
  91. We support using a RPi, see below for the connection details.
  92. Move the release-tarball to the RPi (USB Stick or however) and unpack it
  93. (to the current directory and change into it):
  94. mkdir tarball_extracted
  95. tar -xf <tarball>.tar.xz -C tarball_extracted
  96. cd tarball_extracted
  97. And finally unlock the 8M chip by using the included script (be patient). Again,
  98. this doesn't replace much; it reads the original, unlocks and flashes back:
  99. sudo ./flashrom_rpi_bottom_unlock.sh -m -c <chipname> -k <backup.bin>
  100. That's it. Keep the backup safe.
  101. #### background (just so you know)
  102. * The `-m` option above also runs `me_cleaner -S` before flashing back.
  103. * The `-l` option will (re-)lock your flash ROM, in case you want to force
  104. yourself (and others) to hardware-flashing externally.
  105. * If you don't use a RPi, change the flashrom programmer to your needs.This
  106. is roughly what's going on:
  107. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe.rom
  108. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe2.rom
  109. diff ifdmegbe.rom ifdmegbe2.rom
  110. git clone https://github.com/corna/me_cleaner.git && cd me_cleaner
  111. ./me_cleaner.py -S -O ifdmegbe_meclean.rom ifdmegbe.rom
  112. ifdtool -u ifdmegbe_meclean.rom
  113. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -w ifdmegbe_meclean.rom.new
  114. ### BIOS: the 4MB chip
  115. (internally, memory of the two chips is mapped together, the 8MB being the lower
  116. part, but we can essientially ignore that). Again, using a RPi is supported
  117. here. We assume you have the unpacked release tarball ready, see above. Use
  118. the following included script:
  119. sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios_<hash>_top.rom -c <chipname> -k <backup>
  120. That's it. Keep the backup safe.
  121. ## How to flash
  122. When __upgrading__ to a new release, only the "upper" 4MB chip has to be written
  123. and any of the following examples are possible. Otherwise you cannot use
  124. "internal" flashing and please read
  125. [flashing for the first time](#flashing-for-the-first-time).
  126. ### Example: internal
  127. * Only for _updating_! You have to have your 8MB chip flashed externally using
  128. our `flashrom_rpi_bottom_unlock.sh` script (`ifdtool -u`) before this, once
  129. * very convenient: just install flashrom on your X230 but according to the
  130. [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html)
  131. this is very dangerous!
  132. * Boot Linux with the `iomem=relaxed` boot parameter (for example set in /etc/default/grub)
  133. * download the latest release tarball (4MB "top" BIOS image is included) and extract it
  134. * run `prepare_internal_flashing.sh` for generating all necessary files and instructions
  135. ### Example: Raspberry Pi 3
  136. Here you'll flash externally, using a test clip or hooks, see [required hardware](#preparation-required-hardware).
  137. Remove the 7 screws to remove the keyboard (by pushing it towards the
  138. screen before lifting) and the palmrest. You'll find the chips using the photo
  139. below. This is how the SPI connection looks on both chips:
  140. Screen (furthest from you)
  141. __
  142. MOSI 5 --| |-- 4 GND
  143. CLK 6 --| |-- 3 N/C
  144. N/C 7 --| |-- 2 MISO
  145. VCC 8 --|__|-- 1 CS
  146. Edge (closest to you)
  147. We run [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
  148. and have the following setup
  149. * [Serial connection](https://elinux.org/RPi_Serial_Connection) using a
  150. "USB to Serial" UART Adapter and picocom or minicom (yes, in this case you
  151. need a second PC connected to the RPi over UART)
  152. * in the SD Cards's `/boot/config.txt` file `enable_uart=1` and `dtparam=spi=on`
  153. * [For flashrom](https://www.flashrom.org/RaspberryPi) we put `spi_bcm2835`
  154. and `spidev` in /etc/modules
  155. * [Connect to a wifi](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md)
  156. or ethernet to `sudo apt-get install flashrom`
  157. * connect the Clip to the Raspberry Pi 3 (there are
  158. [prettier images](https://github.com/splitbrain/rpibplusleaf) too):
  159. Edge of pi (furthest from you)
  160. (UART)
  161. L GND TX RX CS
  162. E | | | |
  163. F +---------------------------------------------------------------------------------+
  164. T | x x x x x x x x x x x x x x x x x x x x |
  165. | x x x x x x x x x x x x x x x x x x x x |
  166. E +----------------------------------^---^---^---^-------------------------------^--+
  167. D | | | | |
  168. G 3.3V MOSIMISO| GND
  169. E (VCC) CLK
  170. Body of Pi (closest to you)
  171. Now copy our release tarball over to the Rasperry Pi.
  172. One way to copy, is convertig it to ascii using
  173. `uuencode` (part of Debian's sharutils package) described below. This is a
  174. direct, shady and slow way to transfer a file. Use a USB
  175. Stick or scp instead. :) (but you need even more hardware or a network).
  176. (convert)
  177. host$ uuencode <tarball> <tarball>.ascii > <tarball>.ascii
  178. (transfer)
  179. rpi$ cat > <tarball>.ascii
  180. host$ pv <tarball>.ascii > /dev/ttyUSBX
  181. (wait)
  182. rpi$ (CTRL-D)
  183. (convert back)
  184. rpi$ uudecode -o <tarball> <tarball>.ascii
  185. (verify)
  186. host$ sha1sum <tarball>
  187. rpi$ sha1sum <tarball>
  188. Unpack it:
  189. mkdir tarball_extracted
  190. tar -xf <tarball> -C tarball_extracted
  191. cd tarball_extracted
  192. ![Raspberry Pi at work](rpi_clip.jpg)
  193. Connect the SPI clip to the "top" chip, and run:
  194. sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios_<hash>_top.rom -c <chipname>
  195. That's it.
  196. #### background (just so you know)
  197. * Connecting an ethernet cable as a power-source for SPI (instead of the VCC pin)
  198. is not necessary (some other flashing how-to guides mention this).
  199. Setting a fixed (and low) SPI speed for flashrom offeres the same stability.
  200. Our scripts do this for you.
  201. ## Why does this work?
  202. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  203. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  204. one holds the rest that you can [modify yourself once](#flashing-for-the-first-time),
  205. if you like, but strictly speaking, you
  206. [don't need to touch it at all](https://www.coreboot.org/Board:lenovo/x230#Building_Firmware).
  207. What's this "rest"?
  208. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.