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.

209 lines
9.5 KiB

6 years ago
  1. # coreboot-x230
  2. pre-built [coreboot](https://www.coreboot.org/) images and documentation on
  3. how to flash them for the [Thinkpad X230](https://pcsupport.lenovo.com/en/products/laptops-and-netbooks/thinkpad-x-series-laptops/thinkpad-x230)
  4. These images
  5. * include [SeaBIOS](https://seabios.org/SeaBIOS) as coreboot payload, for maximum compatibility.
  6. * are meant to be [flashed externally](#how-to-flash) (...top.rom release files)
  7. * ...full.rom release files are not functional entirely. Only the the top 4M are usable.
  8. * are compatible with Windows and Linux
  9. ## Latest build (config overview and version info)
  10. See our [releases](https://github.com/merge/coreboot-x230/releases)
  11. * Lenovo's proprietary VGA BIOS ROM is executed in "secure" mode
  12. ### coreboot
  13. * We simply take coreboot's current state in it's master branch at the time we build a release image.
  14. That's the preferred way to use coreboot. The git revision we use is always included in the release.
  15. ### Intel microcode
  16. * revision `1f` from 2018-02-07 (Intel package [20180312](https://downloadcenter.intel.com/download/27591) not yet in coreboot upstream) under [Intel's license](LICENSE.microcode)
  17. ### SeaBIOS
  18. * version [1.11.0](https://seabios.org/Releases#SeaBIOS_1.11.0) from 2017-11-10 (part of coreboot upstream)
  19. ## When do we do a release?
  20. Either when
  21. * There is a new SeaBIOS release,
  22. * There is a new Intel microcode release (for our CPU model),
  23. * There is a coreboot issue that affects us, or
  24. * We change the config
  25. ## TL;DR
  26. Download a released image, connect your hardware SPI flasher to the "upper"
  27. 4MB chip in your X230, and do
  28. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E" -w x230_coreboot_seabios_example_top.rom
  29. where `linux_spi:` is the example of using your SPI pins of, for example, a
  30. Raspberry Pi. A [Bus Pirate](http://dangerousprototypes.com/docs/Bus_Pirate) with
  31. `buspirate_spi` or others connected to the host directly should be fine too.
  32. ## Flashing for the first time
  33. ### flashrom chip config
  34. We use [flashrom](https://flashrom.org/) for flashing. Run `flashrom -p <your_hardware>`
  35. (for [example](#how-to-flash) `flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128` for the
  36. Raspberry Pi) to let flashrom detect the chip. It will probably list a few you need to choose
  37. from when flashing (by adding `-c "<chipname>"`). While there might be specific examples
  38. in the commands below, please review the chip model for your device. In case you are
  39. unsure what to specify, here's some examples we find out there:
  40. #### 4MB chip
  41. * `MX25L3206E` seems to mostly be in use
  42. #### 8MB chip
  43. * `MX25L3206E/MX25L3208E` is seen working with various X230 models.
  44. * `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)
  45. * `EN25QH64` is used sometimes
  46. ### EC firmware (optional)
  47. Enter Lenovo's BIOS with __F1__ and check the embedded controller (EC) version to be
  48. __1.14__ and upgrade using [the latest bootable CD](https://support.lenovo.com/at/en/downloads/ds029188)
  49. if it isn't. The EC cannot be upgraded when coreboot is installed. (In case a newer
  50. version should ever be available (I doubt it), you could temporarily flash back your
  51. original Lenovo BIOS image)
  52. ### me_cleaner (optional)
  53. The Intel Management Engine resides on the 8MB chip. We don't need to touch it
  54. for coreboot-upgrades in the future, but while opening up the Thinkpad anyways,
  55. we can save it and run [ifdtool](https://github.com/coreboot/coreboot/tree/master/util/ifdtool)
  56. and [me_cleaner](https://github.com/corna/me_cleaner) on it:
  57. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe.rom
  58. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe2.rom
  59. diff ifdmegbe.rom ifdmegbe2.rom
  60. git clone https://github.com/corna/me_cleaner.git && cd me_cleaner
  61. ./me_cleaner.py -S -O ifdmegbe_meclean.rom ifdmegbe.rom
  62. ifdtool -u ifdmegbe_meclean.rom
  63. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -w ifdmegbe_meclean.rom.new
  64. ### save the 4MB chip
  65. (internally, memory of the two chips is mapped together, the 8MB being the lower
  66. part, but we can essientially ignore that)
  67. For the first time, we have to save the original image, just like we did with
  68. the 8MB chip. It's important to keep this image somewhere safe:
  69. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E" -r top1.rom
  70. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E" -r top2.rom
  71. diff top1.rom top2.rom
  72. ## Flashing the coreboot / SeaBIOS image
  73. When __upgrading__ to a new version, for example when a new [SeaBIOS](https://seabios.org/Releases)
  74. version is available, only the "upper" 4MB chip has to be written.
  75. Download the latest release image we provide here and flash it:
  76. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E" -w x230_coreboot_seabios_example_top.rom
  77. ## How to flash
  78. We flash externally, using a "Pomona 5250 8-pin SOIC test clip". You'll find
  79. one easily. This is how the X230's SPI connection looks on both chips:
  80. Screen (furthest from you)
  81. __
  82. MOSI 5 --| |-- 4 GND
  83. CLK 6 --| |-- 3 N/C
  84. N/C 7 --| |-- 2 MISO
  85. VCC 8 --|__|-- 1 CS
  86. Edge (closest to you)
  87. ### Example: Raspberry Pi 3
  88. We run [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
  89. and have the following setup
  90. * [Serial connection](https://elinux.org/RPi_Serial_Connection) using a "USB to Serial" UART Adapter and picocom or minicom
  91. * Yes, in this case you need a second PC connected to the RPi over UART
  92. * in the SD Cards's `/boot/config.txt` file `enable_uart=1` and `dtparam=spi=on`
  93. * [For flashrom](https://www.flashrom.org/RaspberryPi) we put `spi_bcm2835` and `spidev` in /etc/modules
  94. * [Connect to a wifi](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md) or to network over ethernet to install `flashrom`
  95. * only use the ...top.rom release file
  96. * connect the Clip to the Raspberry Pi 3:
  97. * use `linux_spi` as flashrom programmer name
  98. Edge of pi (furthest from you)
  99. (UART)
  100. L GND TX RX CS
  101. E | | | |
  102. F +---------------------------------------------------------------------------------+
  103. T | x x x x x x x x x x x x x x x x x x x x |
  104. | x x x x x x x x x x x x x x x x x x x x |
  105. E +----------------------------------^---^---^---^-------------------------------^--+
  106. D | | | | |
  107. G 3.3V MOSIMISO| GND
  108. E (VCC) CLK
  109. Body of Pi (closest to you)
  110. Now you should be able to copy the image over to your Rasperry Pi and run the
  111. mentioned `flashrom` commands. One way to copy, is convertig it to ascii using
  112. `uuencode` (part of Debian's sharutils package) described below. This is a very
  113. direct, shady and slow way to copy file. Another way is of course using a USB
  114. Stick or scp :) (but you need even more hardware or a network).
  115. (convert)
  116. host$ uuencode coreboot.rom coreboot.rom.ascii > coreboot.rom.ascii
  117. (transfer)
  118. rpi$ cat > coreboot.rom.ascii
  119. host$ pv coreboot.rom.ascii > /dev/ttyUSBX
  120. (wait)
  121. rpi$ (CTRL-D)
  122. (convert back)
  123. rpi$ uudecode -o coreboot.rom coreboot.rom.ascii
  124. (verify)
  125. host$ sha1sum coreboot.rom
  126. rpi$ sha1sum coreboot.rom
  127. ![Raspberry Pi at work](rpi_clip.jpg)
  128. ### Example: internal
  129. NOT YET AVAILABLE HERE
  130. * make sure you have your backups
  131. * You have to have your 8MB chip flashed externally after `ifdtool -u ifdmegbe.rom` before this, once
  132. * according to the [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html) this is very dangerous!
  133. * very convenient - you don't need any additional hardware
  134. * here you'll use the ...full.rom release file
  135. * Boot Linux with the `iomem=relaxed` boot parameter (for example set in /etc/default/grub)
  136. * use `internal` as flashrom programmer name
  137. * create the following file (named x230-layout.txt):
  138. 0x00000000:0x007fffff ifdmegbe
  139. 0x00800000:0x00bfffff bios
  140. `flashrom -p internal --layout x230-layout.txt --image bios -c "MX25L3206E" -w x230_coreboot_seabios_example_full.rom`
  141. You may have to set programmer options `internal:laptop=force_I_want_a_brick,spispeed=128` or parts
  142. of it, or other settings...
  143. ## How we build
  144. * Everything necessary to build coreboot (while only the top 4MB are usable of course) is included here
  145. * The task of [building coreboot](https://www.coreboot.org/Build_HOWTO) is not too difficult
  146. * When doing a release here, we always try to upload to coreboot's [board status project](https://www.coreboot.org/Supported_Motherboards)
  147. * If we add out-of-tree patches, we always [post them for review](http://review.coreboot.org/) upstream
  148. ## Why does this work?
  149. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  150. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  151. one holds the rest that you can [modify yourself once](#flashing-for-the-first-time),
  152. if you like, but strictly speaking, you don't need to touch it at all. What's this "rest"?
  153. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.
  154. ## Alternatives
  155. * [Heads](https://github.com/osresearch/heads/releases) also releases pre-built
  156. flash images for the X230 - with __way__ more sophisticated functionality.