| 1 | # Lenovo X200 / T400 / T500 / X301 common |
| 2 | |
| 3 | These models are sold with either 8 MiB or 4 MiB flash chip. You can identify |
| 4 | the chip in your machine through flashrom: |
| 5 | ```console |
| 6 | # flashrom -p internal |
| 7 | ``` |
| 8 | |
| 9 | Note that this does not allow you to determine whether the chip is in a SOIC-8 |
| 10 | or a SOIC-16 package. |
| 11 | |
| 12 | ## Installing with ME firmware |
| 13 | |
| 14 | To install coreboot and keep ME working, you don't need to do anything special |
| 15 | with the flash descriptor. Only flash the `bios` region externally and don't |
| 16 | touch any other regions: |
| 17 | ```console |
| 18 | # flashrom -p YOUR_PROGRAMMER -w coreboot.rom --ifd -i bios |
| 19 | ``` |
| 20 | |
| 21 | ## Installing without ME firmware |
| 22 | |
| 23 | ```{eval-rst} |
| 24 | .. Note:: |
| 25 | **ThinkPad R500** has slightly different flash layout (it doesn't have |
| 26 | ``gbe`` region), so the process would be a little different for that model. |
| 27 | ``` |
| 28 | |
| 29 | On Montevina machines it's possible to disable ME and remove its firmware from |
| 30 | SPI flash by modifying the flash descriptor. This also makes it possible to use |
| 31 | the flash region the ME used for `bios` region, allowing for much larger |
| 32 | payloads. |
| 33 | |
| 34 | First of all create a backup of your ROM with an external programmer: |
| 35 | ```console |
| 36 | # flashrom -p YOUR_PROGRAMMER -r backup.rom |
| 37 | ``` |
| 38 | |
| 39 | Then, split the IFD regions into separate files with ifdtool. You will need |
| 40 | `flashregion_3_gbe.bin` later. |
| 41 | ```console |
| 42 | $ ifdtool -x backup.rom |
| 43 | ``` |
| 44 | |
| 45 | Now you need to patch the flash descriptor. You can either [modify the one from |
| 46 | your backup with **ifdtool**](#modifying-flash-descriptor-using-ifdtool), or |
| 47 | [use one from the coreboot repository](#using-checked-in-flash-descriptor-via-bincfg). |
| 48 | |
| 49 | ### Modifying flash descriptor using ifdtool |
| 50 | |
| 51 | Pick the layout according to your chip size from the table below and save it to |
| 52 | the `new_layout.txt` file: |
| 53 | |
| 54 | ```{eval-rst} |
| 55 | +---------------------------+---------------------------+---------------------------+ |
| 56 | | 4 MiB chip | 8 MiB chip | 16 MiB chip | |
| 57 | +===========================+===========================+===========================+ |
| 58 | | .. code-block:: none | .. code-block:: none | .. code-block:: none | |
| 59 | | | | | |
| 60 | | 00000000:00000fff fd | 00000000:00000fff fd | 00000000:00000fff fd | |
| 61 | | 00001000:00002fff gbe | 00001000:00002fff gbe | 00001000:00002fff gbe | |
| 62 | | 00003000:003fffff bios | 00003000:007fffff bios | 00003000:00ffffff bios | |
| 63 | | 00fff000:00000fff pd | 00fff000:00000fff pd | 00fff000:00000fff pd | |
| 64 | | 00fff000:00000fff me | 00fff000:00000fff me | 00fff000:00000fff me | |
| 65 | +---------------------------+---------------------------+---------------------------+ |
| 66 | ``` |
| 67 | |
| 68 | The last two lines define `pd` and `me` regions of negative size. This way |
| 69 | ifdtool will mark those as unused. |
| 70 | |
| 71 | Update regions in the flash descrpitor (it was extracted previously with |
| 72 | `ifdtool -x`): |
| 73 | ```console |
| 74 | $ ifdtool -n new_layout.txt flashregion_0_flashdescriptor.bin |
| 75 | ``` |
| 76 | |
| 77 | Set `MeDisable` bit in ICH0 and MCH0 straps: |
| 78 | ```console |
| 79 | $ ifdtool -M 1 flashregion_0_flashdescriptor.bin.new |
| 80 | ``` |
| 81 | |
| 82 | Delete previous descriptors and rename the final one: |
| 83 | ```console |
| 84 | $ rm flashregion_0_flashdescriptor.bin |
| 85 | $ rm flashregion_0_flashdescriptor.bin.new |
| 86 | $ mv flashregion_0_flashdescriptor.bin.new.new flashregion_0_flashdescriptor.bin |
| 87 | ``` |
| 88 | |
| 89 | Continue to the [Configuring coreboot](#configuring-coreboot) section. |
| 90 | |
| 91 | ### Using checked-in flash descriptor via bincfg |
| 92 | |
| 93 | There is a copy of an X200's flash descriptor checked into the coreboot |
| 94 | repository. It is supposed to work for the T400/T500 as well. The descriptor |
| 95 | can be converted back to its binary form using a tool called **bincfg**. Go |
| 96 | to `util/bincfg` and build it: |
| 97 | ```console |
| 98 | $ cd util/bincfg |
| 99 | $ make |
| 100 | ``` |
| 101 | |
| 102 | If your flash is not 8 MiB, you need to change values of `flcomp_density1` and |
| 103 | `flreg1_limit` in the `ifd-x200.set` file according to following table: |
| 104 | |
| 105 | ```{eval-rst} |
| 106 | +-----------------+-------+-------+--------+ |
| 107 | | | 4 MiB | 8 MiB | 16 MiB | |
| 108 | +=================+=======+=======+========+ |
| 109 | | flcomp_density1 | 0x3 | 0x4 | 0x5 | |
| 110 | +-----------------+-------+-------+--------+ |
| 111 | | flreg1_limit | 0x3ff | 0x7ff | 0xfff | |
| 112 | +-----------------+-------+-------+--------+ |
| 113 | ``` |
| 114 | |
| 115 | Then convert the flash descriptor: |
| 116 | ```console |
| 117 | $ make gen-ifd-x200 |
| 118 | ``` |
| 119 | |
| 120 | It will be saved to the `flashregion_0_fd.bin` file. |
| 121 | |
| 122 | ### Configuring coreboot |
| 123 | |
| 124 | Now configure coreboot. You need to select correct chip size and specify paths |
| 125 | to flash descriptor and gbe dump. |
| 126 | |
| 127 | ``` |
| 128 | Mainboard ---> |
| 129 | ROM chip size (8192 KB (8 MB)) # According to your chip |
| 130 | (0x7fd000) Size of CBFS filesystem in ROM # or 0x3fd000 for 4 MiB chip / 0xffd000 for 16 MiB chip |
| 131 | |
| 132 | Chipset ---> |
| 133 | [*] Add Intel descriptor.bin file |
| 134 | # Note: if you used bincfg, specify path to generated util/bincfg/flashregion_0_fd.bin |
| 135 | (/path/to/flashregion_0_flashdescriptor.bin) Path and filename of the descriptor.bin file |
| 136 | |
| 137 | [*] Add gigabit ethernet configuration |
| 138 | (/path/to/flashregion_3_gbe.bin) Path to gigabit ethernet configuration |
| 139 | ``` |
| 140 | |
| 141 | Then build coreboot and flash whole `build/coreboot.rom` to the chip. |
| 142 | |
| 143 | ## Flash layout |
| 144 | |
| 145 | The flash layouts of the OEM firmware are as follows: |
| 146 | |
| 147 | ```{eval-rst} |
| 148 | +---------------------------------+---------------------------------+ |
| 149 | | 4 MiB chip | 8 MiB chip | |
| 150 | +=================================+=================================+ |
| 151 | | .. code-block:: none | .. code-block:: none | |
| 152 | | | | |
| 153 | | 00000000:00000fff fd | 00000000:00000fff fd | |
| 154 | | 00001000:001f5fff me | 00001000:005f5fff me | |
| 155 | | 001f6000:001f7fff gbe | 005f6000:005f7fff gbe | |
| 156 | | 001f8000:001fffff pd | 005f8000:005fffff pd | |
| 157 | | 00200000:003fffff bios | 00600000:007fffff bios | |
| 158 | | 00290000:002affff ec | 00690000:006affff ec | |
| 159 | | 003e0000:003fffff bootblock | 007e0000:007fffff bootblock | |
| 160 | +---------------------------------+---------------------------------+ |
| 161 | ``` |
| 162 | |
| 163 | On each boot of vendor BIOS `ec` area in flash is checked for having firmware |
| 164 | there, and if there is one, it proceedes to update firmware on H8S/2116 (when |
| 165 | both external power and main battery are attached). Once update is performed, |
| 166 | first 64 KiB of `ec` area is erased. Visit |
| 167 | [thinkpad-ec repository](https://github.com/hamishcoleman/thinkpad-ec) to learn |
| 168 | more about how to extract EC firmware from vendor updates. |