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.

188 lines
8.3 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-03-12 (Intel package [20180312](https://downloadcenter.intel.com/download/27591) added by us; not yet in coreboot upstream)
  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 (included in coreboot AND affecting our CPU ID),
  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 -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. ### EC firmware (optional)
  34. Enter Lenovo's BIOS with __F1__ and check the embedded controller (EC) version to be
  35. __1.14__ and upgrade using [the latest bootable CD](https://support.lenovo.com/at/en/downloads/ds029188)
  36. if it isn't. The EC cannot be upgraded when coreboot is installed. (In case a newer
  37. version should ever be available (I doubt it), you could temporarily flash back your
  38. original Lenovo BIOS image)
  39. ### me_cleaner (optional)
  40. The Intel Management Engine resides on the 8MB chip. We don't need to touch it
  41. for coreboot-upgrades in the future, but while opening up the Thinkpad anyways,
  42. we can save it and run [ifdtool](https://github.com/coreboot/coreboot/tree/master/util/ifdtool)
  43. and [me_cleaner](https://github.com/corna/me_cleaner) on it:
  44. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E/MX25L3208E" -r ifdmegbe.rom
  45. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E/MX25L3208E" -r ifdmegbe2.rom
  46. diff ifdmegbe.rom ifdmegbe2.rom
  47. git clone https://github.com/corna/me_cleaner.git && cd me_cleaner
  48. ./me_cleaner.py -S -O ifdmegbe_meclean.rom ifdmegbe.rom
  49. ifdtool -u ifdmegbe_meclean.rom
  50. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L3206E/MX25L3208E" -w ifdmegbe_meclean.rom.new
  51. ### save the 4MB chip
  52. (internally, memory of the two chips is mapped together, the 8MB being the lower
  53. part, but we can essientially ignore that)
  54. For the first time, we have to save the original image, just like we did with
  55. the 8MB chip. It's important to keep this image somewhere safe:
  56. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -r top1.rom
  57. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -r top2.rom
  58. diff top1.rom top2.rom
  59. ## Flashing the coreboot / SeaBIOS image
  60. When __upgrading__ to a new version, for example when a new [SeaBIOS](https://seabios.org/Releases)
  61. version is available, only the "upper" 4MB chip has to be written.
  62. Download the latest release image we provide here and flash it:
  63. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -w x230_coreboot_seabios_example_top.rom
  64. ## How to flash
  65. We flash externally, using a "Pomona 5250 8-pin SOIC test clip". You'll find
  66. one easily. This is how the X230's SPI connection looks on both chips:
  67. Screen (furthest from you)
  68. __
  69. MOSI 5 --| |-- 4 GND
  70. CLK 6 --| |-- 3 N/C
  71. N/C 7 --| |-- 2 MISO
  72. VCC 8 --|__|-- 1 CS
  73. Edge (closest to you)
  74. ### Example: Raspberry Pi 3
  75. We run [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
  76. and have the following setup
  77. * [Serial connection](https://elinux.org/RPi_Serial_Connection) using a "USB to Serial" UART Adapter and picocom or minicom
  78. * Yes, in this case you need a second PC connected to the RPi over UART
  79. * in the SD Cards's `/boot/config.txt` file `enable_uart=1` and `dtparam=spi=on`
  80. * [For flashrom](https://www.flashrom.org/RaspberryPi) we put `spi_bcm2835` and `spidev` in /etc/modules
  81. * [Connect to a wifi](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md) or to network over ethernet to install `flashrom`
  82. * only use the ...top.rom release file
  83. * connect the Clip to the Raspberry Pi 3:
  84. Edge of pi (furthest from you)
  85. (UART)
  86. L GND TX RX CS
  87. E | | | |
  88. F +---------------------------------------------------------------------------------+
  89. T | x x x x x x x x x x x x x x x x x x x x |
  90. | x x x x x x x x x x x x x x x x x x x x |
  91. E +----------------------------------^---^---^---^-------------------------------^--+
  92. D | | | | |
  93. G 3.3V MOSIMISO| GND
  94. E (VCC) CLK
  95. Body of Pi (closest to you)
  96. Now you should be able to copy the image over to your Rasperry Pi and run the
  97. mentioned `flashrom` commands. One way to copy, is convertig it to ascii using
  98. `uuencode` (part of Debian's sharutils package) described below. This is a very
  99. direct, shady and slow way to copy file. Another way is of course using a USB
  100. Stick or scp :) (but you need even more hardware or a network).
  101. (convert)
  102. host$ uuencode coreboot.rom coreboot.rom.ascii > coreboot.rom.ascii
  103. (transfer)
  104. rpi$ cat > coreboot.rom.ascii
  105. host$ pv coreboot.rom.ascii > /dev/ttyUSBX
  106. (wait)
  107. rpi$ (CTRL-D)
  108. (convert back)
  109. rpi$ uudecode -o coreboot.rom coreboot.rom.ascii
  110. (verify)
  111. host$ sha1sum coreboot.rom
  112. rpi$ sha1sum coreboot.rom
  113. ### Example: internal
  114. NOT YET AVAILABLE HERE
  115. * make sure you have your backups
  116. * You have to have your 8MB chip flashed externally after `ifdtool -u ifdmegbe.rom` before this, once
  117. * according to the [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html) this is very dangerous!
  118. * very convenient - you don't need any additional hardware
  119. * here you'll use the ...full.rom release file
  120. * Boot Linux with the `iomem=relaxed` boot parameter (for example set in /etc/default/grub)
  121. * create the following file (named x230-layout.txt):
  122. 0x00000000:0x007fffff ifdmegbe
  123. 0x00800000:0x00bfffff bios
  124. `flashrom -p internal --layout x230-layout.txt --image bios -w x230_coreboot_seabios_example_full.rom`
  125. You may have to set `internal:laptop=force_I_want_a_brick,spispeed=128` or parts
  126. of it, or other settings...
  127. ## How we build
  128. Everything necessary to build coreboot is included in this project and building
  129. coreboot is not hard at all. Please refer to [coreboot's own documentation](https://www.coreboot.org/Build_HOWTO).
  130. When building, testing and doing a release here, we always try to upload our
  131. result to coreboot's [board status project](https://www.coreboot.org/Supported_Motherboards).
  132. ## Why does this work?
  133. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  134. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  135. one holds the rest that you can [modify yourself once](#flashing-for-the-first-time),
  136. if you like, but strictly speaking, you don't need to touch it at all. What's this "rest"?
  137. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.
  138. ## Alternatives
  139. * [Heads](https://github.com/osresearch/heads/releases) also releases pre-built
  140. flash images for the X230 - with __way__ more sophisticated functionality.