bbb_setup.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <style type="text/css">
  7. @import url('../css/main.css');
  8. </style>
  9. <title>Setup the BeagleBone Black as an SPI flashrom programmer</title>
  10. </head>
  11. <body>
  12. <div class="section">
  13. <h1 id="pagetop">Setup the BeagleBone Black as an SPI flashrom programmer</h1>
  14. <p>How to use the BBB as an external flashrom programmer, for reading/writing an SPI flash chip.</p>
  15. <p><a href="index.html">Back to previous index</a></p>
  16. </div>
  17. <div class="section">
  18. <h1 id="hardware_requirements">Hardware requirements</h1>
  19. <p>
  20. Shopping list (pictures of this hardware is shown later):
  21. </p>
  22. <ul>
  23. <li>
  24. External SPI programmer: <b>BeagleBone Black</b> (rev. C)
  25. is highly recommended. Sometimes referred to as 'BBB'.
  26. </li>
  27. <li>
  28. Clip for connecting to the flash chip: <b>Pomona 5250</b>
  29. (SOIC-8) or <b>Pomona 5252</b> (SOIC-16) is recommended
  30. (<b>X200S and X200 Tablet users will need a soldering iron
  31. instead</b>, because of the type of package the flash chip is
  32. in on those machines).
  33. </li>
  34. <li>
  35. <b>External 3.3V DC power supply</b>. The one used by this
  36. author has the label HF100W-SF-3.3 on it, but any decent
  37. supply will be fine. Some people use the 3.3V from an ATX
  38. PSU for instance (the kind that you get on a typical
  39. Intel/AMD desktop computer. 6A supply should be fine,
  40. the one used by this author is 20A (it won't actually use
  41. that, it's just what the PSU is capable of).
  42. </li>
  43. <li>
  44. Dupont <b>jumper cables</b> (2.54mm / 0.1&quot; headers)
  45. You should get male-male, male-female and female-female
  46. cables in 10cm and 20cm sizes. Just get a load of them.
  47. </li>
  48. <li>
  49. <b>Mini USB A-B cable</b> (the BeagleBone probably already comes
  50. with one.)
  51. </li>
  52. <li>
  53. <b>FTDI serial board</b>, for unbricking the BeagleBone if
  54. necessary.
  55. </li>
  56. <li>
  57. <b>5V DC power supply</b> (from wall outlet to the BeagleBone).
  58. The BeagleBone can have power supplied via USB, but a
  59. dedicated power supply is recommended.
  60. </li>
  61. </ul>
  62. <p>
  63. <a href="#pagetop">Back to top of page.</a>
  64. </p>
  65. </div>
  66. <div class="section">
  67. <h1>Setting up the 3.3V DC PSU</h1>
  68. <p>
  69. 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
  70. that goes in the wall, but the kettle/clover connector).
  71. Strip the protection away by a decent length, then strip the wires inside so that a decent amount of
  72. copper is shown. Then wire up earth/live/neutral. This will vary according to what country you live in
  73. and/or the colour codes that your cable uses inside. <b>Make sure to get this right, as a botched job
  74. could result in extreme damage to you and your surroundings. Here's what mine looks like after wiring up
  75. the power cable: <a href="images/x200/psu_power.jpg">images/x200/psu_power.jpg</a> - also, make sure
  76. that the plug (for the wall) has the correct fuse. In my case I had a 240V wall socket, and the device
  77. says that it accepts 1.5A at that voltage, so I used the smallest fuse available (3A). For 110-120V the device
  78. says it needs 2.8A.</b> Also, if yours looks like in the image linked above, make sure to wrap electrical tape (lots)
  79. around it for safety. (otherwise, don't touch the terminals while the PSU is plugged in).
  80. </p>
  81. <p>
  82. 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
  83. 1.5cm so you get this: <a href="images/x200/stripped_jumper_lead.jpg">images/x200/stripped_jumper_lead.jpg</a>.
  84. </p>
  85. <p>
  86. Black goes on -V, red goes on +V. In my case, I removed those screws from my PSU like this:
  87. <a href="images/x200/psu_screws_removed.jpg">images/x200/psu_screws_removed.jpg</a>. Then,
  88. </p>
  89. <p>
  90. Then I twisted the exposed copper on the jumper leads (so that they don't fray), and wrapped each to one of the
  91. screws each, around it near the head. I then screwed them in:
  92. <a href="images/x200/psu_jumper_leads.jpg">images/x200/psu_jumper_leads.jpg</a>.
  93. </p>
  94. <p>
  95. If you are using a different PSU, then the steps will change from those above. Anyway, once you are satisfied,
  96. continue reading...
  97. </p>
  98. </div>
  99. <div class="section">
  100. <h1>Setting up the BBB</h1>
  101. <p>
  102. Your BBB will have an sshd with no password on root. Find it's IP address
  103. (it will use DHCP by default) and set a root password. The steps below
  104. are done while SSH'd into a BBB.
  105. </p>
  106. <p>
  107. You can also use a serial FTDI debug board, with GNU Screen (example):<br/>
  108. # <b>screen /dev/ttyUSB0 115200</b><br/>
  109. <a href="images/x200/ftdi.jpg">images/x200/ftdi.jpg</a> and
  110. <a href="images/x200/ftdi_port.jpg">images/x200/ftdi_port.jpg</a>
  111. show an FTDI debug board in use. With screen you can then login as root, like you would using SSH.<br/>
  112. Using this, you can also see text output (from kernel, etc) when booting the machine.
  113. </p>
  114. <p>
  115. You can also simply connect the USB cable from the BBB to another computer and a new network interface will appear,
  116. with it's own IP address: this is the BBB. You can SSH into that. Or, you can (example):<br/>
  117. # <b>screen /dev/ttyACM0 115200</b>
  118. </p>
  119. <p>
  120. Since it's a bare board (no case) and you are also touching inside your X200, you should be earthed/grounded.
  121. <a href="images/x200/strap.jpg">images/x200/strap.jpg</a> shows how I earthed myself. This is to prevent you
  122. from causing any ESD damage. The surface that you place components on should also be earthed/grounded.
  123. (for this, I used a shielded ESD bag with a wire, copper exposed, attached from the bag to the exposed metal
  124. 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>).
  125. Most people ignore this advice and don't ground/earth themselves, at their own risk. You should also store the BBB
  126. in a shielded anti-static bag when you are finished with it.
  127. (the principles above apply to any computer components, since they are extremely sensitive te ESD).
  128. </p>
  129. <p>
  130. These instructions may or may not work for you. They are simply the steps that this author took.
  131. </p>
  132. <p>
  133. 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>
  134. - If you only setup SPI0, you don't have to disable the HDMI out. (you only need one).
  135. That guide is for seting up the device overlay for SPIDEV, last part is to make it persist across reboots.
  136. Needed to turn the BBB into an SPI flasher.
  137. </p>
  138. <p>
  139. Don't bother modifying uEnv.txt. it won't work;
  140. 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>.
  141. </p>
  142. <p>
  143. Follow the instructions at <a href="http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0">http://elinux.org/BeagleBone_Black_Enable_SPIDEV#SPI0</a>
  144. up to (and excluding) the point where it tells you to modify uEnv.txt
  145. </p>
  146. <p>
  147. You need to update the software on the BBB first. Before being able to use apt-get,
  148. 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/>
  149. - Replace the contents of /etc/init.d/led_aging.sh with:
  150. </p>
  151. <pre>
  152. #!/bin/sh -e
  153. ### BEGIN INIT INFO
  154. # Provides: led_aging.sh
  155. # Required-Start: $local_fs
  156. # Required-Stop: $local_fs
  157. # Default-Start: 2 3 4 5
  158. # Default-Stop: 0 1 6
  159. # Short-Description: Start LED aging
  160. # Description: Starts LED aging (whatever that is)
  161. ### END INIT INFO
  162. x=$(/bin/ps -ef | /bin/grep "[l]ed_acc")
  163. if [ ! -n "$x" -a -x /usr/bin/led_acc ]; then
  164. /usr/bin/led_acc &amp;
  165. fi
  166. </pre>
  167. </p>
  168. Run <b>apt-get update</b> and <b>apt-get upgrade</b> then reboot the BBB, before continuing.
  169. </p>
  170. <p>
  171. Run those commands:<br/>
  172. # <b>echo BB-SPI0-01 &gt; /sys/devices/bone_capemgr.*/slots</b><br/>
  173. Then I did:<br/>
  174. # <b>ls -al /dev/spidev0.*</b><br/>
  175. <i>ls: cannot access /dev/spidev0.*: No such file or directory</i><br/>
  176. Then I rebooted and did:<br/>
  177. # <b>cat /sys/devices/bone_capemgr.*/slots</b><br/>
  178. Output:
  179. </p>
  180. <pre>
  181. 0: 54:PF---
  182. 1: 55:PF---
  183. 2: 56:PF---
  184. 3: 57:PF---
  185. 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
  186. 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
  187. </pre>
  188. <p>
  189. And then:<br/>
  190. # <b>ls /lib/firmware/BB-SPI0-01-00A0.*</b><br/>
  191. Output:
  192. </p>
  193. <pre>
  194. /lib/firmware/BB-SPI0-01-00A0.dtbo
  195. </pre>
  196. <p>
  197. Then:<br/>
  198. # <b>echo BB-SPI0-01 &gt; /sys/devices/bone_capemgr.*/slots</b><br/>
  199. # <b>cat /sys/devices/bone_capemgr.*/slots</b><br/>
  200. Output:
  201. </p>
  202. <pre>
  203. 0: 54:PF---
  204. 1: 55:PF---
  205. 2: 56:PF---
  206. 3: 57:PF---
  207. 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
  208. 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
  209. 7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPI0-01
  210. </pre>
  211. <p>
  212. Then check if the device exists:<br/>
  213. # <b>ls -al /dev/spidev0.*</b><br/>
  214. Output:
  215. </p>
  216. <pre>
  217. ls: cannot access /dev/spidev0.*: No such file or directory
  218. </pre>
  219. <p>
  220. It didn't exist under that name, but I then did:<br/>
  221. # <b>ls -al /dev/spid*</b><br/>
  222. Output:
  223. </p>
  224. <pre>
  225. crw-rw---T 1 root spi 153, 0 Nov 19 21:07 /dev/spidev1.0
  226. </pre>
  227. <p>
  228. Now the BBB is ready to be used for flashing. Make this persist
  229. across reboots:<br/>
  230. In /etc/default/capemgr add <b>CAPE=BB-SPI0-01</b> at the end
  231. (or change the existing <b>CAPE=</b> entry to say that, if an
  232. entry already exists.
  233. </p>
  234. <p>
  235. Now you will download and build <b>flashrom</b> on the BBB.<br/>
  236. # <b>apt-get install libpci-dev pciutils zlib1g-dev libftdi-dev build-essential subversion</b><br/>
  237. # <b>svn co svn://flashrom.org/flashrom/trunk flashrom</b><br/>
  238. # <b>cd flashrom/</b><br/>
  239. # <b>make</b>
  240. </p>
  241. <p>
  242. Now test flashrom:<br/>
  243. # <b>./flashrom -p linux_spi:dev=/dev/spidev1.0,spispeed=512</b><br/>
  244. Output:
  245. </p>
  246. <pre>
  247. Calibrating delay loop... OK.
  248. No EEPROM/flash device found.
  249. Note: flashrom can never write if the flash chip isn't found automatically.
  250. </pre>
  251. <p>
  252. This means that it's working (the clip isn't connected to any flash chip,
  253. so the error is fine).
  254. </p>
  255. </div>
  256. <div class="section">
  257. <h1>
  258. Connecting the Pomona 5250/5252
  259. </h1>
  260. <p>
  261. Use this image for reference when connecting the pomona to the BBB:
  262. <a href="http://beagleboard.org/Support/bone101#headers">http://beagleboard.org/Support/bone101#headers</a>
  263. (D0 = MISO or connects to MISO).
  264. </p>
  265. <p>
  266. The following shows how to connect clip to the BBB (on the P9 header), for SOIC-16 (clip: Pomona 5252):
  267. </p>
  268. <pre>
  269. NC - - 21
  270. 1 - - 17
  271. NC - - NC
  272. NC - - NC
  273. NC - - NC
  274. NC - - NC
  275. 18 - - 3.3V PSU RED
  276. 22 - - NC - this is pin 1 on the flash chip
  277. <i>This is how you will connect. Numbers refer to pin numbers on the BBB, on the plugs near the DC jack.</i>
  278. </pre>
  279. <p>
  280. The following shows how to connect clip to the BBB (on the P9 header), for SOIC-8 (clip: Pomona 5250):
  281. </p>
  282. <pre>
  283. 18 - - 1
  284. 22 - - NC
  285. NC - - 21
  286. 3.3V PSU RED - - 17 - this is pin 1 on the flash chip
  287. <i>This is how you will connect. Numbers refer to pin numbers on the BBB, on the plugs near the DC jack.</i>
  288. </pre>
  289. <p>
  290. <b>NC = no connection</b>
  291. </p>
  292. <p>
  293. <b><u>DO NOT</u> connect 3.3V PSU RED yet. ONLY connect this once the pomona is connected to the flash chip.</b>
  294. </p>
  295. <p>
  296. <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
  297. (that is, before you connect the pomona to the flash chip).</b>
  298. </p>
  299. <p>
  300. if you need to extend the 3.3v psu leads, just use the same colour M-F leads, <b>but</b> keep all other
  301. leads short (10cm or less)
  302. </p>
  303. <p>
  304. <a href="images/x200/5252_bbb0.jpg">images/x200/5252_bbb0.jpg</a> and
  305. <a href="images/x200/5252_bbb1.jpg">images/x200/5252_bbb1.jpg</a> shows a properly wired up BBB with Pomona
  306. 5252 before being connected to the flash chip on the X200.
  307. </p>
  308. <p>
  309. That's basically it. Now refer back to the documentation for how to use this on your board.
  310. </p>
  311. <p>
  312. <a href="#pagetop">Back to top of page.</a>
  313. </p>
  314. </div>
  315. <div class="section">
  316. <p>
  317. Copyright &copy; 2014, 2015 Francis Rowe &lt;info@gluglug.org.uk&gt;<br/>
  318. This document is released under the Creative Commons Attribution-ShareAlike 4.0 International Public License and all future versions.
  319. A copy of the license can be found at <a href="../license.txt">../license.txt</a>.
  320. </p>
  321. <p>
  322. This document is distributed in the hope that it will be useful,
  323. but WITHOUT ANY WARRANTY; without even the implied warranty of
  324. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See <a href="../license.txt">../license.txt</a> for more information.
  325. </p>
  326. </div>
  327. </body>
  328. </html>