1 00:00:00,000 --> 00:00:07,200 I'm Abend. This is David. I'm Dave or non-sequitur. We're talking about 2 00:00:07,200 --> 00:00:13,820 hardware hacking and this talk is really for the people that have written software before 3 00:00:13,820 --> 00:00:18,700 but haven't really worked directly with hardware. So if you've never written a bare board app 4 00:00:18,700 --> 00:00:24,120 or something without an operating system or read a schematic to figure out how exactly 5 00:00:24,120 --> 00:00:25,960 to write your software, then you're in the right place. 6 00:00:25,960 --> 00:00:30,960 Our motivation for the talk was to encourage people to get into hardware hacking. 7 00:00:31,420 --> 00:00:36,700 It's something that we've seen as an increasing trend. Make Magazine coming out. It's an increasing 8 00:00:36,700 --> 00:00:42,460 trend in the hobby market that is the do-it-yourself ethic and growth of improving your own devices, 9 00:00:42,540 --> 00:00:47,000 whereas there's a contrary trend in the industry to produce devices that are more and more 10 00:00:47,000 --> 00:00:52,800 restricted. So we're hopefully going to get at least, if we get one person to open up 11 00:00:52,800 --> 00:00:55,940 their TiVo or whatever and improve it, then we'd call it a success. 12 00:00:55,940 --> 00:00:58,680 I suspect most of you probably already did that, though. 13 00:01:09,160 --> 00:01:15,620 We're going to cover building a lab, tools that you can build yourself, where to get 14 00:01:15,620 --> 00:01:21,940 some useful tools, and the forward engineering and reverse engineering processes in kind 15 00:01:21,940 --> 00:01:25,920 of a general overview. We don't have sufficient time. 16 00:01:25,940 --> 00:01:27,300 We don't have sufficient time to get into every detail of everything. 17 00:01:28,920 --> 00:01:33,060 The reason we're calling it forward engineering is more to distinguish it from reverse engineering. 18 00:01:33,540 --> 00:01:39,180 It's really just embedded engineering in general. I'm going to go through pretty much what you 19 00:01:39,180 --> 00:01:45,520 need in your lab and how to get started with starting your own do-it-yourself projects, 20 00:01:45,680 --> 00:01:49,760 whether it be robotics or some random microcontroller somewhere that you want to load code onto, 21 00:01:49,960 --> 00:01:53,620 and just sort of how to design a program for it. 22 00:01:53,620 --> 00:01:58,440 My focus has been on the tools, especially making them cheap, because I'm a cheapskate. 23 00:01:58,560 --> 00:02:01,880 And back when I was a college student, I didn't have a lot of money, so it was good to get 24 00:02:02,620 --> 00:02:07,820 what you need without blowing $1,000, $1,500, $2,000, $10,000, however much money you 25 00:02:07,820 --> 00:02:09,080 want to spend on electronic test equipment. 26 00:02:09,940 --> 00:02:14,600 A normal setup in any sort of industry lab is going to cost anywhere between $30,000 27 00:02:14,600 --> 00:02:16,480 to $100,000 starting. 28 00:02:17,360 --> 00:02:18,540 So we hope to avoid that. 29 00:02:18,780 --> 00:02:19,060 Yeah. 30 00:02:20,680 --> 00:02:21,980 Make it a little bit more accessible. 31 00:02:22,360 --> 00:02:23,600 For the basic requirements, it's going to take a little bit more time. It's going to take a little bit more time. 32 00:02:23,600 --> 00:02:27,980 So, first of all, why would you want your own lab, as opposed to, say, doing it on your dining room table? 33 00:02:28,300 --> 00:02:32,680 The main reason that I found, now that I actually have a lab in the place that I live, is continuity. 34 00:02:32,980 --> 00:02:36,540 I can set things down, come back to them later, and it's just as I left it. 35 00:02:36,580 --> 00:02:41,040 Nothing's had to been shoved out of the way for dinner or got knocked on the floor by the cat or anything like that. 36 00:02:42,220 --> 00:02:45,040 And it provides a certain space where you can get into a mindset. 37 00:02:45,320 --> 00:02:51,900 You get used to, you go into your lab and you focus, and you don't get that when you don't have a dedicated space. 38 00:02:52,580 --> 00:02:54,760 You don't really require a huge amount of space. 39 00:02:55,040 --> 00:03:02,520 I grew up in a 12 by 12 bedroom and basically started there for years, and that was sufficient. 40 00:03:02,820 --> 00:03:09,000 Right now I have a basement that's about 15 by 30, and that's still sufficient. 41 00:03:09,140 --> 00:03:10,280 It's mostly just storage. 42 00:03:12,920 --> 00:03:17,280 Well, in addition to the space, it's also very important how you set up the space. 43 00:03:17,420 --> 00:03:21,340 So if you have a table like this one here, you're not going to want to put any electronics on it, 44 00:03:21,340 --> 00:03:23,080 because this is a tablecloth. 45 00:03:23,420 --> 00:03:28,480 And I'm sure half of you in here have heard of ESD, electrostatic discharge. 46 00:03:29,320 --> 00:03:36,400 You won't know if ESD has damaged your device unless you hit the lottery, and basically it makes it not work at all. 47 00:03:36,720 --> 00:03:41,840 And most ESD damage to any sort of circuitry, you're not going to know about for months. 48 00:03:42,280 --> 00:03:47,120 And then just one feature, or it might be cascading failures down the line. 49 00:03:47,260 --> 00:03:49,160 But it can be... 50 00:03:49,160 --> 00:03:51,320 It's the cause of a lot of... 51 00:03:51,320 --> 00:03:52,160 It's the cause of a lot of things not working. 52 00:03:52,320 --> 00:03:58,120 And it's nice to have that control so you know it's not your equipment, it's your software or whatever. 53 00:03:58,660 --> 00:04:03,580 So you know that you've reduced a number of variables from getting a hack working. 54 00:04:05,000 --> 00:04:13,900 So one way to start is an ESD mat and some grounding bracelets and maybe a coat if you've got cats or whatnot. 55 00:04:14,060 --> 00:04:19,640 Because even if you've got fur on the outside of the coat, it's a material that's going to keep the static from building up on the fur. 56 00:04:19,640 --> 00:04:21,980 And not going to short your devices. 57 00:04:22,180 --> 00:04:25,820 So the coats are actually fairly useful, especially if you have pets. 58 00:04:26,600 --> 00:04:29,260 Other basic stuff to look for in a lab is good ventilation. 59 00:04:29,740 --> 00:04:30,460 There's a lot of... 60 00:04:30,460 --> 00:04:33,000 Hobby Electronics entails a lot of semi-dangerous chemicals. 61 00:04:33,180 --> 00:04:37,120 I work with lead solder because it's actually better than the safer non-lead kind. 62 00:04:37,320 --> 00:04:38,140 It just wets better. 63 00:04:39,280 --> 00:04:40,600 The fumes from that are unpleasant. 64 00:04:40,840 --> 00:04:43,480 The fumes from etching your own circuit boards are very unpleasant. 65 00:04:43,780 --> 00:04:47,360 You've got to keep your lungs in good shape or you're not going to be doing this for very long. 66 00:04:48,560 --> 00:04:49,560 Lighting is also key. 67 00:04:50,320 --> 00:04:53,880 Basically, the brighter your lights are, the better your eyes' resolving power is. 68 00:04:54,000 --> 00:04:55,220 It's just a matter of having small pupils. 69 00:04:57,120 --> 00:04:58,820 Work surfaces and grounding we've covered. 70 00:04:59,840 --> 00:05:00,880 Just very basic. 71 00:05:01,260 --> 00:05:08,380 I mean, it sounds like a lot, but I have a basement, I have a little fume hood, and I have a countertop that has a conductive mat over it. 72 00:05:08,580 --> 00:05:09,460 And that's all it takes. 73 00:05:12,020 --> 00:05:14,560 Soldering is a very basic skill if you're going to get into this field. 74 00:05:14,760 --> 00:05:15,860 It's the process... 75 00:05:15,860 --> 00:05:17,680 How many people actually know what soldering is? 76 00:05:17,740 --> 00:05:18,880 I don't want to be talking down to anybody. 77 00:05:19,640 --> 00:05:20,820 Yeah, okay, so everybody knows what it is. 78 00:05:21,480 --> 00:05:28,600 How many people in here have soldered on a modern PCB layout, which is fairly tightly packed? 79 00:05:28,980 --> 00:05:29,360 Right. 80 00:05:29,540 --> 00:05:33,140 So I see about half the people raising their hands than before. 81 00:05:33,600 --> 00:05:37,600 And one of the important things is having the right solder and the right iron. 82 00:05:37,720 --> 00:05:46,840 Because if you use solder that's too thick, or an iron that has a bad tip, or too hot, you're going to ruin whatever you're working on. 83 00:05:46,980 --> 00:05:49,560 So getting very thin silver solder. 84 00:05:50,560 --> 00:05:59,360 And very fine tip and good working temperature is going to help you minimize the amount of time you apply heat to the board. 85 00:05:59,620 --> 00:06:05,040 And the amount of solder that you use so you don't accidentally short things with big globs of solder. 86 00:06:05,320 --> 00:06:09,900 And I'm probably not the only one that ruined a few boards learning that the hard way. 87 00:06:11,160 --> 00:06:17,020 How many of you have added the accelerometer or the Zigbee chip to the boards? 88 00:06:17,860 --> 00:06:20,640 Oh yeah, I see two... 89 00:06:21,640 --> 00:06:22,500 Oh, three. 90 00:06:22,800 --> 00:06:23,720 Three people. 91 00:06:24,300 --> 00:06:25,880 How hard was soldering that? 92 00:06:26,500 --> 00:06:28,200 A little bit tricky? Very small pins? 93 00:06:29,120 --> 00:06:37,520 There's an increasing trend with electronics towards miniaturization and also towards packages that are not really designed to be soldered by hand anymore. 94 00:06:38,480 --> 00:06:46,780 Probably the epitome of this is the ball grid array package where there are solder points underneath the chip that you simply can't reach with any kind of human hand. 95 00:06:47,020 --> 00:06:58,600 There are however people who have been working with these chips in prototype and hobbyist environments and have come up with some pretty clever tricks for overcoming the limits of what a human being can solder. 96 00:07:00,360 --> 00:07:10,580 Toaster oven reflow soldering, skillet reflow soldering, and hot air tools are the three ways you're going to deal with anything basically smaller than the chips that you saw on the badges. 97 00:07:11,100 --> 00:07:16,140 The industrial equivalent to that is wave soldering where you've got a whole wave of solder. 98 00:07:16,140 --> 00:07:23,060 Kind of like the wave coming out of an aerator in a fish tank where they've got a special coating on everywhere where the solder is supposed to stick. 99 00:07:23,260 --> 00:07:27,960 And that's how they put all the parts for the assembly on top of the PCB when the board is ready. 100 00:07:29,980 --> 00:07:37,020 Reflow soldering is a process that uses powdered solder and flux to basically act as... 101 00:07:37,020 --> 00:07:41,000 It binds the chips to the board temporarily and then the whole board is baked. 102 00:07:41,460 --> 00:07:44,780 The flux burns off cleaning the parts and then the solder melts. 103 00:07:45,020 --> 00:07:45,460 And... 104 00:07:46,140 --> 00:07:46,940 And that's how it's fixed as a part of the board. 105 00:07:48,360 --> 00:07:57,200 Usually a commercial IR reflow oven is a 2000 to many tens of thousands device depending on controllability and also how many boards you can put through it. 106 00:07:57,440 --> 00:08:00,260 The toaster oven reflow is a little simpler. 107 00:08:00,820 --> 00:08:01,860 People actually do this. 108 00:08:02,040 --> 00:08:05,940 They do not do it with the toaster ovens that they eat from if they have any brains at all. 109 00:08:07,240 --> 00:08:10,660 And if they do do it with the toaster oven they eat from, they won't have any brains at all soon. 110 00:08:12,240 --> 00:08:14,500 You can get kits to control the temperature of an oven. 111 00:08:14,500 --> 00:08:18,680 Because the typical reflow is not simply ramp the heat up and bring it back down. 112 00:08:19,440 --> 00:08:23,180 They usually ramp up, hold steady to melt the solder, 113 00:08:23,720 --> 00:08:28,480 peak to melt anything that had a very big pad that it was being soldered to or had a very large piece of metal, 114 00:08:28,640 --> 00:08:33,580 and then drop off quickly to cool everything in place before any vibration knocks any parts loose. 115 00:08:34,520 --> 00:08:36,560 You could also just do this by twiddling the thing. 116 00:08:36,680 --> 00:08:38,960 I've led to believe it is not terribly precise. 117 00:08:40,780 --> 00:08:43,740 The one place that it would fail is a double-sided surface mount board, 118 00:08:43,740 --> 00:08:44,560 like these. 119 00:08:44,800 --> 00:08:48,680 If you were to throw this in the oven to try to solder something on the side of the batteries, 120 00:08:48,860 --> 00:08:52,000 you would lose all your LEDs and be saddened. 121 00:08:54,900 --> 00:08:56,620 Skillet reflow, same trick. 122 00:08:56,880 --> 00:08:59,200 It's just for one-sided boards only. 123 00:08:59,400 --> 00:09:00,800 Works very well for surface mount. 124 00:09:01,440 --> 00:09:06,360 And is a whole $30 if you buy the skillet new in terms of parts investment, 125 00:09:06,600 --> 00:09:07,320 which is hard to beat. 126 00:09:09,760 --> 00:09:12,280 These pictures actually came from sparkfund.com, 127 00:09:12,280 --> 00:09:14,920 which is a site that has some fantastic tutorials on doing this, 128 00:09:15,060 --> 00:09:18,540 and supplies a lot of the useful parts for this sort of trickery. 129 00:09:22,520 --> 00:09:24,880 This is a home-built hot air pencil. 130 00:09:25,160 --> 00:09:27,360 You can get hot air guns pretty easily. 131 00:09:27,520 --> 00:09:30,840 They're just 1,000 degree, or, well, temperature controlled, 132 00:09:30,840 --> 00:09:34,160 but usually 6 to 1,500, 6,000 to, bleh. 133 00:09:34,660 --> 00:09:35,660 I can talk, really. 134 00:09:36,700 --> 00:09:41,080 600 to, say, 1,600 degree stream of air, 135 00:09:41,080 --> 00:09:42,160 capable of melting solder. 136 00:09:42,660 --> 00:09:44,600 This is useful for when you're working with, 137 00:09:45,120 --> 00:09:47,620 when you're trying to rework a surface mount board. 138 00:09:47,840 --> 00:09:50,660 You just apply the heat, heat up all the pins of the chip at once, 139 00:09:50,660 --> 00:09:51,980 and you can just lift it off with tweezers, 140 00:09:52,800 --> 00:09:56,480 which is a lot better than trying to get each pin a single one at a time with a soldering iron. 141 00:09:57,300 --> 00:10:00,500 Another type of hot air gun is for a completely different purpose, 142 00:10:00,620 --> 00:10:05,220 but they've got these wire sleeves that shrink around connections 143 00:10:05,720 --> 00:10:09,780 for if you're putting sleeves to attach a wire to a pin. 144 00:10:09,780 --> 00:10:12,440 You don't actually need a hot air gun for those. 145 00:10:12,500 --> 00:10:15,760 You can just take a big lighter and shrink it to the wire that way 146 00:10:15,760 --> 00:10:20,640 without spending 90 bucks on an overpowered hair dryer. 147 00:10:24,160 --> 00:10:30,580 These are some basic tools that I use in doing hardware work. 148 00:10:32,700 --> 00:10:34,280 The voltometer is basic. 149 00:10:34,520 --> 00:10:37,620 If you don't have one of these, chances are you're not really doing a lot of electronics. 150 00:10:38,740 --> 00:10:39,620 An oscilloscope. 151 00:10:39,780 --> 00:10:44,980 A little less basic, but if you get one, you will not believe how useful it is. 152 00:10:45,580 --> 00:10:47,740 You'll never really remember how you live without it. 153 00:10:48,560 --> 00:10:52,180 Logic probes and logic analyzers are both for working with digital logic only, 154 00:10:52,320 --> 00:10:55,380 and are, well, a logic analyzer is a little expensive. 155 00:10:55,580 --> 00:10:56,500 A logic probe is very simple. 156 00:10:57,140 --> 00:10:57,900 I'm going to go through these. 157 00:10:59,900 --> 00:11:01,400 Voltometers come in two basic types. 158 00:11:01,560 --> 00:11:03,960 That's a digital one, as you can tell by the LCD display. 159 00:11:04,080 --> 00:11:06,720 There's also analog ones that have an actual meter movement. 160 00:11:07,520 --> 00:11:09,760 The only real reason I can think of to go with analog ones 161 00:11:09,780 --> 00:11:13,220 and somebody who's been in the field longer than me probably knows better, 162 00:11:13,340 --> 00:11:16,780 is that if you hook it up to AC, you'll be able to tell. 163 00:11:16,860 --> 00:11:18,160 The meter will actually vibrate. 164 00:11:19,320 --> 00:11:20,740 Otherwise, these are fantastic. 165 00:11:21,280 --> 00:11:24,280 The basic ones, you'll just get ohms, volts, 166 00:11:24,440 --> 00:11:27,420 you measure resistance and voltage, current, 167 00:11:28,260 --> 00:11:29,980 usually a diode or continuity check. 168 00:11:30,720 --> 00:11:32,360 You can get all sorts of crazy features. 169 00:11:32,920 --> 00:11:34,180 Capacitance meters are pretty common. 170 00:11:34,340 --> 00:11:36,560 Some of them have temperature sensors via thermocouples, 171 00:11:36,640 --> 00:11:38,860 which are useful for controlling your toaster oven. 172 00:11:40,200 --> 00:11:41,240 No contact voltage? 173 00:11:42,100 --> 00:11:43,200 No contact voltage. 174 00:11:43,340 --> 00:11:45,860 Oh, yes, clamp meters for going around something 175 00:11:45,860 --> 00:11:47,040 that you believe to be carrying a current 176 00:11:47,040 --> 00:11:48,980 that can pick up the current by induction. 177 00:11:51,760 --> 00:11:54,640 Another useful use for an analog oscilloscope 178 00:11:54,640 --> 00:11:57,060 is when you're debugging your PCB layouts 179 00:11:57,760 --> 00:11:59,620 and you're looking for EMI, 180 00:11:59,760 --> 00:12:01,640 which might be affecting the operation, 181 00:12:01,880 --> 00:12:03,420 so you don't know why it doesn't work, 182 00:12:03,520 --> 00:12:06,040 and you've double-checked your logic 15 times, 183 00:12:06,160 --> 00:12:08,720 you might find that your interference from, say, 184 00:12:08,720 --> 00:12:10,380 your power supply part of the board 185 00:12:10,380 --> 00:12:12,880 is coming in on your analog inputs 186 00:12:13,580 --> 00:12:17,220 and it's not properly isolated with the grounding 187 00:12:17,220 --> 00:12:19,060 and the components are too close 188 00:12:19,060 --> 00:12:20,960 and you might get some signal leakage 189 00:12:20,960 --> 00:12:23,080 even though the traces are isolated, 190 00:12:23,260 --> 00:12:25,220 but they're just too close on the board. 191 00:12:25,360 --> 00:12:27,860 So that will show you whether or not your levels, 192 00:12:27,960 --> 00:12:29,740 what exactly is on that wire 193 00:12:29,740 --> 00:12:32,760 and what is on all the other spots 194 00:12:32,760 --> 00:12:34,800 without having to guess. 195 00:12:35,400 --> 00:12:37,200 How many people know what an oscilloscope does? 196 00:12:40,160 --> 00:12:43,040 It's basically a graphic plot of voltage over time. 197 00:12:44,440 --> 00:12:47,160 Most basic models will have usually two channels 198 00:12:47,160 --> 00:12:48,240 that they can display simultaneously. 199 00:12:50,340 --> 00:12:51,620 Analog ones look like this 200 00:12:51,620 --> 00:12:53,180 and have an actual cathode ray tube. 201 00:12:53,640 --> 00:12:55,940 Digital ones have usually an LCD screen 202 00:12:55,940 --> 00:12:57,120 and are usually a lot smaller, 203 00:12:57,180 --> 00:12:58,940 especially shallower, basically. 204 00:13:00,140 --> 00:13:01,960 You can build your own oscilloscope, 205 00:13:02,040 --> 00:13:04,560 but chances are the bandwidth is not going to be fantastic. 206 00:13:05,040 --> 00:13:06,700 It'll probably be good for audio work, 207 00:13:06,840 --> 00:13:08,580 possibly for some TV work, 208 00:13:08,720 --> 00:13:10,900 but you'll start to lose it around RF 209 00:13:10,900 --> 00:13:14,180 and it certainly won't do 100 MHz buses 210 00:13:14,180 --> 00:13:17,240 on modern microprocessors. 211 00:13:19,780 --> 00:13:21,940 Buying them can be expensive if you're getting them new. 212 00:13:23,160 --> 00:13:24,160 Secondhand ones are good 213 00:13:24,600 --> 00:13:26,360 if you can make sure that it's working. 214 00:13:26,540 --> 00:13:28,160 It probably won't be calibrated anymore 215 00:13:28,160 --> 00:13:29,840 and if it's too old, 216 00:13:29,920 --> 00:13:31,400 you don't want to get anything less than 100 MHz 217 00:13:31,400 --> 00:13:35,160 just because, again, they'll have a bandwidth 218 00:13:35,940 --> 00:13:37,960 and 100 MHz is pretty much 219 00:13:37,960 --> 00:13:41,360 the low end for being really useful for a lot of stuff. 220 00:13:46,940 --> 00:13:49,680 This gentleman informs me that liquidation.com 221 00:13:49,680 --> 00:13:50,900 has really good prices on them. 222 00:13:51,200 --> 00:13:53,120 Oh, governmentliquidations.com. 223 00:13:56,300 --> 00:14:00,880 Well, another alternative is to use USB-based oscilloscopes, 224 00:14:00,900 --> 00:14:05,420 but the display is not going to be anywhere near real time 225 00:14:05,940 --> 00:14:07,740 and there's usually going to be, like, 226 00:14:07,960 --> 00:14:09,860 a noticeable three, four second delay. 227 00:14:10,140 --> 00:14:12,280 Like, if you're monitoring a serial port with it 228 00:14:12,280 --> 00:14:14,100 and you're trying to look at your frame size 229 00:14:14,100 --> 00:14:16,120 and you hit a button on your console 230 00:14:16,120 --> 00:14:17,580 and watch it go on the oscilloscope, 231 00:14:17,680 --> 00:14:19,900 it might be three seconds before you actually see it. 232 00:14:20,440 --> 00:14:23,520 But the USB instruments can be very useful 233 00:14:23,520 --> 00:14:26,160 because it'll only be a couple hundred dollars 234 00:14:26,160 --> 00:14:28,840 rather than tens of thousands of dollars 235 00:14:28,840 --> 00:14:32,040 for the equivalent full instrument 236 00:14:32,820 --> 00:14:34,780 that you'd see in a lab. 237 00:14:39,260 --> 00:14:40,620 Yes, Hamfest is definitely, 238 00:14:41,240 --> 00:14:43,360 we come from, well, I come from the Boston area, 239 00:14:43,420 --> 00:14:44,940 so the MIT flea market is good there. 240 00:14:45,240 --> 00:14:46,580 You can look them up on the internet. 241 00:14:46,860 --> 00:14:49,060 It's basically get-togethers like this 242 00:14:49,060 --> 00:14:51,560 only for ham radio people instead of computer security people. 243 00:14:52,100 --> 00:14:54,320 And the vendor room tends to have a lot of 244 00:14:54,320 --> 00:14:55,860 this sort of electronic test equipment, 245 00:14:56,600 --> 00:14:57,880 radio gear, that sort of thing. 246 00:14:59,360 --> 00:15:00,940 The device I've pulled up on the screen here 247 00:15:00,940 --> 00:15:02,960 is a logic probe, which is basically 248 00:15:02,960 --> 00:15:05,100 it displays one bit of data. 249 00:15:05,220 --> 00:15:06,680 It's the state of a single logic line. 250 00:15:06,680 --> 00:15:08,700 And it's useful for checking 251 00:15:08,700 --> 00:15:10,180 if you've built a logic circuit. 252 00:15:10,280 --> 00:15:11,540 You can just check the outputs, 253 00:15:11,840 --> 00:15:13,180 make sure they are what you expect. 254 00:15:15,140 --> 00:15:17,480 I actually have a couple of them up here. 255 00:15:18,680 --> 00:15:20,520 They're pretty easy to build. 256 00:15:20,700 --> 00:15:23,200 I'm actually, I have kits that I brought 257 00:15:23,200 --> 00:15:25,540 that are for building a very basic logic probe. 258 00:15:27,380 --> 00:15:29,800 The choice between building it yourself 259 00:15:29,800 --> 00:15:32,740 or buying one is pretty much 260 00:15:32,740 --> 00:15:34,020 six and one half dozen to the other. 261 00:15:34,260 --> 00:15:35,600 If you're just getting into electronics, 262 00:15:35,600 --> 00:15:36,800 it's a useful project. 263 00:15:37,060 --> 00:15:38,560 You learn some digital electronics, 264 00:15:39,380 --> 00:15:40,480 basic assembly. 265 00:15:41,040 --> 00:15:43,100 If you understand how it works already, 266 00:15:43,280 --> 00:15:44,720 you probably don't need to build it. 267 00:15:47,440 --> 00:15:49,880 Logic analyzer is basically a whole bunch 268 00:15:49,880 --> 00:15:51,380 of logic probes side by side 269 00:15:51,380 --> 00:15:54,840 with some recording and playback capacity usually. 270 00:15:55,180 --> 00:15:58,040 This can be good for debugging buses 271 00:15:58,040 --> 00:15:59,580 which contain peripheral devices 272 00:15:59,580 --> 00:16:05,400 like a lot of microcontroller based devices 273 00:16:05,600 --> 00:16:07,840 will have either an SPI bus 274 00:16:07,840 --> 00:16:09,140 or an I2C bus. 275 00:16:09,320 --> 00:16:10,760 Those are both proprietary names. 276 00:16:11,080 --> 00:16:12,680 They'll also be called generically 277 00:16:12,680 --> 00:16:14,980 two-wire buses for I2C 278 00:16:14,980 --> 00:16:17,180 or three-wire buses for SPI, 279 00:16:17,180 --> 00:16:19,400 even though SPI buses are usually four wires 280 00:16:20,020 --> 00:16:21,580 because they have a clock wire, 281 00:16:22,460 --> 00:16:23,960 data in, data out, 282 00:16:24,080 --> 00:16:25,040 and then a slave select 283 00:16:25,040 --> 00:16:26,300 to select between which device 284 00:16:26,300 --> 00:16:27,700 on the bus is being talked to. 285 00:16:29,040 --> 00:16:30,740 When you're using a logic analyzer, 286 00:16:30,740 --> 00:16:32,180 you can look at all four of those lines 287 00:16:32,180 --> 00:16:33,680 and see how the devices are, 288 00:16:33,760 --> 00:16:35,280 how the chips on the board are communicating. 289 00:16:35,600 --> 00:16:37,120 And whether or not there's, 290 00:16:37,120 --> 00:16:40,080 where the bugs are in your code 291 00:16:40,080 --> 00:16:41,340 or your layout or whatever. 292 00:16:42,340 --> 00:16:43,680 These peripherals we're talking about 293 00:16:43,680 --> 00:16:45,400 are on a single board. 294 00:16:45,720 --> 00:16:46,620 This would be like communication 295 00:16:47,180 --> 00:16:48,420 between one chip and another. 296 00:16:48,640 --> 00:16:50,820 I don't think that I2C is usually used 297 00:16:50,820 --> 00:16:52,180 to communicate between individual devices 298 00:16:52,180 --> 00:16:54,040 like a computer and router or whatever. 299 00:16:55,380 --> 00:16:56,840 You can do it yourself, 300 00:16:56,960 --> 00:16:58,940 make a do-it-yourself logic analyzer. 301 00:16:59,000 --> 00:17:00,580 I have also kits for that. 302 00:17:01,520 --> 00:17:03,660 I'm thinking since we have the question and answer room, 303 00:17:03,740 --> 00:17:05,160 I'll be giving some of these kits out there. 304 00:17:06,320 --> 00:17:07,780 They hook up the parallel port 305 00:17:07,780 --> 00:17:09,260 and can watch eight lines at once. 306 00:17:09,480 --> 00:17:12,100 Due to the relative slowness of the parallel port, 307 00:17:12,220 --> 00:17:14,060 they get about one million samples per second, 308 00:17:14,200 --> 00:17:17,500 so they can't pick up a signal 309 00:17:17,500 --> 00:17:18,540 much more than one megahertz. 310 00:17:18,660 --> 00:17:19,780 Well, actually it has to be 311 00:17:19,780 --> 00:17:20,920 much less than one megahertz. 312 00:17:20,980 --> 00:17:22,220 For those of you who are familiar with it, 313 00:17:22,240 --> 00:17:23,020 I believe it's Shannon entropy. 314 00:17:25,160 --> 00:17:26,600 But on the other hand, it's cheap. 315 00:17:26,720 --> 00:17:28,060 It's a 179 cent chip. 316 00:17:28,380 --> 00:17:30,340 We already mentioned the USB tool. 317 00:17:30,520 --> 00:17:33,380 This tool here is the USB, 318 00:17:33,580 --> 00:17:34,780 B-E-E, 319 00:17:34,780 --> 00:17:36,060 for maximal confusion. 320 00:17:37,220 --> 00:17:39,660 It's a USB logic analyzer, 321 00:17:39,700 --> 00:17:41,760 protocol debugger, oscilloscope. 322 00:17:42,480 --> 00:17:43,960 It's basically an entire lab 323 00:17:43,960 --> 00:17:45,440 in a little box the size of an ice cube. 324 00:17:45,960 --> 00:17:48,060 The downside is it costs $1,500. 325 00:17:49,140 --> 00:17:51,560 If you have the money for it, 326 00:17:51,620 --> 00:17:52,400 I'm sure it's fantastic. 327 00:17:52,800 --> 00:17:53,680 I don't. 328 00:17:55,840 --> 00:17:57,560 This is also a Windows-only device. 329 00:17:57,640 --> 00:17:59,660 There's not Linux support for this thing. 330 00:18:00,920 --> 00:18:01,760 Not surprisingly. 331 00:18:04,780 --> 00:18:05,560 For do-it-yourself tools, 332 00:18:06,340 --> 00:18:08,420 X-Oscope is a program for Linux 333 00:18:08,420 --> 00:18:09,960 that allows you to use your sound card 334 00:18:09,960 --> 00:18:11,620 as an oscilloscope. 335 00:18:11,980 --> 00:18:13,620 It's not a fantastic oscilloscope. 336 00:18:14,020 --> 00:18:15,560 It's permanently AC coupled 337 00:18:15,560 --> 00:18:17,120 because of the way sound cards are constructed, 338 00:18:17,380 --> 00:18:19,480 which basically means that it's not great 339 00:18:19,480 --> 00:18:21,340 for dealing with signals that will stay 340 00:18:21,340 --> 00:18:22,940 at one level or another for a very long time. 341 00:18:24,060 --> 00:18:26,720 It's a little tricky to use, 342 00:18:26,900 --> 00:18:32,440 and the bandwidth is not good. 343 00:18:32,800 --> 00:18:34,760 It's about the audio bandwidth. 344 00:18:34,780 --> 00:18:35,700 It's about the bandwidth of the human ear, 345 00:18:35,860 --> 00:18:37,820 because that's what sound cards are optimized for. 346 00:18:38,320 --> 00:18:40,320 Parallel port logic analyzers are already mentioned. 347 00:18:44,300 --> 00:18:46,280 JTAG lip wigglers we'll come to in a little bit. 348 00:18:46,660 --> 00:18:48,660 And those are used for debugging embedded systems. 349 00:18:49,160 --> 00:18:51,700 And flash dumpers for removing 350 00:18:52,240 --> 00:18:54,320 or retrieving the contents of flash RAM 351 00:18:54,320 --> 00:18:56,100 for firmware reverse engineering. 352 00:18:58,540 --> 00:19:00,200 And some sources we've already mentioned. 353 00:19:01,300 --> 00:19:02,840 Hamfest's Amaya oscilloscope 354 00:19:02,840 --> 00:19:04,480 is a 100 megahertz unit 355 00:19:04,780 --> 00:19:05,960 pulled out of the garbage at a college, 356 00:19:06,140 --> 00:19:08,240 fully working with all manuals and probes. 357 00:19:08,360 --> 00:19:09,900 I don't know that everybody will be that lucky, 358 00:19:10,000 --> 00:19:10,740 but one can hope. 359 00:19:12,700 --> 00:19:15,260 Also, colleges, if you have friends who are in a college 360 00:19:15,260 --> 00:19:16,400 and are in an EE program, 361 00:19:17,860 --> 00:19:19,700 definitely ask them what they have in their labs. 362 00:19:20,380 --> 00:19:22,160 I got very lucky and found somebody 363 00:19:22,160 --> 00:19:24,880 who had an EEPROM dumper that they could let me use 364 00:19:25,720 --> 00:19:27,200 for a reverse engineering project 365 00:19:27,200 --> 00:19:28,160 that I'll go over in a little bit. 366 00:19:28,940 --> 00:19:30,540 eBay, of course, has all sorts of stuff, 367 00:19:30,680 --> 00:19:32,400 but of course at variable prices 368 00:19:32,400 --> 00:19:34,200 and variable quality. 369 00:19:37,060 --> 00:19:39,720 As far as teaching yourself the basics of electronics, 370 00:19:40,480 --> 00:19:41,580 which won't be in any time you want, 371 00:19:43,380 --> 00:19:44,520 Forrest Mims is an author 372 00:19:44,520 --> 00:19:46,180 who wrote for RadioShack for a long time. 373 00:19:46,360 --> 00:19:48,420 His books tend to be very full on schematics, 374 00:19:48,640 --> 00:19:50,520 so they're a cookbook approach. 375 00:19:50,760 --> 00:19:52,820 There's not a huge amount of theory in them, 376 00:19:52,980 --> 00:19:54,520 but if you want a basic circuit 377 00:19:54,520 --> 00:19:55,900 to just do something simple, 378 00:19:56,080 --> 00:19:58,040 logic probe circuits, for example, 379 00:19:58,660 --> 00:20:00,560 555 timer circuits for tone generators, 380 00:20:00,760 --> 00:20:01,900 pulse delays, that sort of thing, 381 00:20:02,400 --> 00:20:03,060 they're a great resource. 382 00:20:03,780 --> 00:20:06,560 One of the classic books is Art of Electronics. 383 00:20:06,760 --> 00:20:07,680 Now that book's been around 384 00:20:07,680 --> 00:20:09,940 for at least a couple dozen years. 385 00:20:10,500 --> 00:20:12,940 My boss recently recommended that to me 386 00:20:12,940 --> 00:20:14,660 because I just got a new job 387 00:20:14,660 --> 00:20:17,160 doing a different sort of embedded engineering. 388 00:20:17,740 --> 00:20:22,680 And basically it takes what you learn 389 00:20:22,680 --> 00:20:25,500 as a double E and distills it into things 390 00:20:26,040 --> 00:20:28,240 that you don't need to be a double E to understand. 391 00:20:28,680 --> 00:20:31,500 So one of the reviews I read for it 392 00:20:31,500 --> 00:20:33,820 was a professor handed it to one of his grad students 393 00:20:33,820 --> 00:20:35,800 that made a Fubard op-amp circuit, 394 00:20:36,000 --> 00:20:38,600 and the very next morning he had it completely fixed, 395 00:20:38,680 --> 00:20:40,120 working, and polished. 396 00:20:40,380 --> 00:20:42,440 Because it's really where the rubber meets the road 397 00:20:42,440 --> 00:20:44,720 and not so much theory, but it's all practical 398 00:20:44,720 --> 00:20:46,520 how to use each component. 399 00:20:46,640 --> 00:20:48,180 If you run into a component on a board 400 00:20:48,180 --> 00:20:50,060 like an optocoupler, and you're like, 401 00:20:50,180 --> 00:20:51,520 what the hell does an optocoupler do? 402 00:20:51,700 --> 00:20:53,480 You look it up in that, and it's probably going to have 403 00:20:53,480 --> 00:20:54,480 five sections on it. 404 00:20:55,800 --> 00:20:56,820 It's a great resource. 405 00:20:59,000 --> 00:21:00,460 Basically it starts at the beginning 406 00:21:00,460 --> 00:21:02,440 and goes through advanced electronics. 407 00:21:02,760 --> 00:21:04,960 It's over a thousand pages long 408 00:21:04,960 --> 00:21:07,620 and one of the most complete resources I've seen. 409 00:21:07,980 --> 00:21:09,800 It's also structured as a textbook, 410 00:21:10,100 --> 00:21:12,540 so it's useful if you're teaching yourself the field. 411 00:21:12,800 --> 00:21:15,020 It also is referred to as the Bible. 412 00:21:15,240 --> 00:21:17,360 So you know what that means. 413 00:21:17,520 --> 00:21:19,000 If the book is the Bible of a field, 414 00:21:19,120 --> 00:21:20,680 it's generally highly regarded. 415 00:21:20,940 --> 00:21:23,880 It does show a little bit of dating 416 00:21:24,320 --> 00:21:29,440 in storage methodologies for digital stuff. 417 00:21:29,440 --> 00:21:32,800 It doesn't cover as much flash as it does EPROMs, 418 00:21:32,820 --> 00:21:34,520 and its focus on microcontrollers 419 00:21:34,520 --> 00:21:36,780 is Motorola 6800 architectures. 420 00:21:37,640 --> 00:21:39,060 Which are deprecated. 421 00:21:39,340 --> 00:21:40,740 Yeah, they're gradually going away. 422 00:21:41,840 --> 00:21:44,320 But the principles still hold. 423 00:21:44,800 --> 00:21:47,260 The application notes are published 424 00:21:47,260 --> 00:21:49,680 by the manufacturers of software, 425 00:21:49,880 --> 00:21:51,000 or of hardware, excuse me. 426 00:21:52,480 --> 00:21:56,500 And they basically cover how to use an individual chip. 427 00:21:57,460 --> 00:21:58,140 The... 428 00:21:58,140 --> 00:21:59,540 A lot of... 429 00:21:59,540 --> 00:22:02,140 The funny thing about some stuff 430 00:22:02,140 --> 00:22:04,380 is that it's just the application note in a box. 431 00:22:04,600 --> 00:22:05,920 This is especially true of video cards. 432 00:22:06,160 --> 00:22:08,820 People will take Nvidia, for example's chip 433 00:22:08,820 --> 00:22:10,540 and the documentation for it, 434 00:22:10,580 --> 00:22:11,760 and just build that, 435 00:22:11,900 --> 00:22:12,940 maybe add a few parts, 436 00:22:13,000 --> 00:22:13,920 maybe not add a few parts, 437 00:22:14,060 --> 00:22:15,340 and call it a video card. 438 00:22:18,680 --> 00:22:20,080 Okay, embedded engineering. 439 00:22:20,080 --> 00:22:20,740 Moving on. 440 00:22:27,640 --> 00:22:28,940 It's not reverse engineering. 441 00:22:30,240 --> 00:22:31,660 In this case we wanted to 442 00:22:32,120 --> 00:22:33,200 emphasize the similarities 443 00:22:33,200 --> 00:22:34,280 to the software development process. 444 00:22:35,240 --> 00:22:37,520 First step is gathering the requirements of the device, 445 00:22:37,680 --> 00:22:38,340 what it has to do, 446 00:22:38,400 --> 00:22:39,380 what it has to not do, 447 00:22:39,500 --> 00:22:41,780 situations where it is permissible to fail or not fail. 448 00:22:42,880 --> 00:22:44,040 Then research the resources, 449 00:22:44,380 --> 00:22:45,520 what's available to build this thing, 450 00:22:46,100 --> 00:22:46,800 assemble it, 451 00:22:46,880 --> 00:22:48,420 generally a prototype first, 452 00:22:48,500 --> 00:22:49,440 before production runs, 453 00:22:49,440 --> 00:22:49,600 requirements. 454 00:22:50,200 --> 00:22:52,960 Requirements also include things like low cost, 455 00:22:54,140 --> 00:22:55,620 maybe easy to assemble, 456 00:22:56,280 --> 00:22:59,740 and able to be built in a home lab. 457 00:23:00,100 --> 00:23:02,960 But they're also the functional requirements of your device. 458 00:23:03,180 --> 00:23:03,940 Like this one, 459 00:23:04,080 --> 00:23:06,380 the requirements are user programmable, 460 00:23:07,100 --> 00:23:07,660 moddable, 461 00:23:07,840 --> 00:23:10,680 and display text on a bunch of LEDs. 462 00:23:11,000 --> 00:23:12,020 So it does all that. 463 00:23:12,580 --> 00:23:13,140 But... 464 00:23:15,040 --> 00:23:16,700 Generally this process is iterative. 465 00:23:16,980 --> 00:23:19,020 If you see a board that's got rev, 466 00:23:19,440 --> 00:23:20,240 and a number after it, 467 00:23:20,320 --> 00:23:22,260 that's how many times they've done 468 00:23:22,260 --> 00:23:23,560 a different release of that board. 469 00:23:25,040 --> 00:23:29,040 Usually companies start with special revision numbers, 470 00:23:29,260 --> 00:23:30,740 so they don't have to tell anyone 471 00:23:30,740 --> 00:23:32,760 how many revs they went through before it worked. 472 00:23:35,440 --> 00:23:37,480 A few notes on architecture. 473 00:23:38,200 --> 00:23:40,640 With a lot of the smaller microcontrollers, 474 00:23:40,660 --> 00:23:42,640 you have your choice between 4-bit, 475 00:23:42,760 --> 00:23:43,460 8-bit, 476 00:23:43,600 --> 00:23:44,460 16-bit, 477 00:23:44,540 --> 00:23:45,420 and 32-bit. 478 00:23:45,680 --> 00:23:47,400 Now the biggest difference between these, 479 00:23:47,440 --> 00:23:48,460 other than register width, 480 00:23:48,600 --> 00:23:49,200 is cost. 481 00:23:49,440 --> 00:23:52,420 And a lot of it is also speed of the processors. 482 00:23:52,680 --> 00:23:56,040 With a lot of the lower end 16 and 8-bit stuff, 483 00:23:56,200 --> 00:23:57,980 you're going to max out around 40 megahertz, 484 00:23:58,120 --> 00:24:00,380 and your onboard flash and RAM 485 00:24:00,380 --> 00:24:02,700 is going to be less than a meg combined. 486 00:24:03,320 --> 00:24:05,660 So you might have 2K of RAM, 487 00:24:05,840 --> 00:24:11,040 and less than 512K of flash. 488 00:24:11,460 --> 00:24:12,960 And you'll like it, 489 00:24:13,020 --> 00:24:16,020 because really it's a very simple chip, 490 00:24:16,120 --> 00:24:17,960 and it's more than enough space 491 00:24:17,960 --> 00:24:19,900 to be able to do what it needs to do. 492 00:24:19,980 --> 00:24:22,100 Because it doesn't really have that much I.O. speed. 493 00:24:22,540 --> 00:24:24,180 But for simple things like this, 494 00:24:24,320 --> 00:24:26,600 anything more than a couple K is overkill anyway. 495 00:24:28,040 --> 00:24:29,920 The chip I used for a few projects 496 00:24:29,920 --> 00:24:32,520 is the ATmega168 made by Atmel. 497 00:24:32,680 --> 00:24:36,580 16 megahertz system clock, 498 00:24:36,700 --> 00:24:39,720 16 kilobytes of storage space, 499 00:24:39,940 --> 00:24:41,060 just flash on the chip. 500 00:24:41,360 --> 00:24:44,660 It's programmable pretty easily with variants of C. 501 00:24:44,980 --> 00:24:47,240 A lot of microcontrollers have moved to 502 00:24:47,240 --> 00:24:48,860 system-on-a-chip architectures, 503 00:24:48,920 --> 00:24:51,500 where you've got not only the CPU core it's called, 504 00:24:51,640 --> 00:24:54,160 which is the core determines what instructions that it uses, 505 00:24:54,320 --> 00:24:56,280 but also standard peripheral systems. 506 00:24:56,680 --> 00:24:58,360 So you're going to have like an SPI module, 507 00:24:58,700 --> 00:25:00,420 maybe a couple CAM modules, 508 00:25:00,520 --> 00:25:02,980 which is a proprietary communication protocol, 509 00:25:03,320 --> 00:25:04,920 which is very common in automotive, 510 00:25:05,260 --> 00:25:07,980 marine, and avionic applications. 511 00:25:09,360 --> 00:25:11,000 You've got SPI, of course, 512 00:25:11,020 --> 00:25:12,320 which is another standard interconnect 513 00:25:12,320 --> 00:25:13,360 for other devices, 514 00:25:13,520 --> 00:25:15,160 which may be Ethernet chips or whatever. 515 00:25:15,760 --> 00:25:17,140 And then you've got, 516 00:25:17,240 --> 00:25:21,440 you've got EPROM that might be off-board as well, 517 00:25:21,600 --> 00:25:24,300 off-board RAM that you've got to interact with. 518 00:25:24,700 --> 00:25:25,780 As well as communications, 519 00:25:25,980 --> 00:25:28,120 there's sometimes stuff just completely built into the chip. 520 00:25:28,280 --> 00:25:30,560 Real-time clocks and watchdog timers are pretty common, 521 00:25:30,700 --> 00:25:32,780 which are useful for setting the chip 522 00:25:32,780 --> 00:25:34,360 to do something in the future, basically, 523 00:25:34,420 --> 00:25:35,940 if you have a part of the code 524 00:25:35,940 --> 00:25:37,460 that you won't run every N seconds, 525 00:25:38,520 --> 00:25:40,940 or resetting the chip if something goes horribly awry. 526 00:25:41,200 --> 00:25:44,280 The other thing to look at is how many pins the chip has out, 527 00:25:44,360 --> 00:25:46,040 because a lot of the picks will have 528 00:25:46,040 --> 00:25:48,320 16 pins on each side, 529 00:25:48,440 --> 00:25:52,280 where 8 of those pins are devoted to VCC ground 530 00:25:52,280 --> 00:25:54,300 and associated crystal stuff. 531 00:25:54,700 --> 00:25:57,840 And then you have 8 address pins 532 00:25:57,840 --> 00:25:59,400 and 16 data pins 533 00:26:00,060 --> 00:26:01,060 for communicating, 534 00:26:01,320 --> 00:26:02,180 just dedicated, 535 00:26:02,400 --> 00:26:04,620 all your GPIOs to one other device, 536 00:26:04,780 --> 00:26:06,000 like off-board memory. 537 00:26:06,560 --> 00:26:08,320 And some of those will also 538 00:26:08,320 --> 00:26:10,020 dual-purpose all those pins, 539 00:26:10,100 --> 00:26:12,760 where you can select in the memory-mapped registers of the chip 540 00:26:12,760 --> 00:26:15,020 whether or not you're going to be using GPIOs, 541 00:26:15,620 --> 00:26:16,820 as in bulk, 542 00:26:16,920 --> 00:26:18,400 or like an SPI bus, 543 00:26:18,600 --> 00:26:21,800 or any number of other system-on-a-chip type configurations. 544 00:26:22,380 --> 00:26:25,740 And they get pretty fancy with what they provide. 545 00:26:25,840 --> 00:26:29,400 Some of them will have secure ROMs, 546 00:26:29,400 --> 00:26:32,820 where you cannot read out the ROM through anything 547 00:26:32,820 --> 00:26:34,120 once it's been loaded, 548 00:26:34,180 --> 00:26:37,060 for protecting IP, of course. 549 00:26:37,780 --> 00:26:41,340 This is true for certain values of cannot read out. 550 00:26:41,440 --> 00:26:44,740 If anybody caught Bunny's talk at ShmooCon two years ago, 551 00:26:44,740 --> 00:26:47,500 he basically depotted a chip, 552 00:26:47,620 --> 00:26:49,380 removed plastic from the top of it, 553 00:26:49,420 --> 00:26:51,400 and then shone UV in at an angle 554 00:26:51,400 --> 00:26:53,320 to get under the aluminum layer 555 00:26:53,320 --> 00:26:54,960 that was covering the fuses 556 00:26:54,960 --> 00:26:58,800 that were set when the chip was set to be write-only. 557 00:26:59,740 --> 00:27:01,480 And that way managed to clear the fuse 558 00:27:01,480 --> 00:27:02,840 and dump all the code out of the chip. 559 00:27:03,440 --> 00:27:06,280 Needless to say, that's not a very easy operation. 560 00:27:07,260 --> 00:27:08,580 It's doable, though. 561 00:27:08,760 --> 00:27:10,300 Or something a noob should attempt. 562 00:27:10,680 --> 00:27:12,620 Yeah, he used a lot of acid for that 563 00:27:12,620 --> 00:27:14,120 to etch the chip top off. 564 00:27:16,740 --> 00:27:19,120 When you're speccing out a new project, 565 00:27:19,260 --> 00:27:20,160 whether it be for robotics 566 00:27:20,160 --> 00:27:22,960 or just you're trying to emulate, 567 00:27:23,280 --> 00:27:25,600 let's say you got the ROM dumped of some chip 568 00:27:25,600 --> 00:27:28,020 and you order a different chip to load it onto 569 00:27:28,020 --> 00:27:28,980 so you can debug it, 570 00:27:29,900 --> 00:27:31,480 you're going to want an evaluation board, 571 00:27:31,580 --> 00:27:33,020 because I'm not an electrical engineer. 572 00:27:33,240 --> 00:27:36,080 I know several very good ones that can design a PCB for me, 573 00:27:36,160 --> 00:27:39,280 but I don't really have the knowledge to do that myself. 574 00:27:39,660 --> 00:27:41,980 So you can order evaluation boards 575 00:27:41,980 --> 00:27:43,760 for just about any microcontroller out there 576 00:27:43,760 --> 00:27:46,480 that already have the power already done, 577 00:27:46,600 --> 00:27:48,160 crystals attached to the board, 578 00:27:48,840 --> 00:27:50,660 breakout boards for all the I.O. pins, 579 00:27:51,580 --> 00:27:54,260 solderless breadboards to put whatever peripherals you want on there, 580 00:27:54,380 --> 00:27:57,280 and basically allow you to start working 581 00:27:57,280 --> 00:28:00,480 without actually having to do any electrical engineering, 582 00:28:00,720 --> 00:28:03,880 which is good if you only know how to write software like me. 583 00:28:04,320 --> 00:28:07,500 The downside of using these is that they can be a little bit too good. 584 00:28:07,860 --> 00:28:11,900 It's a situation where you'll usually have the best revision of the chip 585 00:28:11,900 --> 00:28:13,120 with all the features enabled, 586 00:28:13,760 --> 00:28:16,980 in a board that's been designed by the people who know every quirk of the chip 587 00:28:16,980 --> 00:28:18,300 to support it perfectly, 588 00:28:18,720 --> 00:28:20,840 and a real world application might be a little harsher. 589 00:28:22,400 --> 00:28:23,880 However, you can usually get these, 590 00:28:25,020 --> 00:28:27,340 depending on what the manufacturer is trying to promote, 591 00:28:27,560 --> 00:28:29,120 you can get these at a pretty good price. 592 00:28:29,600 --> 00:28:30,560 Don't you have an evaluation board? 593 00:28:30,640 --> 00:28:32,260 I do not have an evaluation board in there. 594 00:28:33,820 --> 00:28:34,220 No? 595 00:28:34,540 --> 00:28:34,940 No. 596 00:28:35,320 --> 00:28:36,720 I don't have an evaluation board at all. 597 00:28:41,120 --> 00:28:43,740 Oh, you can find evaluation boards just anywhere on the internet. 598 00:28:43,760 --> 00:28:48,140 Let's say you just take a chip name and type in prototype or evaluation board, 599 00:28:48,280 --> 00:28:49,640 you're going to get tons of them up there. 600 00:28:50,020 --> 00:28:54,980 Now, you can be able to build firmware for this using standard new tools 601 00:28:54,980 --> 00:29:00,440 like GCC and everything else that you'll need. 602 00:29:01,140 --> 00:29:04,960 Basically what you do is you have to compile across compiler, 603 00:29:05,280 --> 00:29:11,640 which basically you delve into the specifics of all the GCC compilation settings 604 00:29:11,640 --> 00:29:13,240 and pick your architecture. 605 00:29:13,240 --> 00:29:16,800 To compile, cross compile binaries for. 606 00:29:17,680 --> 00:29:19,660 Now, what this allows you to do is 607 00:29:20,400 --> 00:29:23,640 if I've got GCC that cross compiles to ARM on this thing, 608 00:29:23,780 --> 00:29:27,000 I can make an ARM binary, load it onto an ARM chip, 609 00:29:27,200 --> 00:29:29,180 and have it be able to run it natively. 610 00:29:29,500 --> 00:29:32,700 Now, that's very important because none of these microcontrollers 611 00:29:32,700 --> 00:29:38,420 will use the same instruction set as my x86 laptop here 612 00:29:38,420 --> 00:29:43,000 because x86 is almost never used in embedded applications, 613 00:29:43,040 --> 00:29:43,220 just for the sake of it. 614 00:29:43,240 --> 00:29:44,140 Just because it's overkill. 615 00:29:44,780 --> 00:29:47,720 An overly complicated instruction set, a lot of pins, 616 00:29:48,140 --> 00:29:49,640 just a lot of legacy stuff in it. 617 00:29:49,980 --> 00:29:54,220 I actually use a cross compilation toolchain for working with the AVR microcontrollers 618 00:29:54,220 --> 00:29:55,340 that uses AVR glibc. 619 00:29:56,080 --> 00:29:59,720 It's all open source stuff, so it's free, easy to come by. 620 00:30:01,620 --> 00:30:04,280 However, as I said, availability is highly variable. 621 00:30:04,580 --> 00:30:08,700 It's whatever people are developing for and whatever they can get the information on. 622 00:30:08,840 --> 00:30:12,040 If the manufacturer of the chip wants to maintain a lock 623 00:30:12,040 --> 00:30:13,660 on their software end of the market as well, 624 00:30:13,780 --> 00:30:18,340 they won't make the internals of the chip as available to developers, 625 00:30:18,600 --> 00:30:21,500 so they won't be able to create cross compilation toolchains for it. 626 00:30:22,360 --> 00:30:25,680 Now, the next thing you'll need in making your own embedded device 627 00:30:25,680 --> 00:30:30,120 is to decide which way to go, whether or not you want an operating system at all. 628 00:30:30,500 --> 00:30:34,840 Some things that can determine this is if you have real-time deadlines that you have to meet. 629 00:30:34,920 --> 00:30:38,900 Let's say you're doing some sort of control application for an airplane. 630 00:30:38,900 --> 00:30:45,280 If you don't send a certain signal every 500 milliseconds, the engines stop. 631 00:30:46,440 --> 00:30:49,720 Basically, that's a hard deadline. 632 00:30:51,900 --> 00:30:53,060 Very hard. 633 00:30:53,580 --> 00:30:58,140 You need a real-time OS that will schedule things based on deadline priorities 634 00:30:58,140 --> 00:31:00,240 to make sure that all those deadlines are met. 635 00:31:00,720 --> 00:31:02,880 That's one application that you'd need a real-time OS, 636 00:31:03,080 --> 00:31:07,620 but for simple things like this badge, if this thing stops working, 637 00:31:08,280 --> 00:31:11,460 I'm not going to be shedding any tears, and I don't think anyone else will either. 638 00:31:14,480 --> 00:31:17,200 Basically, this just uses an infinite while loop. 639 00:31:19,960 --> 00:31:21,700 I've got the code here. 640 00:31:28,840 --> 00:31:30,760 He's been modifying his badge slightly. 641 00:31:31,040 --> 00:31:35,480 It now supports a 30-character text string and some other stuff. 642 00:31:35,680 --> 00:31:37,600 It also doesn't change state randomly from time to time. 643 00:31:37,620 --> 00:31:38,480 I'm bumping against his stomach. 644 00:31:45,960 --> 00:31:47,080 Thank you. 645 00:31:47,380 --> 00:31:50,380 Anyway, you'll notice that it says while 1. 646 00:31:50,620 --> 00:31:53,940 Basically, this will execute this loop of code forever. 647 00:31:54,580 --> 00:32:00,820 After it starts up, because it's got initialization code somewhere in here, 648 00:32:03,900 --> 00:32:06,420 which is, as you see, assembly code. 649 00:32:06,420 --> 00:32:09,960 What it will do is it's going to initialize various registers on this chip 650 00:32:09,960 --> 00:32:14,200 and get it configured for working with these shifters on the back 651 00:32:14,200 --> 00:32:18,100 and the optional accelerometer and Zigbee chip 652 00:32:18,580 --> 00:32:21,820 so that the chip knows how to talk to its peripherals. 653 00:32:22,300 --> 00:32:24,320 That'll all happen before you hit the main loop. 654 00:32:24,480 --> 00:32:27,440 Once you get into main, basically all you do is you loop around. 655 00:32:27,900 --> 00:32:30,900 What he's done here is he's implemented a state machine 656 00:32:31,500 --> 00:32:34,140 using a while loop and a current state. 657 00:32:35,440 --> 00:32:40,440 He's got all his interrupts for the keyboard as interrupts 658 00:32:40,440 --> 00:32:42,260 rather than polling the status. 659 00:32:42,480 --> 00:32:46,700 He can sit in infinite loops while waiting for more input to occur. 660 00:32:47,480 --> 00:32:50,800 When it does occur, it just jumps over to that and then jumps back. 661 00:32:51,780 --> 00:32:55,720 It's very simple code, and it's very easy to modify it 662 00:32:55,720 --> 00:32:56,880 if you know what it's doing. 663 00:32:58,440 --> 00:33:01,420 Most embedded applications, they'll have an infinite while loop 664 00:33:01,420 --> 00:33:03,200 and then they'll have basically a driver stack. 665 00:33:03,200 --> 00:33:05,780 It'll go round robin through each driver 666 00:33:05,780 --> 00:33:08,000 and determine what messages it needs to send 667 00:33:08,000 --> 00:33:10,900 based on all the global data it has. 668 00:33:11,420 --> 00:33:14,380 In the application world, you hear that global data is bad. 669 00:33:14,840 --> 00:33:18,240 On an embedded device like this, there's no dynamic memory allocation. 670 00:33:18,560 --> 00:33:20,440 Everything is going to be determined at startup. 671 00:33:21,880 --> 00:33:25,320 Basically, anything that will dynamically allocate memory 672 00:33:25,320 --> 00:33:26,800 could crash your device, 673 00:33:27,080 --> 00:33:29,860 especially if you're doing safety-critical applications. 674 00:33:30,040 --> 00:33:31,260 You don't want any of that. 675 00:33:31,380 --> 00:33:33,180 Everything has to be completely mapped out 676 00:33:33,200 --> 00:33:36,440 well before you even write a line of code 677 00:33:36,440 --> 00:33:38,500 for what your memory requirements are going to be. 678 00:33:40,300 --> 00:33:42,700 This one, he had a lot of extra strings in there 679 00:33:42,700 --> 00:33:46,640 for his Easter eggs and some other useless stuff that I saw. 680 00:33:47,020 --> 00:33:50,460 When I took that out, I was able to free up a 30-character buffer 681 00:33:50,460 --> 00:33:53,060 for the scrolling display. 682 00:33:53,620 --> 00:33:57,420 You'll see I have up, up, down, down, left, right, left, right, B, A, B, A, 683 00:33:57,440 --> 00:34:00,380 select, start, fully display. 684 00:34:04,780 --> 00:34:05,260 That's the way it works. 685 00:34:06,300 --> 00:34:07,620 I'm sure you're a bad influence. 686 00:34:12,580 --> 00:34:14,560 The downside of not having an operating system 687 00:34:14,560 --> 00:34:16,620 is, of course, that you have to do all the hardware access yourself. 688 00:34:17,320 --> 00:34:20,660 However, if the processor is simple enough that you can't put an OS on it, 689 00:34:20,760 --> 00:34:22,780 there's not going to be a lot of hardware to be accessing. 690 00:34:23,220 --> 00:34:26,300 It's generally the AVR chips that I'm most familiar with. 691 00:34:26,680 --> 00:34:30,260 Doing SPI communications is a simple matter of setting a few registers 692 00:34:30,260 --> 00:34:32,240 and then loading one variable with what you want, 693 00:34:32,240 --> 00:34:36,100 sending out the SPI port, and then checking it a few milliseconds later 694 00:34:36,100 --> 00:34:37,760 to see what came back in. 695 00:34:38,300 --> 00:34:43,620 A lot of embedded applications, they will use while loops without a scheduler, 696 00:34:43,700 --> 00:34:47,180 but the way they meet soft deadlines is they do a timing analysis 697 00:34:47,180 --> 00:34:51,300 to make sure that each driver in the stack when you're going round robin 698 00:34:51,300 --> 00:34:54,260 is guaranteed to take less than the worst-case time, 699 00:34:54,400 --> 00:34:58,200 and all the worst-case times added together is less than the next time 700 00:34:58,200 --> 00:35:01,560 that a certain task needs to be executed twice in. 701 00:35:01,560 --> 00:35:05,420 That way, you can ensure that everything's going to happen on time. 702 00:35:05,760 --> 00:35:10,680 Now, for other more complicated things, you might have things running on timers 703 00:35:10,680 --> 00:35:13,260 where this only executes every 100 milliseconds, 704 00:35:13,600 --> 00:35:16,040 and each task may have an individual timer, 705 00:35:16,160 --> 00:35:19,140 or they may all share a single time base 706 00:35:19,140 --> 00:35:23,080 where every 5 milliseconds this occurs, every 100 milliseconds this occurs, 707 00:35:23,280 --> 00:35:26,120 and you just set flags for when those deadlines have been passed. 708 00:35:27,280 --> 00:35:30,720 And then the next step up is, of course, a real-time OS 709 00:35:30,720 --> 00:35:36,020 or embedded Linux or ECOS, which is a free real-time OS. 710 00:35:36,340 --> 00:35:39,320 And then I think Abe had something to say about DOS. 711 00:35:39,320 --> 00:35:41,840 Yeah, DOS is not a real-time OS. 712 00:35:41,960 --> 00:35:46,200 However, when your process is running, the DOS is not doing much itself. 713 00:35:47,360 --> 00:35:48,820 It's not hard real-time. 714 00:35:48,940 --> 00:35:51,680 You wouldn't, I don't think, want to use it in anything that people's lives depended on, 715 00:35:51,800 --> 00:35:55,180 but the band the Sisters of Mercy used it as a drummer for a long time, 716 00:35:55,440 --> 00:35:57,520 so if it's good enough for them, it's good enough for me. 717 00:35:58,680 --> 00:36:00,620 Now, I've already gone over the tasks. 718 00:36:00,720 --> 00:36:03,320 The task loop and, of course, the global data. 719 00:36:03,520 --> 00:36:05,940 Now, the global data is usually used as a database, 720 00:36:06,060 --> 00:36:07,640 and that determines your state of your device, 721 00:36:07,760 --> 00:36:12,320 because at any given moment, your global data determines what it's going to do next. 722 00:36:12,660 --> 00:36:19,040 So that's fairly important, and we're running out of time, 723 00:36:19,120 --> 00:36:21,000 so I'm going to have to speed this up. 724 00:36:21,600 --> 00:36:27,120 Now, in a lot of larger applications, you're going to have several microcontrollers, 725 00:36:27,200 --> 00:36:29,400 and you might have multiple microcontrollers 726 00:36:29,400 --> 00:36:32,520 that do exactly the same thing hooked up to a bigger microcontroller. 727 00:36:32,720 --> 00:36:36,540 So you can use an object-oriented approach to build larger distributed systems 728 00:36:36,540 --> 00:36:40,800 and basically get a lot accomplished with very low-cost parts. 729 00:36:41,440 --> 00:36:43,600 Similarly, from a hobbyist's point of view, there are some modules 730 00:36:43,600 --> 00:36:47,260 that are basically just drop-in things that you can use to plug together a system 731 00:36:48,080 --> 00:36:49,660 without having to design them yourself. 732 00:36:49,960 --> 00:36:53,620 This comes in really handy if you're doing RF, for example, 733 00:36:53,780 --> 00:36:55,820 and, like me, don't know a whole lot of radio. 734 00:36:56,340 --> 00:36:58,200 You can buy radio modules. 735 00:36:58,200 --> 00:36:59,740 They're like a little simple thing. 736 00:36:59,840 --> 00:37:03,360 They get power, ground, and data, and you put data in, data comes out. 737 00:37:03,460 --> 00:37:06,440 You don't have to worry about resonance or frequencies or tuning anything. 738 00:37:07,600 --> 00:37:10,100 Now for the part you've all been waiting for, reverse engineering. 739 00:37:12,640 --> 00:37:15,780 It's the exact inverse of the forward engineering process. 740 00:37:15,980 --> 00:37:18,960 You start with a completed thing, figure out what the parts of it are, 741 00:37:19,120 --> 00:37:22,520 determine how everything's hooked together, how everything works, and what each thing does. 742 00:37:23,020 --> 00:37:26,640 Generally, when you're reverse engineering, there's a specific thing that you want it to do 743 00:37:26,640 --> 00:37:28,180 that it doesn't do or something like that. 744 00:37:28,200 --> 00:37:29,900 It's something that it does do that you wish it would quit. 745 00:37:30,840 --> 00:37:34,060 So you want to be able to select the areas that you want to focus on 746 00:37:34,060 --> 00:37:37,720 and ignore things like the power supply, unless the power supply is the source of your problems. 747 00:37:39,620 --> 00:37:42,200 Printed circuit boards are actually remarkably readable. 748 00:37:43,000 --> 00:37:46,460 If you look, you've got your chips, and they've all got their part numbers, 749 00:37:46,680 --> 00:37:49,560 so you use those to search on the Internet, get data sheets. 750 00:37:49,800 --> 00:37:52,540 A lot of manufacturers don't provide a lot of data sheet information, 751 00:37:53,920 --> 00:37:56,900 but the ones that do are generally very, very useful 752 00:37:56,900 --> 00:38:02,320 for figuring out where functionality the chip has that you might not have known about, 753 00:38:03,340 --> 00:38:05,800 figuring out what the chip could be talking to on the board. 754 00:38:06,180 --> 00:38:11,600 I have a monocle sort of display that was set up for PAL, 755 00:38:11,980 --> 00:38:13,920 but I opened it up and looked at the circuit board, 756 00:38:14,100 --> 00:38:16,800 and I noticed that right next to the resistor that sets, 757 00:38:16,840 --> 00:38:20,380 this is a PAL video input, were a pair of empty pads. 758 00:38:21,100 --> 00:38:23,860 Looking at the data sheet, I found out that sets NTSC, 759 00:38:24,000 --> 00:38:25,900 and I got it to work better with, you know, 760 00:38:25,900 --> 00:38:28,680 U.S. equipment as opposed to the rest of the world where they use PAL. 761 00:38:29,940 --> 00:38:31,400 Traces are useful to look at. 762 00:38:31,680 --> 00:38:35,180 Big, thick traces generally means it's power or carrying a lot of current. 763 00:38:35,500 --> 00:38:36,980 Thin traces are usually a signal. 764 00:38:37,220 --> 00:38:41,460 And the silk screen will tell you not only what type each part is, 765 00:38:41,560 --> 00:38:44,400 especially for small things that you can't really read the numbers off of, 766 00:38:44,480 --> 00:38:46,920 like surface mount devices, whether they're resistors, capacitors, 767 00:38:48,680 --> 00:38:50,420 microchips, or just ordinary transistors. 768 00:38:51,120 --> 00:38:53,520 The nice thing is that PCBs are expensive, 769 00:38:53,660 --> 00:38:55,880 and they cost money to put extra layers on. 770 00:38:55,900 --> 00:38:59,620 So most devices aren't going to have many, many layers. 771 00:38:59,960 --> 00:39:01,760 So most of it's going to be visible, 772 00:39:02,540 --> 00:39:06,380 which helps in the reverse engineering process. 773 00:39:07,380 --> 00:39:08,920 Unpopulated pads are also useful. 774 00:39:09,080 --> 00:39:10,740 I unfortunately missed Joe Grant's talk, 775 00:39:10,920 --> 00:39:13,300 but even just looking at this, I knew that it was doing wireless 776 00:39:13,300 --> 00:39:16,060 because it has a pair of antennas on it, these loop tracks. 777 00:39:19,080 --> 00:39:20,980 How do we get that? 778 00:39:22,640 --> 00:39:24,620 This thing's 10-9 warning rate. 779 00:39:25,960 --> 00:39:28,300 Recognizing common subsystems is just a skill that you'll get 780 00:39:28,300 --> 00:39:30,500 if you look into a lot of devices. 781 00:39:31,020 --> 00:39:32,840 Power stuff is easy to recognize. 782 00:39:32,900 --> 00:39:35,360 There's big capacitors, big inductors, big traces. 783 00:39:35,540 --> 00:39:38,140 It's all chunky stuff compared to everything else in the circuit. 784 00:39:38,300 --> 00:39:38,560 Which? 785 00:39:39,520 --> 00:39:42,260 Fuses, yes. Big fuses. No, thank you. 786 00:39:45,260 --> 00:39:47,080 If you have to reverse engineer a protocol, 787 00:39:47,340 --> 00:39:48,880 a communications protocol between two devices, 788 00:39:48,980 --> 00:39:49,700 you have a few options. 789 00:39:50,940 --> 00:39:53,640 You snoop on the protocol if you have something that can speak it. 790 00:39:53,640 --> 00:39:57,340 You can just watch as the two things talk to each other. 791 00:39:57,500 --> 00:40:01,020 The schematic that's up here is a serial sniffer. 792 00:40:01,160 --> 00:40:03,540 I believe this is a half duplex one. 793 00:40:04,040 --> 00:40:06,220 It will only catch one half of a communication. 794 00:40:08,660 --> 00:40:11,660 This is for just ordinary RS-232 serial. 795 00:40:11,820 --> 00:40:14,540 There are devices available for USB that do this. 796 00:40:15,520 --> 00:40:17,920 There's also fuzzing, everybody's favorite topic. 797 00:40:18,640 --> 00:40:21,540 You could just throw random stuff at it over the serial port 798 00:40:21,540 --> 00:40:22,340 and see how it responds. 799 00:40:22,340 --> 00:40:25,740 If you're lucky, you can just pull out the firmware 800 00:40:25,740 --> 00:40:27,820 and see how the protocol is done in there. 801 00:40:29,780 --> 00:40:32,120 Pulling out the firmware can be done in a variety of ways. 802 00:40:32,400 --> 00:40:34,120 BDM stands for background debug module. 803 00:40:35,080 --> 00:40:37,960 Unfortunately, you can't dump the firmware from a BDM cable 804 00:40:37,960 --> 00:40:39,380 or verify what's on there. 805 00:40:39,640 --> 00:40:43,220 But you can erase it and write new firmware to it. 806 00:40:44,300 --> 00:40:46,600 Once you get firmware in this little chip here, 807 00:40:46,720 --> 00:40:49,060 it's there forever and you're never getting it back out 808 00:40:49,640 --> 00:40:51,560 unless you have a bootloader that can read it out. 809 00:40:51,560 --> 00:40:53,180 But this one doesn't. 810 00:40:53,660 --> 00:40:56,900 Some BDM systems also let you do things like clock stepping 811 00:40:56,900 --> 00:41:00,680 to slow down the process and run inspecting each register 812 00:41:00,680 --> 00:41:02,100 as each clock cycle passes. 813 00:41:04,240 --> 00:41:06,820 But modifying registers, modifying memory locations. 814 00:41:07,160 --> 00:41:09,380 These actually have a BDM port on the back. 815 00:41:09,520 --> 00:41:11,080 As you see, I put a pin header on it. 816 00:41:11,200 --> 00:41:14,600 It's actually a one-wire bus that allows you to debug the chip. 817 00:41:14,780 --> 00:41:17,560 It uses some proprietary burst protocol, 818 00:41:17,780 --> 00:41:19,500 which is not at all a standard. 819 00:41:19,640 --> 00:41:20,680 So for different devices, 820 00:41:20,680 --> 00:41:22,240 you have different BDM pinouts. 821 00:41:22,400 --> 00:41:23,720 Some of them will be eight pins. 822 00:41:23,800 --> 00:41:24,580 Some of them are six. 823 00:41:24,880 --> 00:41:26,760 And all of them require different pods. 824 00:41:26,960 --> 00:41:29,180 And it's a very expensive way to do development. 825 00:41:29,380 --> 00:41:32,420 But since each pod's only about 50 to 100 bucks. 826 00:41:32,740 --> 00:41:34,880 And if you notice, the Freescale pods, 827 00:41:35,000 --> 00:41:36,000 if you connect them backwards, 828 00:41:36,280 --> 00:41:38,020 it'll short the pod and you need a new one. 829 00:41:39,020 --> 00:41:40,520 So you can go through a lot of them 830 00:41:40,520 --> 00:41:42,600 if you're using those in your manufacturing process. 831 00:41:43,000 --> 00:41:45,480 BDM usually shows up on Freescale and Motorola processors. 832 00:41:46,620 --> 00:41:48,400 JTAG is an alternative to BDM. 833 00:41:48,460 --> 00:41:50,400 It stands for Joint Test Application Group. 834 00:41:50,680 --> 00:41:52,320 Also not standard, but better. 835 00:41:52,320 --> 00:41:53,680 Well, there are standards. 836 00:41:54,120 --> 00:41:57,540 The pins, there are named pins that have certain functions. 837 00:41:57,800 --> 00:42:00,360 However, the headers are highly variable. 838 00:42:00,660 --> 00:42:03,340 I've got two devices here, both of which have JTAG headers. 839 00:42:03,440 --> 00:42:04,260 One of them has 10 pins. 840 00:42:04,400 --> 00:42:05,420 One of them has 14. 841 00:42:06,480 --> 00:42:07,840 The connections are different. 842 00:42:07,940 --> 00:42:09,600 And it's been largely trial and error 843 00:42:09,600 --> 00:42:12,000 trying to get JTAG connections into these devices. 844 00:42:12,840 --> 00:42:15,300 It supports a lot of the same stuff as BDM. 845 00:42:15,480 --> 00:42:17,280 Basic JTAG won't let you do debug. 846 00:42:17,440 --> 00:42:19,560 It won't let you step the clock one step at a time. 847 00:42:19,560 --> 00:42:20,820 It won't let you access the registers. 848 00:42:21,140 --> 00:42:25,060 It will, however, let you set or clear 849 00:42:25,060 --> 00:42:26,760 the state of any pin around the device. 850 00:42:27,040 --> 00:42:29,580 Basically, the JTAG talks to a chain of shift registers 851 00:42:29,580 --> 00:42:32,500 that sit between the actual metal pin 852 00:42:32,500 --> 00:42:33,720 on the outside of the circuit 853 00:42:33,720 --> 00:42:35,380 and the silicon inside the device 854 00:42:35,380 --> 00:42:38,280 and allow you to change this pin state 855 00:42:38,880 --> 00:42:40,960 without the chip itself actually running. 856 00:42:44,040 --> 00:42:45,960 These are a couple of JTAG pinouts. 857 00:42:47,160 --> 00:42:49,040 And this is the shift register. 858 00:42:49,040 --> 00:42:52,060 I'm going to go over this more in the Q&A section. 859 00:42:52,700 --> 00:42:54,840 This is an EPROM dumper that somebody built. 860 00:42:55,360 --> 00:42:56,620 EPROMs are an older technology. 861 00:42:56,720 --> 00:42:59,220 They predate Flash and are used for mass data storage. 862 00:43:00,400 --> 00:43:03,400 Generally, they were UV erasable or electrically erasable 863 00:43:03,400 --> 00:43:06,840 and just used to store the code of a system. 864 00:43:07,440 --> 00:43:09,540 I had some good luck with a magnetic card reader 865 00:43:09,540 --> 00:43:11,160 that had all of its code in one of these. 866 00:43:11,440 --> 00:43:13,320 And so reverse engineering the protocol 867 00:43:13,320 --> 00:43:14,660 that it spoke over its serial port 868 00:43:14,660 --> 00:43:17,320 was as simple as pulling the chip, putting it in a reader, 869 00:43:17,320 --> 00:43:21,000 and then taking the read-out version of the software 870 00:43:21,000 --> 00:43:22,140 and throwing it through IDAPRO, 871 00:43:22,260 --> 00:43:23,520 which I'm sure a lot of you have used. 872 00:43:23,680 --> 00:43:24,660 Show of hands, maybe. 873 00:43:26,320 --> 00:43:27,080 IDAPRO represent. 874 00:43:28,380 --> 00:43:32,340 Another thing where resources from the embedded engineering 875 00:43:32,340 --> 00:43:34,460 or forward engineering process come in handy 876 00:43:34,460 --> 00:43:37,480 is when you got decompiled binary. 877 00:43:37,920 --> 00:43:40,580 So first thing you look for are vectors 878 00:43:40,580 --> 00:43:42,560 that are defined in the chip spec, 879 00:43:42,660 --> 00:43:44,900 like the reset vectors, the interrupt table vectors, 880 00:43:45,060 --> 00:43:47,300 and figure out where the components 881 00:43:47,320 --> 00:43:48,860 of the code starts and where it goes 882 00:43:48,860 --> 00:43:51,900 when it jumps from the code it's executing to an interrupt. 883 00:43:52,420 --> 00:43:54,900 The general first interrupt that's going to get serviced 884 00:43:54,900 --> 00:43:56,780 when the chip starts up is the reset interrupt vector. 885 00:43:57,060 --> 00:43:58,140 If you can find out where that is, 886 00:43:58,200 --> 00:43:59,800 that's the entry point for your code. 887 00:44:00,000 --> 00:44:01,480 You just tell IDA this is the entry point 888 00:44:01,480 --> 00:44:02,760 and it'll figure it out. 889 00:44:03,400 --> 00:44:05,340 Exactly, the G-spot, as it were. 890 00:44:05,680 --> 00:44:07,800 The flash dumper thing I was talking about up there, 891 00:44:07,920 --> 00:44:10,520 that is for accessing more modern stuff, 892 00:44:10,680 --> 00:44:14,080 these 48-pin thin small outline package flash chips. 893 00:44:14,740 --> 00:44:17,140 It turns out that XD cards 894 00:44:17,320 --> 00:44:19,300 for cameras and smart media cards for cameras 895 00:44:19,300 --> 00:44:21,720 are basically NAND flash in a funny package. 896 00:44:22,320 --> 00:44:23,860 They're exactly the same interface 897 00:44:23,860 --> 00:44:27,600 and you can use one of them to build a flash dumper 898 00:44:27,600 --> 00:44:29,000 that you can just clip onto the chip 899 00:44:29,000 --> 00:44:31,960 and, depending on the electrical characteristics of the board, 900 00:44:32,120 --> 00:44:35,000 dump the flash via a USB cable. 901 00:44:36,100 --> 00:44:37,260 It's... two minutes? 902 00:44:37,300 --> 00:44:38,940 I actually have one up here. 903 00:44:40,760 --> 00:44:42,060 It's incredibly ghetto-looking 904 00:44:42,060 --> 00:44:44,260 and got me all sorts of funny looks on the airplane over here, 905 00:44:44,360 --> 00:44:47,100 but that's the card reader and I just desoldered the socket 906 00:44:47,320 --> 00:44:49,720 and then hooked up little metal bits to connect. 907 00:44:49,800 --> 00:44:51,800 They basically clip onto the chip itself. 908 00:44:52,100 --> 00:44:53,180 Then you can just use DD. 909 00:44:53,300 --> 00:44:54,580 You get a hex image out of that 910 00:44:54,580 --> 00:44:55,880 and throw it into IDA Pro. 911 00:44:56,260 --> 00:44:59,680 If anyone has any questions about how to hack this 912 00:44:59,680 --> 00:45:00,920 and write your own firmware, 913 00:45:01,100 --> 00:45:02,500 we're going to be in the QA room later 914 00:45:02,500 --> 00:45:05,700 and I've got a development environment set up on my laptop, 915 00:45:06,000 --> 00:45:07,980 but I'd like to take these last couple minutes 916 00:45:07,980 --> 00:45:10,020 to let everyone know that 917 00:45:10,860 --> 00:45:12,780 the best way to get started in this 918 00:45:12,780 --> 00:45:15,160 is to see who else is interested in the area 919 00:45:15,160 --> 00:45:16,940 and start a hackerspace. 920 00:45:17,320 --> 00:45:20,000 The Hacker Foundation has a hackerspaces initiative 921 00:45:20,000 --> 00:45:22,060 where they'll help you. 922 00:45:22,300 --> 00:45:24,000 Once you get a group of people together 923 00:45:24,000 --> 00:45:25,460 that's motivated to get your own space, 924 00:45:25,700 --> 00:45:27,520 they'll get you under the nonprofit umbrella 925 00:45:28,180 --> 00:45:32,140 and help deal with the managerial aspects of maintaining it 926 00:45:32,140 --> 00:45:36,940 and basically make sure that you're on the track for success. 927 00:45:38,600 --> 00:45:41,400 And the Hacker Foundation needs your support. 928 00:45:42,020 --> 00:45:44,960 I guess the Riviera kind of raped them 929 00:45:44,960 --> 00:45:46,400 with some stuff they had shipped here 930 00:45:46,400 --> 00:45:49,840 because they charged $30 a box for receiving it 931 00:45:50,350 --> 00:45:54,480 and they lost over $400 that way. 932 00:45:54,680 --> 00:45:56,780 So they need your support. 933 00:45:56,980 --> 00:45:58,820 They're selling t-shirts in the vendor area 934 00:45:59,400 --> 00:46:01,140 and please show your support 935 00:46:01,140 --> 00:46:04,620 and ask Nick if there's any hackerspaces 936 00:46:05,310 --> 00:46:07,100 which are setting up in your city 937 00:46:07,100 --> 00:46:08,100 if you're interested. 938 00:46:08,560 --> 00:46:09,960 Thank you all for coming. 939 00:46:10,100 --> 00:46:12,560 I hope you found something of interest in this. 940 00:46:18,360 --> 00:46:18,900 Thank you.