summaryrefslogtreecommitdiffstats
path: root/docs/install/x200_external.html
blob: 4b990a0c54fa3bf94f79e9a7d369bcc0121f7d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<style type="text/css">
		@import url('../css/main.css');
	</style>

	<title>ThinkPad X200: flashing tutorial (BeagleBone Black)</title>
</head>

<body>

	<header>
		<h1 id="pagetop">Flashing the X200 with a BeagleBone Black</h1>
		<aside>Initial flashing instructions for X200.</aside>
	</header>
	
	<p>
		This guide is for those who want libreboot on their ThinkPad X200
		while they still have the original Lenovo BIOS present. This guide
		can also be followed (adapted) if you brick your X200, to know how
		to recover.
	</p>
	
	<p>
		The X200S is also briefly covered (image showing soldering joints, wired up
		to a BBB). Note, the X200S and X200T are unsupported both in coreboot an libreboot at the time of writing (raminit doesn't work). This info
is just for future reference. <b>Only the X200 is supported.</b>
	</p>
	
	<p>
		Before following this section, please make sure to setup your libreboot ROM properly first. 
		Although ROM images are provided pre-built in libreboot, there are some modifications that 
		you need to make to the one you chose before flashing. (instructions referenced later in
		this guide)
	</p>

	<p>Or go <a href="index.html">back to main index</a></p>

<hr/>

	<h1 id="hardware_requirements">Hardware requirements</h1>
	
		<p>
			There are two possible flash chip sizes for the X200: 4MiB
			(32Mbit) or 8MiB (64Mbit). This can be identified by the type
			of flash chip below the palmrest: 4MiB is SOIC-8 (8 pins), 8MiB
			is SOIC-16 (16 pins). The X200S uses a WSON package and has the same
			pinout as SOIC-8 (covered briefly later on in this guide) but
			the chip is on the underside of the board (disassembly required).
		</p>
	
		<p>
			Shopping list (pictures of this hardware is shown later):
		</p>
			<ul>
				<li>
					External SPI programmer: <b>BeagleBone Black</b> (rev. C)
					is highly recommended. Sometimes referred to as 'BBB'.
				</li>
				<li>
					Clip for connecting to the flash chip: <b>Pomona 5250</b>
					(SOIC-8) or <b>Pomona 5250</b> (SOIC-16) is recommended
				</li>
				<li>
					<b>External 3.3V DC power supply</b>. The one used by this
					author has the label HF100W-SF-3.3 on it, but any decent
					supply will be fine. Some people use the 3.3V from an ATX
					PSU for instance (the kind that you get on a typical
					Intel/AMD desktop computer. 6A supply should be fine,
					the one used by this author is 20A (it won't actually use
					that, it's just what the PSU is capable of).
				</li>
				<li>
					Dupont <b>jumper cables</b> (the kinds of cables that you see 
					used on the pins on a raspberry pi - note: the pi is
					proprietary and not endorsed by libreboot, merely refered
					to in this instance to let you know the type of cables.
					You should get male-male, male-female and female-female
					cables in 10cm and 20cm sizes. 
				</li>
				<li>
					<b>Mini USB A-B cable</b> (the BeagleBone probably already comes
					with one.)
				</li>
				<li>
					<b>FTDI serial board</b>, for unbricking the BeagleBone if
					necessary.
				</li>
				<li>
					<b>5V DC power supply</b> (from wall outlet to the BeagleBone).
					The BeagleBone can have power supplied via USB, but a
					dedicated power supply is recommended. 
				</li>
			</ul>
	
		<p>
			<a href="#pagetop">Back to top of page.</a>
		</p>
		
<hr/>

	<h1 id="configure_bbb">Configuring the BeagleBone Black</h1>
	
		<h2>Setting up the 3.3V DC PSU</h2>
			<p>
				With my PSU, first I had wire up the mains power cable. Any clover or kettle lead will do. Cut the end off (not the one
				that goes in the wall, but the kettle/clover connector).
				Strip the protection away by a decent length, then strip the wires inside so that a decent amount of
				copper is shown. Then wire up earth/live/neutral. This will vary according to what country you live in
				and/or the colour codes that your cable uses inside. <b>Make sure to get this right, as a botched job
				could result in extreme damage to you and your surroundings. Here's what mine looks like after wiring up
				the power cable: <a href="images/x200/psu_power.jpg">images/x200/psu_power.jpg</a> - also, make sure
				that the plug (for the wall) has the correct fuse. In my case I had a 240V wall socket, and the device
				says that it accepts 1.5A at that voltage, so I used the smallest fuse available (3A). For 110-120V the device
				says it needs 2.8A.</b> Also, if yours looks like in the image linked above, make sure to wrap electrical tape (lots)
				around it for safety. (otherwise, don't touch the terminals while the PSU is plugged in).
			</p>
			<p>
				Now take a red and black 20cm female-female jumper lead, and cut one of the ends off. Strip away the bare copper by about 1 or
				1.5cm so you get this: <a href="images/x200/stripped_jumper_lead.jpg">images/x200/stripped_jumper_lead.jpg</a>. 
			</p>
			<p>
				Black goes on -V, red goes on +V. In my case, I removed those screws from my PSU like this:
				<a href="images/x200/psu_screws_removed.jpg">images/x200/psu_screws_removed.jpg</a>. Then,
			</p>
			<p>
				Then I twisted the exposed copper on the jumper leads (so that they don't fray), and wrapped each to one of the
				screws each, around it near the head. I then screwed them in:
				<a href="images/x200/psu_jumper_leads.jpg">images/x200/psu_jumper_leads.jpg</a>.
			</p>
			<p>
				If you are using a different PSU, then the steps will change from those above. Anyway, once you are satisfied,
				continue reading...
			</p>
		<h2>Setting up the BBB</h2>
			<p>
				Since it's a bare board (no case) and you are also touching inside your X200, you should be earthed/grounded. 
				<a href="images/x200/strap.jpg">images/x200/strap.jpg</a> shows how I earthed myself. This is to prevent you 
				from causing any ESD damage. The surface that you place components on should also be earthed/grounded.
				(for this, I used a shielded ESD bag with a wire, copper exposed, attached from the bag to the exposed metal
				part on a radiator, which was earthed - not professional, but it should work. see <a href="images/x200/mat.jpg">images/x200/mat.jpg</a>).
				Most people ignore this advice and don't ground/earth themselves, at their own risk. You should also store the BBB
				in a shielded anti-static bag when you are finished with it.
				(the principles above apply to any computer components, since they are extremely sensitive te ESD).
			</p>
			<p>
				These instructions may or may not work for you. They are simply the steps that this author took.
			</p>
			<p>
				setting up SPIDEV on the BBB: <a href="http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0">http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0</a>
				- If you only setup SPI0, you don't have to disable the HDMI out. (you only need one).
				That guide is for seting up the device overlay for SPIDEV, last part is to make it persist across reboots.
				Needed to turn the BBB into an SPI flasher.
			</p>
			<p>
				Don't bother modifying uEnv.txt. it won't work;
				use the workaround here instead: <a href="http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Loading_custom_capes">http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Loading_custom_capes</a>.
			</p>
			<p>
				Follow the instructions at <a href="http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0">http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0</a>
				up to (and excluding) the point where it tells you to modify uEnv.txt
			</p>
			<p>
				You need to update the software on the BBB first. Before being able to use apt-get,
				I had to use the workaround defined <a href="https://groups.google.com/forum/?_escaped_fragment_=msg/beagleboard/LPjCn4LEY2I/alozBGsbTJMJ#!msg/beagleboard/LPjCn4LEY2I/alozBGsbTJMJ">here</a>:<br/>
				- Replace the contents of /etc/init.d/led_aging.sh with:
			</p>
<pre>
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          led_aging.sh
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start LED aging
# Description:       Starts LED aging (whatever that is)
### END INIT INFO

x=$(/bin/ps -ef | /bin/grep "[l]ed_acc")
if [ ! -n "$x" -a -x /usr/bin/led_acc ]; then
    /usr/bin/led_acc &amp;
fi
</pre>
			</p>
				Run <b>apt-get update</b> and <b>apt-get upgrade</b> then reboot the BBB, before continuing.
			</p>
			<p>
				Run those commands:<br/>
				# <b>echo BB-SPI0-01 &gt; /sys/devices/bone_capemgr.*/slots</b><br/>
				Then I did:<br/>
				# <b>ls -al /dev/spidev0.*</b><br/>
				<i>ls: cannot access /dev/spidev0.*: No such file or directory</i><br/>
				Then I rebooted and did:<br/>
				# <b>cat /sys/devices/bone_capemgr.*/slots</b><br/>
				Output:
			</p>
<pre>
 0: 54:PF--- 
 1: 55:PF--- 
 2: 56:PF--- 
 3: 57:PF--- 
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
</pre>
			<p>
				And then:<br/>
				# <b>ls /lib/firmware/BB-SPI0-01-00A0.*</b><br/>
				Output:
			</p>
<pre>
/lib/firmware/BB-SPI0-01-00A0.dtbo
</pre>
			<p>
				Then:<br/>
				# <b>echo BB-SPI0-01 &gt; /sys/devices/bone_capemgr.*/slots</b><br/>
				# <b>cat /sys/devices/bone_capemgr.*/slots</b><br/>
				Output:
			</p>
<pre>
 0: 54:PF--- 
 1: 55:PF--- 
 2: 56:PF--- 
 3: 57:PF--- 
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
 7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI0-01
</pre>
			<p>
				Then check if the device exists:<br/>
				# <b>ls -al /dev/spidev0.*</b><br/>
				Output:
			</p>
<pre>
ls: cannot access /dev/spidev0.*: No such file or directory
</pre>
			<p>
				It didn't exist under that name, but I then did:<br/>
				# <b>ls -al /dev/spid*</b><br/>
				Output:
			</p>
<pre>
crw-rw---T 1 root spi 153, 0 Nov 19 21:07 /dev/spidev1.0
</pre>
			<p>
				Now the BBB is ready to be used for flashing. Make this persist
				across reboots:<br/>
				In /etc/default/capemgr add <b>CAPE=BB-SPI0-01</b> at the end
				(or change the existing <b>CAPE=</b> entry to say that, if an
				entry already exists.
			</p>
			<p>
				Now you will download and build <b>flashrom</b> on the BBB.<br/>
				# <b>apt-get install libpci-dev pciutils zlib1g-dev libftdi-dev build-essential subversion</b><br/>
				# <b>svn co svn://flashrom.org/flashrom/trunk flashrom</b><br/>
				# <b>cd flashrom/</b><br/>
				# <b>make</b>
			</p>
			
			<p>
				Now test flashrom:<br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512</b><br/>
				Output:
			</p>
<pre>
Calibrating delay loop... OK.
No EEPROM/flash device found.
Note: flashrom can never write if the flash chip isn't found automatically.
</pre>

			<p>
				This means that it's working (the clip isn't connected to any flash chip,
				so the error is fine).
			</p>
		<h2>
			Connecting the Pomona 5250/5252
		</h2>
			<p>
				Use this image for reference when connecting the pomona to the BBB:
				<a href="http://beagleboard.org/Support/bone101#headers">http://beagleboard.org/Support/bone101#headers</a>
				(D0 = MISO or connects to MISO).
			</p>
		
			<p>
				The following shows how to connect clip to the BBB	(on the P9 header), for SOIC-16 (clip: Pomona 5252):
			</p>
<pre>
===  front (display) ====
 NC              -       - 21
 1               -       - 17
 NC              -       - NC
 NC              -       - NC
 NC              -       - NC
 NC              -       - NC
 18              -       - 3.3V PSU RED
 22              -       - NC - this is pin 1 on the flash chip
===  back (palmrest) ===
<i>This is how you will connect. Numbers refer to pin numbers on the BBB, on the plugs near the DC jack.</i>
</pre>
			<p>
				The following shows how to connect clip to the BBB	(on the P9 header), for SOIC-8 (clip: Pomona 5250):
			</p>
<pre>
===  front (display) ====
 18              -       - 1
 22              -       - NC
 NC              -       - 21
 3.3V PSU RED    -       - 17 - this is pin 1 on the flash chip
===  back (palmrest) ===
<i>This is how you will connect. Numbers refer to pin numbers on the BBB, on the plugs near the DC jack.</i>
<b>On the X200S (not fully covered in this guide) the flash chip is underneath the board, in a WSON package. 
The pinout is very much the same as a SOIC-8, except you need to solder (there are no clips available). 
<a href="images/x200/wson_soldered.jpg">images/x200/wson_soldered.jpg</a> (image copyright (C) 2014 <a href="mailto:sgsit@libreboot.org">Steve Shenton</a> under CC-BY-SA 4.0
or higher, same license that this document uses) shows it wired (soldered) and
connected to a BBB. Note, the X200S and X200T are unsupported both in coreboot an libreboot at the time of writing (raminit doesn't work). This info
is just for future reference.</b>
</pre>
			<p>
				<b>NC = no connection</b>
			</p>
			<p>
				<b><u>DO NOT</u> connect 3.3V PSU RED yet. ONLY connect this once the pomona is connected to the flash chip.</b>
			</p>
			<p>
				<b>You also need to connect the BLACK wire from the 3.3V PSU to pin 2 on the BBB (P9 header). It is safe to install this now.</b>
			</p>
			<p>
				if you need to extend the 3.3v psu leads, just use the same colour M-F leads, <b>but</b> keep all other 
				leads short (10cm or less)
			</p>
			
			<p>
				<a href="images/x200/5252_bbb0.jpg">images/x200/5252_bbb0.jpg</a> and
				<a href="images/x200/5252_bbb1.jpg">images/x200/5252_bbb1.jpg</a> shows a properly wired up BBB with Pomona
				5252 before being connected to the flash chip on the X200.
			</p>
			
		<h2>
			Connect Pomona 5252/5250 to the X200 flash chip, and dump/flash
		</h2>
			<p>
				<a href="images/x200/x200_pomona.jpg">images/x200/x200_pomona.jpg</a>
				shows everything connected. In this picture, the X200 is being flashed
				with the BBB.
			</p>
			<p>
				Remove the battery from your X200, then remove all the screws on
				the bottom (underside) of the machine. Then remove the keyboard and palmrest. 
				The flash chip is below the palm rest. Lift back the tape that goes over it,
				and then connect your 5252/5250 (make sure to get it the right way round). 
				Then connect the 3.3v PSU wire (red one) and make sure that everything else is connected.
			</p>
			<p>
				I did:<br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512</b><br/>
				In my case, the output was:
			</p>
<pre>
flashrom v0.9.7-r1854 on Linux 3.8.13-bone47 (armv7l)
flashrom is free software, get the source code at http://www.flashrom.org
Calibrating delay loop... OK.
Found Macronix flash chip &quot;MX25L6405(D)&quot; (8192 kB, SPI) on linux_spi.
Found Macronix flash chip &quot;MX25L6406E/MX25L6436E&quot; (8192 kB, SPI) on linux_spi.
Found Macronix flash chip &quot;MX25L6445E/MX25L6473E&quot; (8192 kB, SPI) on linux_spi.
Multiple flash chip definitions match the detected chip(s): &quot;MX25L6405(D)&quot;, &quot;MX25L6406E/MX25L6436E&quot;, &quot;MX25L6445E/MX25L6473E&quot;
Please specify which chip definition to use with the -c &lt;chipname&gt; option.
</pre>
			<p>
				This is just to test that it's working. In my case, I had to define which chip to use, like so (in your case
				it may be different, depending on what flash chip you have):<br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -c &quot;MX25L6405(D)&quot;</b>
			</p>
			<p>
				At this point, you need to create a copy of the original lenovo firmware that is currently flashed. 
				This is so that you can extract the gbe (gigabit ethernet) and flash descriptor regions for use in libreboot. <b>These
				are not blobs, they only contain non-functional data (configuration details, fully readable) which is fully documented in public datasheets.</b>
				The descriptor will need to be modified
				to disable the ME (also disable AMT) so that you can flash a ROM that excludes it. 
			</p>
			<p>
				How to backup factory.rom (change the -c option as neeed, for your flash chip):<br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -c &quot;MX25L6405(D)&quot; -r factory.rom</b><br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -c &quot;MX25L6405(D)&quot; -r factory1.rom</b><br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -c &quot;MX25L6405(D)&quot; -r factory2.rom</b><br/>
				Now compare the 3 images:<br/>
				# <b>sha512sum factory*.rom</b><br/>
				If the hashes match, then just copy one of them (the factory.rom) to a safe place (on a drive connected to another machine, not
				the BBB). You will need it later for part of the deblobbing.
			</p>
			<p>
				Information about the descriptor and gbe can be found in the notes linked at
				<a href="../hcl/x200_remove_me.html">../hcl/x200_remove_me.html</a> - also shows how to modify them to disable and remove the ME/AMT blob.
				<span style="font-size:1.5em; background:#ccc;"><b><u><i>MAKE SURE TO FOLLOW THE GUIDE IN THIS LINK, BEFORE CONTINUING.
				FAILURE TO DO SO WILL RESULT IN A BRICKED MACHINE.</i></u></b></span>
			</p>
			<p>
				Assuming that your libreboot ROM image is properly setup (modified descriptor plus gbe region included in the ROM),
				then you can flash (assuming that the filename is <b>libreboot.rom</b>) for example I had to do:<br/>
				# <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512 -c &quot;MX25L6405(D)&quot; -w libreboot.rom</b>
			</p>
			<p>
				You might see errors, but if it says <b>Verifying flash... VERIFIED</b> at the end, then it's flashed and should boot.
				Test it! (boot your X200)
			</p>
			<p>
				My output when running the command above:
			</p>
<pre>
flashrom v0.9.7-r1854 on Linux 3.8.13-bone47 (armv7l)
flashrom is free software, get the source code at http://www.flashrom.org
Calibrating delay loop... OK.
Found Macronix flash chip "MX25L6405(D)" (8192 kB, SPI) on linux_spi.
Reading old flash chip contents... done.
Erasing and writing flash chip... FAILED at 0x00001000! Expected=0xff, Found=0x00, failed byte count from 0x00000000-0x0000ffff: 0xd716
ERASE FAILED!
Reading current flash chip contents... done. Looking for another erase function.
Erase/write done.
Verifying flash... VERIFIED.
</pre>
			
		<p>
			<a href="#pagetop">Back to top of page.</a>
		</p>

<hr/>

	<p>
		Copyright &copy; 2014 Francis Rowe &lt;info@gluglug.org.uk&gt;<br/>
		This document is released under the Creative Commons Attribution-ShareAlike 4.0 International Public License and all future versions.
		A copy of the license can be found at <a href="../license.txt">../license.txt</a>.
	</p>

	<p>
		This document is distributed in the hope that it will be useful,
		but WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See <a href="../license.txt">../license.txt</a> for more information.
	</p>

</body>
</html>