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.

236 lines
10 KiB

6 years ago
6 years ago
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
  4. [Thinkpad X230](https://pcsupport.lenovo.com/en/products/laptops-and-netbooks/thinkpad-x-series-laptops/thinkpad-x230).
  5. SeaBIOS is used as coreboot payload to be compatible with Windows and Linux
  6. systems.
  7. ![seabios_bootmenu](front.jpg)
  8. ## Latest release (config overview and version info)
  9. * coreboot-x230 0.0.5 - see our [release page](https://github.com/merge/coreboot-x230/releases)
  10. * Lenovo's proprietary VGA BIOS ROM is executed in "secure" mode
  11. ### coreboot
  12. * We simply take coreboot's current state in it's master branch at the time we build a release image.
  13. That's the preferred way to use coreboot. The git revision we use is always included in the release.
  14. ### Intel microcode
  15. * 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)
  16. ### SeaBIOS
  17. * version [1.11.1](https://seabios.org/Releases) from 2018-03-19 (part of coreboot upstream)
  18. ## table of contents
  19. * [TL;DR](#tl-dr)
  20. * [Flashing for the first time](#flashing-for-the-first-time)
  21. * [How to update](#how-to-update)
  22. * [When do we do a release?](#when-do-we-do-a-release)
  23. * [How we build](#how-we-build)
  24. * [Why does this work](#why-does-this-work)
  25. * [Alternatives](#alternatives)
  26. ## TL;DR
  27. For first-time flashing, remove the keyboard and palmrest, and (using a
  28. Raspberry Pi), run `flashrom_rpi_bottom_unlock.sh` on the lower chip
  29. and `flashrom_rpi_top_write.sh` on the top chip of the two.
  30. For updating after this, run `prepare_internal_flashing.sh` to get
  31. files and instructions.
  32. ## Flashing for the first time
  33. Especially for the first time, you must flash externally. See below for the details
  34. for using a Rapberry Pi, for example.
  35. ### flashrom chip config
  36. We (or our scripts) use [flashrom](https://flashrom.org/) for flashing. Run
  37. `flashrom -p <your_hardware>` (for [example](#how-to-flash)
  38. `flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128` for the
  39. Raspberry Pi) to let flashrom detect the chip.
  40. It will probably list a few you need to choose from when flashing
  41. (by adding `-c <chipname>`). Please review the chip model for your device.
  42. In case you are unsure what to specify, here's some examples we find out there:
  43. #### 4MB chip
  44. * `MX25L3206E` seems to mostly be in use
  45. #### 8MB chip
  46. * `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)
  47. * `MX25L3206E/MX25L3208E` is seen working with various X230 models.
  48. * `EN25QH64` is used sometimes
  49. ### EC firmware (optional)
  50. Enter Lenovo's BIOS with __F1__ and check the embedded controller (EC) version to be
  51. __1.14__ and upgrade using
  52. [the latest bootable CD](https://support.lenovo.com/at/en/downloads/ds029188)
  53. if it isn't. This updates BIOS and EC. The EC cannot be upgraded when coreboot
  54. is installed. (In case a newer version should ever be available (I doubt it),
  55. you could temporarily flash back the original Lenovo BIOS image from your
  56. backup)
  57. ### ifd unlock and me_cleaner: the 8MB chip
  58. The Intel Management Engine resides on the 8MB chip (at the bottom, closer to
  59. you). We don't need to touch it
  60. for coreboot-upgrades in the future, but to enable internal flashing, we need
  61. to unlock it once.
  62. We run [ifdtool](https://github.com/coreboot/coreboot/tree/master/util/ifdtool)
  63. and, while we are at it, [me_cleaner](https://github.com/corna/me_cleaner) on it:
  64. We support using a RPi, see below for the connection details.
  65. Move the release-tarball to the RPi (USB Stick or however) and unpack it
  66. (to the current directory and change into it):
  67. mkdir tarball_extracted
  68. tar -xf <tarball>.tar.xz -C tarball_extracted
  69. cd tarball_extracted
  70. And finally unlock the 8M chip by using the included script (be patient):
  71. sudo ./flashrom_rpi_bottom_unlock.sh -m -c <chipname> -k <backup.bin>
  72. That's it. Keep the backup safe.
  73. when updating to a new release, you don't have to disasseble your Thinkpad
  74. and can flash internally (at your own risk), see below.
  75. #### background (just so you know)
  76. The `-m` option above also runs `me_cleaner -S` before flashing back.
  77. If you don't use a RPi, change the flashrom programmer to your needs:
  78. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe.rom
  79. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -r ifdmegbe2.rom
  80. diff ifdmegbe.rom ifdmegbe2.rom
  81. git clone https://github.com/corna/me_cleaner.git && cd me_cleaner
  82. ./me_cleaner.py -S -O ifdmegbe_meclean.rom ifdmegbe.rom
  83. ifdtool -u ifdmegbe_meclean.rom
  84. flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=128 -c "MX25L6406E/MX25L6408E" -w ifdmegbe_meclean.rom.new
  85. ### BIOS: the 4MB chip
  86. (internally, memory of the two chips is mapped together, the 8MB being the lower
  87. part, but we can essientially ignore that). Again, using a RPi is supported
  88. here. We assume you have the unpacked release tarball ready, see above. Use
  89. the following included script:
  90. sudo ./flashrom_rpi_top_write.sh -i x230_coreboot_seabios_<hash>_top.rom -c <chipname> -k <backup>
  91. That's it. Keep the backup safe.
  92. ## How to update
  93. When __upgrading__ to a new release, only the "upper" 4MB chip has to be written.
  94. Download the latest release image we provide and flash it:
  95. ### Example: Raspberry Pi 3
  96. Here you'll flash externally, using a "Pomona 5250 8-pin SOIC test clip". You'll find
  97. one easily. This is how the X230's SPI connection looks on both chips:
  98. Screen (furthest from you)
  99. __
  100. MOSI 5 --| |-- 4 GND
  101. CLK 6 --| |-- 3 N/C
  102. N/C 7 --| |-- 2 MISO
  103. VCC 8 --|__|-- 1 CS
  104. Edge (closest to you)
  105. and with our release tarball unpacked, the command you need looks like so:
  106. flashrom_rpi_top_write.sh -i x230_coreboot_seabios_<release>_top.rom -c <chipname>
  107. We run [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
  108. and have the following setup
  109. * [Serial connection](https://elinux.org/RPi_Serial_Connection) using a "USB to Serial" UART Adapter and picocom or minicom
  110. * Yes, in this case you need a second PC connected to the RPi over UART
  111. * in the SD Cards's `/boot/config.txt` file `enable_uart=1` and `dtparam=spi=on`
  112. * [For flashrom](https://www.flashrom.org/RaspberryPi) we put `spi_bcm2835` and `spidev` in /etc/modules
  113. * [Connect to a wifi](https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md) or to network over ethernet to install `flashrom`
  114. * only use the ...top.rom release file
  115. * connect the Clip to the Raspberry Pi 3 (there are [prettier images](https://github.com/splitbrain/rpibplusleaf) too:
  116. Edge of pi (furthest from you)
  117. (UART)
  118. L GND TX RX CS
  119. E | | | |
  120. F +---------------------------------------------------------------------------------+
  121. T | x x x x x x x x x x x x x x x x x x x x |
  122. | x x x x x x x x x x x x x x x x x x x x |
  123. E +----------------------------------^---^---^---^-------------------------------^--+
  124. D | | | | |
  125. G 3.3V MOSIMISO| GND
  126. E (VCC) CLK
  127. Body of Pi (closest to you)
  128. Now you should be able to copy the image over to your Rasperry Pi and run the
  129. mentioned `flashrom` commands. One way to copy, is convertig it to ascii using
  130. `uuencode` (part of Debian's sharutils package) described below. This is a very
  131. direct, shady and slow way to copy file. Another way is of course using a USB
  132. Stick or scp :) (but you need even more hardware or a network).
  133. (convert)
  134. host$ uuencode coreboot.rom coreboot.rom.ascii > coreboot.rom.ascii
  135. (transfer)
  136. rpi$ cat > coreboot.rom.ascii
  137. host$ pv coreboot.rom.ascii > /dev/ttyUSBX
  138. (wait)
  139. rpi$ (CTRL-D)
  140. (convert back)
  141. rpi$ uudecode -o coreboot.rom coreboot.rom.ascii
  142. (verify)
  143. host$ sha1sum coreboot.rom
  144. rpi$ sha1sum coreboot.rom
  145. ![Raspberry Pi at work](rpi_clip.jpg)
  146. ### Example: internal
  147. CAUTION: THIS IS NOT ENCOURAGED
  148. * Only for updating! You have to have your 8MB chip flashed externally using
  149. our `flashrom_rpi_bottom_unlock.sh` script (`ifdtool -u`) before this, once
  150. * very convenient, but according to the [flashrom manpage](https://manpages.debian.org/stretch/flashrom/flashrom.8.en.html) this is very dangerous!
  151. * Boot Linux with the `iomem=relaxed` boot parameter (for example set in /etc/default/grub)
  152. * download the latest release tarball (4MB "top" BIOS image is included) and extract it
  153. * run `prepare_internal_flashing.sh` for generating all necessary files and instructions
  154. ## When do we do a release?
  155. Either when
  156. * There is a new SeaBIOS release,
  157. * There is a new Intel microcode release (for our CPU model),
  158. * There is a coreboot issue that affects us, or
  159. * We change the config
  160. ## How we build
  161. * Everything necessary to build coreboot (while only the top 4MB are usable of course) is included here
  162. * The task of [building coreboot](https://www.coreboot.org/Build_HOWTO) is not too difficult
  163. * When doing a release here, we always try to upload to coreboot's [board status project](https://www.coreboot.org/Supported_Motherboards)
  164. * If we add out-of-tree patches, we always [post them for review](http://review.coreboot.org/) upstream
  165. ## Why does this work?
  166. On the X230, there are 2 physical "BIOS" chips. The "upper" 4MB
  167. one holds the actual bios we can generate using coreboot, and the "lower" 8MB
  168. one holds the rest that you can [modify yourself once](#flashing-for-the-first-time),
  169. if you like, but strictly speaking, you
  170. [don't need to touch it at all](https://www.coreboot.org/Board:lenovo/x230#Building_Firmware).
  171. What's this "rest"?
  172. Mainly a tiny binary used by the Ethernet card and the Intel Management Engine.
  173. ## Alternatives
  174. * [Heads](https://github.com/osresearch/heads/releases) also releases pre-built
  175. flash images for the X230 - with __way__ more sophisticated functionality.