1 00:00:00,000 --> 00:00:00,660 All right. 2 00:00:00,660 --> 00:00:02,500 Thank you, everyone, for coming out. 3 00:00:02,800 --> 00:00:06,460 And apologies, there's a little delay, as happens with these things. 4 00:00:06,500 --> 00:00:09,120 But we're gonna go pretty fast. 5 00:00:09,120 --> 00:00:17,940 We have a lot to go over, thanks in no part to our Silicon vendors, our supply chain, our DHL. 6 00:00:18,580 --> 00:00:27,060 But yeah, we're excited to talk about behind the badge and a little on how we use an abuse hardware to create the ADS-B receiver on a badge for the Aerospace Emotions here. 7 00:00:27,100 --> 00:00:28,000 My name is Adam Latorre. 8 00:00:28,000 --> 00:00:29,440 This is Robert Bradford. 9 00:00:29,860 --> 00:00:31,560 And let's get into it. 10 00:00:32,260 --> 00:00:36,160 So we start off with some theory and some practice. 11 00:00:36,340 --> 00:01:04,990 But the theory of the badge is when, yeah, the idea we have for the badge is actually one that Aerospace Village has had kind of in the back pocket for a while, which is it wouldn't be so super cool to do an ADS-B receiver on a badge, fully integrated and able to run without needing a network connection from a service like FlightAware or anything that feeds community crowdsource ADS-B. 12 00:01:05,030 --> 00:01:14,030 So for those of you that might not be aware, ADS-B is, or Automatic Dependent Surveillance Broadcast, is a protocol. 13 00:01:14,030 --> 00:01:17,830 It's a type of signal that's a very important aspect of aviation safety. 14 00:01:17,830 --> 00:01:30,230 It is transmitted between airplanes, between ground stations, and in some cases even with satellites that can transmit a whole host of messages between different stations. 15 00:01:30,230 --> 00:01:41,110 The most relevant for us are things like call signs, flight numbers, ICAO addresses, altitude, headings, so information about planes that you can see flying overhead. 16 00:01:42,010 --> 00:01:58,230 And while it's intended uses for safety and air traffic control, a common hobbyist and enthusiast use case is it's just cool to be able to see a map of all the planes and aircraft around you overhead and be able to see what flight number it is, it's heading, 17 00:01:58,230 --> 00:01:59,890 where it's going, flight plans. 18 00:02:00,650 --> 00:02:11,170 And ADS-B itself can exist over multiple types of data links, but when we say ADS-B, the most common physical medium that it's sent over is the MODIS downlink at 1090 megahertz. 19 00:02:11,490 --> 00:02:17,010 And if you want more information on ADS-B or what it's used for, talk to the Aerospace Militia. 20 00:02:18,450 --> 00:02:29,730 But where we come in as like hardware design and badge designers is how do we actually, we have this signal, we know what we want to receive, but how do we actually implement and make a badge that can receive this signal? 21 00:02:30,850 --> 00:02:37,790 So the most common like enthusiast receivers utilize SDRs or software defined radios like the RTL-SDR. 22 00:02:38,030 --> 00:02:44,670 And because this was designed a long time ago, the protocol and the modulation is actually fairly simple to demodulate and decode. 23 00:02:44,670 --> 00:02:48,230 It's on-off keyed, which is effectively digital amplitude modulation. 24 00:02:48,230 --> 00:02:49,410 It's either on or off. 25 00:02:49,410 --> 00:02:53,550 You're either getting RF or you are not on the 1090 megahertz. 26 00:02:53,550 --> 00:03:00,530 And the data bits themselves are Manchester encoded, meaning that the data exists in the transitions between 1 and 0 or 0 and 1. 27 00:03:01,370 --> 00:03:09,390 Now to do this on a badge, if you want to do a so -called real SDR receiver, the chips that are required for that is expensive. 28 00:03:09,390 --> 00:03:16,450 They are like very high-end RF chipsets and it's way too expensive to put on a badge. 29 00:03:16,910 --> 00:03:22,030 Think of something like a Hyper-RF, for example, as a proper SDR. 30 00:03:22,510 --> 00:03:30,790 The SDRs like the RTL-SDR uses a DVB-T, which is a digital terrestrial broadcast television. 31 00:03:30,950 --> 00:03:40,230 And they overdrive those chips to run faster than they're intended to, which lets you get into that 1090 megahertz band and then receive it and decode it in software. 32 00:03:40,830 --> 00:03:55,890 One of the issues that we found when we started looking into using one of these DVB-T tuner chips ourselves, though, is that they are very power-hungry, especially when being overdriven to hit the 1090 megahertz band. 33 00:03:56,010 --> 00:04:02,130 And in addition to just getting really, really hot, the battery life of the badge would be next to zero. 34 00:04:02,710 --> 00:04:04,870 So we had to come up with a new way to do it. 35 00:04:05,190 --> 00:04:09,690 And the third major way of receiving ADS-B is the Log-Amp architecture. 36 00:04:09,690 --> 00:04:17,330 This uses a very fast RF power level meter, which converts the logarithmic received RF power into a linear output voltage. 37 00:04:17,730 --> 00:04:25,950 And in this mode, it can act as an envelope detector when filtered with some very tight 1090 megahertz saw filters. 38 00:04:26,350 --> 00:04:44,790 So the way that the architecture, the receive chain works, is that you get the entire RF spectrum coming in through your antenna that gets amplified and filtered and amplified and filtered again through very tight 1090 megahertz bandpass filters. 39 00:04:44,790 --> 00:04:51,210 So we can extract only the very specific slice of the spectrum that is centered at 1090 megahertz. 40 00:04:51,470 --> 00:05:02,130 And then because the signal that we are trying to demodulate is just on and off, the RF power meter will let us know, is it seeing no RF or is it seeing more RF? 41 00:05:02,210 --> 00:05:13,730 And that lets us turn the 1090 megahertz ADS-B packets in the air into a two megahertz baseband level output. 42 00:05:14,450 --> 00:05:26,730 And we actually used an amplifier and anti-aliasing filter chip from a composite video receiver because it is very cheap. 43 00:05:26,730 --> 00:05:38,590 If you want to buy an eighth order Butterworth filter with multiple channels and power amplifiers and clamp diodes, well, analog devices would love to charge you a lot of money for that. 44 00:05:38,730 --> 00:05:42,790 But if you want the... I mean, no one uses composite video anymore, right? 45 00:05:42,790 --> 00:05:53,650 But if you want this composite video amplifier with an eighth order Butterworth filter implemented into it and multiple chains and an amplifier, well, please take it. 46 00:05:53,690 --> 00:05:55,570 Who uses composite video? 47 00:05:56,950 --> 00:06:01,850 But the last step in this process is digitizing the signal itself. 48 00:06:02,990 --> 00:06:08,290 Again, the common way of doing it is to put it into a fast analog to digital converter, an ADC. 49 00:06:08,390 --> 00:06:14,210 But again, high-performance RF-intended ADCs are expensive. 50 00:06:14,730 --> 00:06:19,810 And when trying to optimize design, the best chip is no chip. 51 00:06:21,970 --> 00:06:26,670 So the SoC that we're using for the main Linux component of the badge is the Allwinner T113. 52 00:06:26,670 --> 00:06:31,510 It has dual Cortex-A7s, and we'll get into some more of the specs a little bit later. 53 00:06:31,690 --> 00:06:38,650 But it doesn't have any fast ADCs on board, at least nothing that's actually fast enough to demodulate ADS-B. 54 00:06:38,690 --> 00:06:43,630 Well, it is intended actually for automotive video applications. 55 00:06:43,630 --> 00:06:46,850 So it has multiple video inputs and outputs. 56 00:06:46,850 --> 00:06:51,190 And one of the supported video input modes is composite video. 57 00:06:51,190 --> 00:07:01,230 Well, if you know your composite video trivia, the baseband signal has frequency components that require at least a 27-megasample ADC. 58 00:07:01,250 --> 00:07:15,910 And sure enough, if you look at the block diagram we have in our datasheet, it says that on the left side next to the PGA is an ADC block, because you must have a fast ADC to be able to digitize composite video. 59 00:07:18,330 --> 00:07:25,270 And it's a fast ADC, but if you actually go back, you can see the ADC is not isolated. 60 00:07:25,270 --> 00:07:27,970 It's wrapped inside a bunch of filters. 61 00:07:27,970 --> 00:07:29,250 You have the PGA. 62 00:07:29,250 --> 00:07:34,030 You have all the hardware blocks that are designed to demodulate composite video. 63 00:07:34,030 --> 00:07:36,390 So you don't get raw samples from the ADC. 64 00:07:36,390 --> 00:07:38,650 You get pixels, basically. 65 00:07:38,650 --> 00:07:39,750 So it tries to find the lock. 66 00:07:39,750 --> 00:07:40,850 It tries to find H-sync. 67 00:07:40,850 --> 00:07:42,170 It tries to find V-sync. 68 00:07:42,190 --> 00:07:50,890 It has built-in filters to do color correction, which means that as it stands, it could not receive ADS-B. 69 00:07:50,890 --> 00:07:54,870 It couldn't actually get you samples, because it would just always say, oh, I can't find a signal. 70 00:07:54,870 --> 00:07:57,590 I can't see a video signal, and just do nothing. 71 00:07:57,990 --> 00:08:00,610 But the ADC itself is in the silicon. 72 00:08:00,730 --> 00:08:04,870 And as we like to say, we paid for the whole silicon, and we want to use the whole silicon. 73 00:08:05,610 --> 00:08:11,370 And, well, we had to do some reverse engineering on how to be able to disable these filters. 74 00:08:11,370 --> 00:08:22,790 And we were able to discover certain undocumented registers that... some undocumented registers in the all-owner chip itself that let you put it into this special manufacturing test mode. 75 00:08:22,790 --> 00:08:31,470 See, making fast ADCs, the reason it's expensive and isolation is that it's kind of hard to fabricate and then verify the harmonic performance of. 76 00:08:31,730 --> 00:08:42,050 So, the silicon manufacturer will put in these modes that let you basically bypass out the actual video, the H-sync, V-sync blocks, because those would probably work. 77 00:08:42,050 --> 00:08:48,430 But the ADC itself can then be isolated in the special test mode, which can get you the true raw samples out. 78 00:08:48,490 --> 00:08:51,670 And then when you have the true raw samples, you can verify the performance. 79 00:08:51,830 --> 00:08:58,370 So, that's exactly what we want, to be able to abuse this as a standalone straightforward ADC. 80 00:08:59,070 --> 00:09:02,170 And that's exactly what we did. 81 00:09:02,170 --> 00:09:15,370 We did some reverse engineering, we found the registers, and when we put into this test mode, as you can see from the trace, that is pulled from a badge with the RF front end attached. 82 00:09:15,370 --> 00:09:23,250 That is the ADSB preamble and the start of a data packet being received as raw samples from the onboard ADC. 83 00:09:23,970 --> 00:09:26,250 And actually, I will go back. 84 00:09:26,450 --> 00:09:34,150 You see the preamble pattern, the 101-101, and that's exactly what we're seeing on the output of our ADC. 85 00:09:34,590 --> 00:09:38,770 And this was our proof of concept to say that, okay, we can actually do this. 86 00:09:38,770 --> 00:09:52,490 We can get away with not using any external ADC or SDR chips or really anything intended to be used in this way, except like the saw filters, and do it fully integrated on just the core Linux SoC. 87 00:09:54,770 --> 00:10:02,830 Now, as I said, the specs of the badge itself, outside of just the RF, we are running full mainline Linux 6.6. 88 00:10:02,990 --> 00:10:07,910 We thought it would be really cool to bring basically a Linux death kit on a board. 89 00:10:08,330 --> 00:10:20,870 And since we have the power of our SoC to do the RF decoding, and we have to write a bunch of software to manage the Wi-Fi and everything, we're like, hey, instead of writing all the drivers ourselves, mainline Linux is out there, and it's great. 90 00:10:20,870 --> 00:10:21,770 Let's use it. 91 00:10:22,330 --> 00:10:28,430 Our display is a 40 by 40 circular display, which we got custom manufactured for us. 92 00:10:30,610 --> 00:10:35,070 A lot of people actually thought, it's not a smart watch screen. 93 00:10:36,050 --> 00:10:48,750 We actually don't really know where it's from, but when our display manufacturer said, hey, guys, we have these like cool, we have the circular displays you're talking about, and this 2.7 inch form factor, what do you think? 94 00:10:48,750 --> 00:10:49,950 We're like, this is perfect. 95 00:10:49,950 --> 00:10:53,050 It looks like a radar scope, it looks like an oscilloscope. 96 00:10:53,050 --> 00:10:53,970 Let's go. 97 00:10:54,870 --> 00:11:07,790 Outside of the ADC, on the core T113 SoC itself, we have the dual core A7s running at 1.2 gigahertz each, and that's the application processor cluster that is running Linux. 98 00:11:07,970 --> 00:11:26,610 And then another bonus that we got on our silicon is the HiFi4 DSP, which we'll talk about a little bit more in a few slides, but that's a DSP core that's designed to be an audio core processor that we are, again, reprogramming outside the manufacturer's use case to actually do the demodulation, 99 00:11:26,610 --> 00:11:29,650 Manchester decode, and ADS-B bit slicing. 100 00:11:30,890 --> 00:11:41,770 In the package, we have embedded 120 megs of DDR3 SD-RAM, 8 gigabytes of VMMC onboard storage, and some other RF implementations. 101 00:11:41,770 --> 00:11:44,830 We have GPS and Wi-Fi, because why not? 102 00:11:44,830 --> 00:11:46,030 We're already going all out. 103 00:11:46,030 --> 00:11:50,370 We're already doing full custom RF and printed PCB antennas. 104 00:11:50,710 --> 00:11:51,710 Let's go for broke. 105 00:11:51,710 --> 00:11:52,650 Let's add GPS. 106 00:11:52,650 --> 00:11:53,830 Let's add Wi-Fi. 107 00:11:55,510 --> 00:11:57,850 So that's all in theory. 108 00:11:58,790 --> 00:12:04,930 Before that, I think there's a badge giveaway that's going to be... Okay, I'll keep going. 109 00:12:04,930 --> 00:12:06,070 Okay, okay. 110 00:12:08,170 --> 00:12:10,830 So now this is all what we had in theory. 111 00:12:10,830 --> 00:12:28,110 This is what came up with the designs, and then we get it manufactured by our manufacturer, and then they come back, and now we actually get to implement it and go through all the crazy systems and actually do the reverse engineering and make sure that we can actually get this ADS-B receiver running inside of this badge. 112 00:12:28,690 --> 00:12:43,390 So you'd think the most challenging part of this whole design process would be the fully custom ADS-B receiver running with an ADC in an undocumented test mode, and then piping it into an audio DSP, which was never designed with the goal of actually doing ADS-B decoding. 113 00:12:43,430 --> 00:12:45,410 But that was actually the easiest part. 114 00:12:45,410 --> 00:12:46,890 We had the RF. 115 00:12:46,890 --> 00:12:53,430 Adam, being a mad lad, made a full zero to tri-band microwave RF in just four months. 116 00:12:53,570 --> 00:12:55,490 This is his first RF project. 117 00:12:58,050 --> 00:13:09,590 And then the TV decoder code, we got it working after a night of debugging, and we actually had a cool oscilloscope mode that we could actually read directly from the ADC in and get it plotted on our screen. 118 00:13:09,950 --> 00:13:17,910 And then we got the DSP code execution in a week, and then after that we did a week for Linux kernel dev, and then a week for algorithms, and we got ADS-B. 119 00:13:17,910 --> 00:13:19,390 That was the easy part. 120 00:13:19,470 --> 00:13:28,610 It was everything else that should have just worked that didn't, mainly which if any of you guys have ever worked with USB-C before can probably understand why it's USB-C. 121 00:13:28,690 --> 00:13:36,230 And then of course the AXP2585 battery management chip, which we will go into more detail later about the whole experience with that. 122 00:13:37,890 --> 00:13:45,310 So before we get into the more challenging parts, here's a quick guide on running code on your HiFi4 DSP. 123 00:13:45,610 --> 00:13:52,710 So the Allwinner T113, it has a HiFi4 DSP, and they advertise it as, oh, you have a third core. 124 00:13:52,710 --> 00:13:55,430 But what they don't tell you is that they only give you the firmware. 125 00:13:55,430 --> 00:14:01,850 It's like a blob that gets loaded in, and it's only for audio processing because it has an audio out, and it does all the codecs with that. 126 00:14:02,330 --> 00:14:06,630 And the mainline kernel doesn't even touch the DSP. 127 00:14:06,750 --> 00:14:13,350 But it is its own CPU core, it can be programmed, and if you find the right resources, you can actually program it. 128 00:14:13,350 --> 00:14:23,110 Because we're doing all of these ADSB processing, we want to try and get the maximum performance to get as high speed out as possible so we can increase the sample rate and have better performance. 129 00:14:23,270 --> 00:14:35,350 So we wanted to do the full SIMD vectorization and actually use the real HiFi4 toolchain from the vendor, rather than using a lot of like the open source ones you might find with ESP32 running with GCC. 130 00:14:36,030 --> 00:14:49,950 So if you find the extensive toolchain, you get the extensive toolchain and compiler with the vendor tools, but you also need to actually get the custom vendor IP block which was used to generate that exact silicon. 131 00:14:50,030 --> 00:14:55,310 The great part about HiFi4 is it can be exactly customized to the exact chip you want to build. 132 00:14:55,370 --> 00:14:59,170 So if you want to have all of these advanced vector units, you can add them in. 133 00:14:59,170 --> 00:15:07,330 If not, you can remove them, you can have however many registers you want, and it's all configurable to the silicon vendor, but that means that the compiler needs to know what it has available. 134 00:15:07,590 --> 00:15:18,530 And the way they do that is a full blob which has full Verilog for the chip that actually gets produced as just a giant zip file, and you load it all into the toolchain and it figures out how to program for your chip. 135 00:15:18,870 --> 00:15:31,550 So once you find that, then you have to compare that with the exact version of the extensive toolchain that it was built with, and then you have to locate all the drivers from Allwinner and source them and gather them up to actually do the interrupt controller, 136 00:15:31,550 --> 00:15:35,610 timers, mailbox, and then you just download the FreeRTOS port from GitHub. 137 00:15:35,670 --> 00:15:44,350 And you combine them all together, and you can actually get one of the most stable development environments we've had on this entire badge, where you just run Extended Explorer and it just works. 138 00:15:44,450 --> 00:15:47,430 So that's kind of the process for getting DSP. 139 00:15:49,570 --> 00:16:03,310 And now actually for Linux on the badge, we are again, we mentioned we're using mainline Linux, and that actually drastically sped up the dev time, where you don't have to do, a lot of the drivers came pre-baked, you just have to configure them correctly. 140 00:16:03,310 --> 00:16:04,570 It just works. 141 00:16:04,750 --> 00:16:13,670 But you have to figure out how to configure it, so a lot of the time it's finding magical incantations and device trees that you forget to set, that cause it to panic, all of that. 142 00:16:13,670 --> 00:16:22,690 And then if you put all the things together and you figure out that it should be working, but it's not, then it's a bug, and then you spend three weeks doing advanced kernel debugging, figuring out why your display is not working. 143 00:16:23,370 --> 00:16:25,690 Speaking of which, display trivia. 144 00:16:25,950 --> 00:16:39,610 Take a guess, which of these four options caused the artifacting of the clock being messed up, you have too large of a back porch, there's an unknown silicon bug that only happens when the Linux driver sets an undocumented bit, which just happens to exist in a sister chip, 145 00:16:39,610 --> 00:16:46,530 but is not in our system on chip, or the display controller registers were initialized in the wrong order, they never tell you the right order. 146 00:16:48,510 --> 00:16:55,570 The answer is E, you didn't seat the cable properly when you're trying to solve all the other previous ones, and you're trying to debug the issue above. 147 00:16:55,910 --> 00:16:57,570 This is the silicon bug. 148 00:16:59,150 --> 00:17:12,770 So this was just a fun thing, and we spent three weeks trying to solve this silicon bug right here, where actually the display would turn green, and it was because they were setting some, the driver for the sister chip had a bit which they were setting, 149 00:17:12,770 --> 00:17:28,650 but it caused this chip to glitch in a weird way, causing the MSB of that green channel to be set high, but it only occurred on this one, and you have to go through all 10,000 lines of the display driver and find the exact line you have to comment out which caused the display not to turn green. 150 00:17:28,650 --> 00:17:31,530 But if you do that, then you have a working screen. 151 00:17:33,950 --> 00:17:36,410 So here's a continuation of the meme. 152 00:17:36,830 --> 00:17:43,210 The AXV2585 has been the thing that has been battling us and fighting us for the entire badge. 153 00:17:45,090 --> 00:17:50,270 So this chip, it's just a USB-C negotiator, battery charger, BME all-in-one. 154 00:17:50,270 --> 00:17:53,690 It's actually a very unique chip, because there's not that many that do all of these. 155 00:17:53,690 --> 00:17:56,490 A lot of the time you have to get several chips and stitch them together. 156 00:17:56,690 --> 00:18:03,230 So there's no firmware, it's not like some embedded 8081 core, 8051 core, all that. 157 00:18:03,230 --> 00:18:06,610 It's just basic I2C registers you need to configure. 158 00:18:07,210 --> 00:18:09,070 How difficult could it be to program? 159 00:18:09,070 --> 00:18:10,490 It's just flip-flops, right? 160 00:18:12,110 --> 00:18:18,650 There were several bugs that we found in the AXV2585, and all of them battled us throughout development. 161 00:18:18,650 --> 00:18:26,050 From the first bring up, we've had battery detection, which says it should try and detect if there's a battery and not try and charge it if it doesn't see one. 162 00:18:26,070 --> 00:18:36,610 But they say it should always try and do that by default, but all of the chips we get actually are cleared and they assume a battery is present, causing weird instability until you program it in the boot loader and in Linux. 163 00:18:36,870 --> 00:18:46,890 There's also fun things where if you get power or any sort of hardware glitches, it causes undefined results in the silicon, where certain registers stop working or things stop writing. 164 00:18:47,610 --> 00:18:58,050 There's also the joys of USB Type-C, where we learned that if you plug it into certain model MacBooks, instead of the MacBook charging the badge, the badge will try to charge the MacBook, which does not work. 165 00:18:59,430 --> 00:19:14,070 And there's also the biggest thing that actually delayed us a lot right at DEF CON when we were trying to solve this, and we spent a big part of the time when we were trying to get things ready, trying to debug why the actual IRQ pin to interrupt the Linux kernel and say data is available, 166 00:19:14,070 --> 00:19:16,410 actually not going low. 167 00:19:16,790 --> 00:19:19,410 And this was all due to a certain manufacturing issue. 168 00:19:19,410 --> 00:19:27,090 It was not actually a bug in the chip or a configuration issue, but one of the pins was not soldered correctly by the board manufacturer. 169 00:19:27,090 --> 00:19:43,370 It passed all visual inspection, but one of the ground pins was not soldered well enough, and it got just enough of a ground pin connection through the other ground pad that it worked enough, but not enough to have a bunch of weird glitches and voltage dropping out and weird chip instability. 170 00:19:43,610 --> 00:20:00,030 So we have probably... this AXP2585, it's a great chip for the cost and everything, but the true cost for this chip is really in the development hours of all these bugs trying to solve the USB-C issues and bring up and try and figure out why the chip isn't booting. 171 00:20:00,090 --> 00:20:11,330 But if we wrangled it enough to actually get the badge running and we have a stable system, just make sure you have a battery in when booting up, because BMU gremlins will come up without it because of instabilities. 172 00:20:11,570 --> 00:20:13,390 So yeah. 173 00:20:17,450 --> 00:20:26,590 All right, so yeah, thank you so much for joining us for this overview. 174 00:20:26,590 --> 00:20:36,750 I know it's, as you can see, we've been battling gremlins for untold amount of time, so everything is a little bit rushed, but we have zero minutes. 175 00:20:36,750 --> 00:20:42,550 So if you have any questions, we will be more than happy to chat after either here at the village. 176 00:20:42,550 --> 00:20:44,090 Basically, come find us. 177 00:20:44,090 --> 00:20:45,530 We'd love to chat some more. 178 00:20:45,910 --> 00:20:53,030 And yeah, if you have a badge out there, tag us on the aerospace village Twitter. 179 00:20:53,030 --> 00:20:56,450 We'd love to see where they travel to and what planes are picking up. 180 00:20:56,790 --> 00:20:59,190 And with that, thank you.