aboutsummaryrefslogtreecommitdiff
path: root/docs/install/bbb_setup.html
blob: 4bef441127d9a4c8188a6d4f59707bfe786afc5b (plain) (blame)
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
<!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>How to programme an SPI flash chip with the BeagleBone Black</title>
</head>

<body>

	<div class="section">
		<h1 id="pagetop">How to programme an SPI flash chip with the BeagleBone Black</h1>
			<p>
				This document exists as a guide for reading from or writing to an SPI flash chip with the BeagleBone Black,
				using the <a href="http://flashrom.org/Flashrom">flashrom</a> software. 
				BeagleBone Black rev. C was used when creating this guide, but earlier revisions
				may also work.
			</p>
			<p><a href="index.html">Back to previous index</a></p>
	</div>

	<div class="section" id="hardware_requirements">

		<h1>Hardware requirements</h1>
		
			<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'.
						<a href="http://beagleboard.org/black">This page</a> contains a list of distributors.
					</li>
					<li>
						Electrical tape: cover the entire bottom surface of the BBB (the part that
						rests on a surface). This is important, when placing the BBB on top of a board
						so that nothing shorts.
					</li>
					<li>
						Clip for connecting to the flash chip: if you have a SOIC-16
						flash chip (16 pins), you will need the <b>Pomona 5252</b>
						or equivalent. For SOIC-8 flash chips (8 pins), you will
						need the <b>Pomona 5250</b> or equivalent. Do check which chip you have,
						before ordering a clip. Also, make sure to buy at least two clips
						(they break easily).
					</li>
					<li>
						<b>External 3.3V DC power supply</b>, for powering the flash chip.
						An ATX power supply / PSU (common on Intel/AMD desktop computers) will work for this.
					</li>
					<li>
						<b>External 5V DC power supply</b>, for powering the BBB.
						The BeagleBone can have power supplied via USB, but a
						dedicated power supply is recommended. 
					</li>
					<li>
						<b>Pin header / jumper cables</b> (2.54mm / 0.1&quot; headers)
						You should get male-male, male-female and female-female
						cables in 10cm and 20cm sizes. Just get a load of them.
					</li>
					<li>
						<b>Mini USB A-B cable</b> (the BeagleBone probably already comes
						with one.)
					</li>
					<li>
						<b>FTDI TTL cable or debug board</b>, for accessing the serial console on your BBB.
						<a href="http://elinux.org/Beagleboard:BeagleBone_Black_Serial">This page</a> contains
						a list.
					</li>
				</ul>
		
			<p>
				<a href="#pagetop">Back to top of page.</a>
			</p>
			
	</div>
		
	<div class="section" id="psu33">

		<h1>Setting up the 3.3V DC PSU</h1>

			<p>
				ATX PSU pinouts are on <a href="https://en.wikipedia.org/wiki/Power_supply_unit_%28computer%29#Wiring_diagrams">wikipedia</a>
			</p>
			<p>
				On 20-pin ATX PSUs, you can use pin 1 or 2 (orange) for 3.3V, and any of the ground/earth sources (black cables).
				Short PS_ON# / Power on (green) to a ground (black. there is one right next to it) using a wire/paperclip/jumper then
				power on the PSU.
			</p>
			<p>
				On newer 24-pin ATX PSUs, there is an additional 3.3V (orange) on pin 12.
			</p>
			<p>
				You only need one 3.3V supply and one ground for the flash chip, after grounding PS_ON# to ground.
				Multiple 3.3V supplies means that you could theoretically power multiple flash chips at once with the
				same PSU.
			</p>
			
			<p>
				The male end of a 0.1&quot; or 2.54mm header cable is not thick enough to remain permanently
				connected to the ATX PSU on its own.
				When connecting header cables to the connector on the ATX PSU, use a female end attached to
				a thicker piece of wire (you could use a paper clip), or wedge the male end of the jumper cable
				into the sides of the hole in the connector, instead of going through the centre.
			</p>
			
			<p>
				Here is an example set up:<br/>
				<img src="images/x200/psu33.jpg" alt="" title="Copyright &copy; 2015 Patrick &quot;P. J.&quot; McDermott &lt;pj@pehjota.net&gt; CC BY-SA 3.0 or later" />
			</p>
			
	</div>
	
	<div class="section" id="bbb_access">
		
		<h1>Accessing the operating system on the BBB</h1>
			<p>
				The operating system on your BBB will probably have an SSH daemon
				running where the root account has no password. Use SSH to access
				the operating system and set a root password. By default, the OS
				on your BBB will most likely use DHCP, so it should already have an IP
				address.
			</p>
			<p>
				You will also be using the OS on your BBB for programming an SPI flash chip.
			</p>
			<h2>Alternatives to SSH (in case SSH fails)</h2>
				<p>
					You can also use a serial FTDI debug board with GNU Screen, to access the serial console.<br/>
					# <b>screen /dev/ttyUSB0 115200</b><br/>
					Here are some example photos:<br/>
					<img src="images/x200/ftdi.jpg" alt="" />
					<img src="images/x200/ftdi_port.jpg" alt="" /><br/>
				</p>
				<p>
					You can also connect the USB cable from the BBB to another computer and a new network interface will appear,
					with its own IP address. This is directly accessible from SSH, or screen:<br/>
					# <b>screen /dev/ttyACM0 115200</b>
				</p>
				<p>
					You can also access the uboot console, using the serial method
					instead of SSH.
				</p>
			
	</div>
	
	<div class="section" id="spidev">
		
		<h1>Setting up spidev on the BBB</h1>
		
			<p>
				Log on as root on the BBB, using either SSH or a serial console as defined in
				<a href="#bbb_access">#bbb_access</a>. Make sure that you have internet access
				on your BBB.
			</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. If you have an
				element14 brand BBB (sold by Premier Farnell plc. stores like
				Farnell element14, Newark element14, and Embest), you may need
				to <a href="https://groups.google.com/forum/?_escaped_fragment_=msg/beagleboard/LPjCn4LEY2I/alozBGsbTJMJ#!msg/beagleboard/LPjCn4LEY2I/alozBGsbTJMJ">work around a bug</a>
				in the LED aging init script before you can update your
				software. If you don't have a file named
				/etc/init.d/led_aging.sh, you can skip this step and update your
				software as described below. Otherwise, replace the contents of
				this file 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>
				Check that the firmware exists:<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>
				Verify that the spidev device now exists:<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>
				Get flashrom from the libreboot_util release archive, or build it from libreboot_src/git if you need to.
				An ARM binary (statically compiled) for flashrom exists in libreboot_util releases. Put the flashrom binary
				on your BBB.
			</p>
			<p>
				You may also need ich9gen, if you will be flashing an ICH9-M laptop (such as the X200). Get it from libreboot_util,
				or build it from libreboot_src, and put the ARM binary for it on your BBB.
			</p>
			<p>
				Finally, get the ROM image that you would like to flash and put that on your BBB.
			</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>
			
	</div>
	
	<div class="section" id="clip">
			
		<h1>
			Connecting the Pomona 5250/5252
		</h1>
			<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>
 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
<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>
 18              -       - 1
 22              -       - NC
 NC              -       - 21
 3.3V PSU RED    -       - 17 - this is pin 1 on the flash chip
<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>
				<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
				(that is, before you connect the pomona to the flash chip).</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>
				You should now have something that looks like this:<br/>
				<img src="images/x200/5252_bbb0.jpg" alt="" />
				<img src="images/x200/5252_bbb1.jpg" alt="" />
			</p>
			
		<p>
			<a href="#pagetop">Back to top of page.</a>
		</p>
		
	</div>
	
	<div class="section">
	
		<h1>EHCI debugging</h1>
		
			<p>
				Some libreboot systems lack serial ports, so you have to use the debug port (USB) instead.
				The BeagleBone can be configured for this. It may involve compiling a patched kernel.
			</p>
			
			<p>
				Work is in progress to implement this, and document it in libreboot. These are just some preliminary notes.
			</p>
			
			<p>
				<a href="www.coreboot.org/EHCI_Debug_Port">www.coreboot.org/EHCI_Debug_Port</a>
				<a href="www.coreboot.org/EHCI_Gadget_Debug">www.coreboot.org/EHCI_Gadget_Debug</a>
			</p>
			
<pre>
from #coreboot
&lt;tty0_&gt; stefanct,  1) plug the the BBB to a running system first and make sure you see it as "Netchip" (with lsusb).  if that is correct (i.e you have BBB > ver1 ) , you have to rebuild coreboot/libreboot with Net20DB instead of BBB as debug dongle
&lt;stefanct&gt; tty0_: the coreboot config is clear to me... it fails to show up in lsusb already
&lt;tty0_&gt; on BBB, unload all the modules, then modprobe g_dbgp
&lt;tty0_&gt; ... and when i siad lsusb, you do that on the target system, not on BBB

&lt;tty0_&gt; fchmmr, the kernel should be compiled with: CONFIG_EARLY_PRINTK_DBGP=y to output on EHCI debug: https://wiki.ubuntu.com/Kernel/Debugging/USBearlyprintk

&lt;tty0_&gt; stefanct, carldani: Note that the script has small bug in the last for loop:  for dev in &quot;$debug_dmesg_devs&quot;; do ...
&lt;stefanct&gt; tty0_: had ;)
&lt;stefanct&gt; carldani: ok that's what i was expecting, thanks
* ob-sed has quit (Ping timeout: 248 seconds)
&lt;tty0_&gt; On the wiki there are links to two scripts, the updated one has bug
&lt;tty0_&gt; $debug_dmesg_devs should not be quoted
&lt;tty0_&gt; ... if there are multiple controllers with debug, $dev will be assgined &lt;controller1 controller2&gt; instead of iterating throug each of them
&lt;stefanct&gt; i have seen your conversation with mtjm earlier
&lt;stefanct&gt; that's the reason why i was working on usb debug today at all :)
&lt;stefanct&gt; idwer: ping
&lt;carldani&gt; tty0_: indeed, this was a bug.
&lt;stefanct&gt; carldani: the most annoying thing about lsusb... the debug device is actually missing from lsusb -t as i have found out today
&lt;tty0_&gt; It shows only ports that have something attached to them, because of that you have to go with usb stick through all the ports and run the script each time
&lt;stefanct&gt; tty0_: lsusb without the -t shows the debug device... but doesnt print the port number

</pre>
	
	</div>

	<div class="section">

		<p>
			Copyright &copy; 2014, 2015 Francis Rowe &lt;info@gluglug.org.uk&gt;<br/>
			Copyright &copy; 2015 Patrick &quot;P. J.&quot; McDermott &lt;pj@pehjota.net&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>
		
	</div>

</body>
</html>