[00:00.000 --> 00:04.260] All right. Thank you, everyone, for coming out. And apologies, there's a little delay, [00:04.260 --> 00:11.120] as happens with these things. But we're gonna go pretty fast. We have a lot to go over, [00:11.120 --> 00:19.100] thanks in no part to our Silicon vendors, our supply chain, our DHL. But yeah, we're excited [00:19.100 --> 00:24.640] to talk about behind the badge and a little on how we use an abuse hardware to create the ADS-B [00:24.640 --> 00:28.700] receiver on a badge for the Aerospace Emotions here. My name is Adam Latorre. This is Robert [00:28.700 --> 00:36.160] Bradford. And let's get into it. So we start off with some theory and some practice. [00:36.340 --> 00:47.330] But the theory of the badge is when, yeah, the idea we have for the badge is actually one that [00:47.330 --> 00:51.990] Aerospace Village has had kind of in the back pocket for a while, which is it wouldn't be so [00:51.990 --> 00:58.410] super cool to do an ADS-B receiver on a badge, fully integrated and able to run without needing [00:58.630 --> 01:03.390] a network connection from a service like FlightAware or anything that feeds community [01:03.390 --> 01:09.990] crowdsource ADS-B. So for those of you that might not be aware, ADS-B is, or Automatic Dependent [01:09.990 --> 01:16.470] Surveillance Broadcast, is a protocol. It's a type of signal that's a very important aspect [01:16.470 --> 01:21.790] of aviation safety. It is transmitted between airplanes, between ground stations, and in some [01:21.790 --> 01:30.230] cases even with satellites that can transmit a whole host of messages between different stations. [01:30.230 --> 01:34.530] The most relevant for us are things like call signs, flight numbers, ICAO addresses, [01:35.370 --> 01:41.110] altitude, headings, so information about planes that you can see flying overhead. [01:42.010 --> 01:49.410] And while it's intended uses for safety and air traffic control, a common hobbyist and enthusiast [01:49.410 --> 01:55.470] use case is it's just cool to be able to see a map of all the planes and aircraft around you overhead [01:55.470 --> 01:59.890] and be able to see what flight number it is, it's heading, where it's going, flight plans. [02:00.650 --> 02:05.870] And ADS-B itself can exist over multiple types of data links, but when we say ADS-B, the most [02:05.870 --> 02:12.630] common physical medium that it's sent over is the MODIS downlink at 1090 megahertz. And if you want [02:12.630 --> 02:17.010] more information on ADS-B or what it's used for, talk to the Aerospace Militia. [02:18.450 --> 02:23.850] But where we come in as like hardware design and badge designers is how do we actually, we have [02:23.850 --> 02:28.490] this signal, we know what we want to receive, but how do we actually implement and make a badge that [02:28.490 --> 02:35.650] can receive this signal? So the most common like enthusiast receivers utilize SDRs or software [02:35.650 --> 02:41.510] defined radios like the RTL-SDR. And because this was designed a long time ago, the protocol and the [02:41.510 --> 02:46.530] modulation is actually fairly simple to demodulate and decode. It's on-off keyed, which is effectively [02:46.530 --> 02:52.050] digital amplitude modulation. It's either on or off. You're either getting RF or you are not on [02:52.050 --> 02:56.970] the 1090 megahertz. And the data bits themselves are Manchester encoded, meaning that the data [02:56.970 --> 03:04.810] exists in the transitions between 1 and 0 or 0 and 1. Now to do this on a badge, if you want to do a [03:04.810 --> 03:10.990] so-called real SDR receiver, the chips that are required for that is expensive. They are like very [03:10.990 --> 03:17.830] high-end RF chipsets and it's way too expensive to put on a badge. Think of something [03:17.830 --> 03:28.450] like a Hyper-RF, for example, as a proper SDR. The SDRs like the RTL-SDR uses a DVB-T, which is a [03:28.450 --> 03:34.330] digital terrestrial broadcast television. And they overdrive those chips to run faster than they're [03:34.330 --> 03:39.470] intended to, which lets you get into that 1090 megahertz band and then receive it and decode it [03:39.470 --> 03:44.650] in software. One of the issues that we found when we started looking into using one of these DVB-T [03:44.650 --> 03:53.510] tuner chips ourselves, though, is that they are very power-hungry, especially when being overdriven [03:53.510 --> 03:59.710] to hit the 1090 megahertz band. And in addition to just getting really, really hot, the battery [03:59.710 --> 04:05.930] life of the badge would be next to zero. So we had to come up with a new way to do it. And the [04:05.930 --> 04:12.050] third major way of receiving ADS-B is the Log-Amp architecture. This uses a very fast RF power [04:12.050 --> 04:17.330] level meter, which converts the logarithmic received RF power into a linear output voltage. [04:17.730 --> 04:24.030] And in this mode, it can act as an envelope detector when filtered with some very tight [04:24.030 --> 04:31.650] 1090 megahertz saw filters. So the way that the architecture, the receive chain works, [04:31.650 --> 04:38.690] is that you get the entire RF spectrum coming in through your antenna that gets [04:38.690 --> 04:44.050] amplified and filtered and amplified and filtered again through very tight 1090 megahertz bandpass [04:44.050 --> 04:50.090] filters. So we can extract only the very specific slice of the spectrum that is centered at 1090 [04:50.090 --> 04:56.250] megahertz. And then because the signal that we are trying to demodulate is just on and off, [04:56.250 --> 05:02.130] the RF power meter will let us know, is it seeing no RF or is it seeing more RF? [05:02.210 --> 05:10.450] And that lets us turn the 1090 megahertz ADS-B packets in the air into a two megahertz [05:11.090 --> 05:20.890] baseband level output. And we actually used an amplifier and anti-aliasing filter chip from a [05:20.890 --> 05:30.650] composite video receiver because it is very cheap. If you want to buy an eighth order Butterworth [05:30.650 --> 05:36.810] filter with multiple channels and power amplifiers and clamp diodes, well, analog devices would love [05:36.810 --> 05:41.570] to charge you a lot of money for that. But if you want the... I mean, no one uses composite [05:41.570 --> 05:45.890] video anymore, right? But if you want this composite video amplifier with an eighth order [05:45.890 --> 05:52.650] Butterworth filter implemented into it and multiple chains and an amplifier, well, [05:52.650 --> 06:00.710] please take it. Who uses composite video? But the last step in this process is digitizing the [06:00.710 --> 06:06.890] signal itself. Again, the common way of doing it is to put it into a fast analog to digital [06:06.890 --> 06:16.730] converter, an ADC. But again, high-performance RF-intended ADCs are expensive. And when trying [06:16.730 --> 06:24.450] to optimize design, the best chip is no chip. So the SoC that we're using for the main Linux [06:24.450 --> 06:30.410] component of the badge is the Allwinner T113. It has dual Cortex-A7s, and we'll get into some more [06:30.410 --> 06:35.370] of the specs a little bit later. But it doesn't have any fast ADCs on board, at least nothing [06:35.370 --> 06:42.630] that's actually fast enough to demodulate ADS-B. Well, it is intended actually for automotive video [06:42.630 --> 06:49.650] applications. So it has multiple video inputs and outputs. And one of the supported video input modes [06:49.650 --> 06:55.170] is composite video. Well, if you know your composite video trivia, the baseband signal [06:55.170 --> 07:02.410] has frequency components that require at least a 27-megasample ADC. And sure enough, if you look at [07:02.410 --> 07:08.950] the block diagram we have in our datasheet, it says that on the left side next to the PGA [07:09.610 --> 07:15.910] is an ADC block, because you must have a fast ADC to be able to digitize composite video. [07:18.330 --> 07:25.550] And it's a fast ADC, but if you actually go back, you can see the ADC is not isolated. It's wrapped [07:25.550 --> 07:31.970] inside a bunch of filters. You have the PGA. You have all the hardware blocks that are designed [07:31.970 --> 07:38.150] to demodulate composite video. So you don't get raw samples from the ADC. You get pixels, [07:38.150 --> 07:42.170] basically. So it tries to find the lock. It tries to find H-sync. It tries to find V-sync. [07:42.190 --> 07:50.010] It has built-in filters to do color correction, which means that as it stands, it could not [07:50.010 --> 07:54.050] receive ADS-B. It couldn't actually get you samples, because it would just always say, [07:54.050 --> 07:59.210] oh, I can't find a signal. I can't see a video signal, and just do nothing. But the ADC itself [07:59.210 --> 08:03.910] is in the silicon. And as we like to say, we paid for the whole silicon, and we want to use the [08:03.910 --> 08:10.650] whole silicon. And, well, we had to do some reverse engineering on how to be able to disable these [08:10.650 --> 08:17.170] filters. And we were able to discover certain undocumented registers that... some undocumented [08:17.170 --> 08:22.070] registers in the all-owner chip itself that let you put it into this special manufacturing test [08:22.070 --> 08:28.270] mode. See, making fast ADCs, the reason it's expensive and isolation is that it's kind of [08:28.270 --> 08:33.970] hard to fabricate and then verify the harmonic performance of. So, the silicon manufacturer [08:33.970 --> 08:40.390] will put in these modes that let you basically bypass out the actual video, the H-sync, V-sync [08:40.390 --> 08:44.830] blocks, because those would probably work. But the ADC itself can then be isolated in the special [08:44.830 --> 08:50.130] test mode, which can get you the true raw samples out. And then when you have the true raw samples, [08:50.130 --> 08:55.710] you can verify the performance. So, that's exactly what we want, to be able to abuse this as a [08:55.710 --> 09:04.250] standalone straightforward ADC. And that's exactly what we did. We did some reverse engineering, [09:04.250 --> 09:09.750] we found the registers, and when we put into this test mode, as you can see from the trace, [09:09.750 --> 09:18.230] that is pulled from a badge with the RF front end attached. That is the ADSB preamble and [09:18.230 --> 09:23.250] the start of a data packet being received as raw samples from the onboard ADC. [09:23.970 --> 09:30.530] And actually, I will go back. You see the preamble pattern, the 101-101, [09:31.050 --> 09:34.150] and that's exactly what we're seeing on the output of our ADC. [09:34.590 --> 09:39.410] And this was our proof of concept to say that, okay, we can actually do this. We can get away [09:39.410 --> 09:45.850] with not using any external ADC or SDR chips or really anything intended to be used in this way, [09:45.850 --> 09:52.490] except like the saw filters, and do it fully integrated on just the core Linux SoC. [09:54.770 --> 10:01.050] Now, as I said, the specs of the badge itself, outside of just the RF, we are running full [10:01.050 --> 10:07.170] mainline Linux 6.6. We thought it would be really cool to bring basically a Linux death kit on [10:07.250 --> 10:14.210] a board. And since we have the power of our SoC to do the RF decoding, and we have to write a [10:14.210 --> 10:17.070] bunch of software to manage the Wi-Fi and everything, we're like, hey, instead of writing [10:17.070 --> 10:21.770] all the drivers ourselves, mainline Linux is out there, and it's great. Let's use it. [10:22.330 --> 10:28.430] Our display is a 40 by 40 circular display, which we got custom manufactured for us. [10:30.610 --> 10:37.670] A lot of people actually thought, it's not a smart watch screen. We actually don't really [10:37.670 --> 10:43.050] know where it's from, but when our display manufacturer said, hey, guys, we have these [10:43.050 --> 10:48.190] like cool, we have the circular displays you're talking about, and this 2.7 inch form factor, [10:48.190 --> 10:51.850] what do you think? We're like, this is perfect. It looks like a radar scope, [10:51.850 --> 10:58.970] it looks like an oscilloscope. Let's go. Outside of the ADC, on the core T113 SoC itself, [10:58.970 --> 11:05.430] we have the dual core A7s running at 1.2 gigahertz each, and that's the application processor [11:06.030 --> 11:12.450] cluster that is running Linux. And then another bonus that we got on our silicon is the HiFi4 DSP, [11:12.450 --> 11:17.690] which we'll talk about a little bit more in a few slides, but that's a DSP core that's [11:17.690 --> 11:24.170] designed to be an audio core processor that we are, again, reprogramming outside the manufacturer's [11:24.170 --> 11:29.650] use case to actually do the demodulation, Manchester decode, and ADS-B bit slicing. [11:30.890 --> 11:37.810] In the package, we have embedded 120 megs of DDR3 SD-RAM, 8 gigabytes of VMMC onboard storage, [11:37.810 --> 11:45.310] and some other RF implementations. We have GPS and Wi-Fi, because why not? We're already going [11:45.310 --> 11:51.810] all out. We're already doing full custom RF and printed PCB antennas. Let's go for broke. Let's [11:51.810 --> 12:00.890] add GPS. Let's add Wi-Fi. So that's all in theory. Before that, I think there's a badge [12:00.890 --> 12:06.070] giveaway that's going to be... Okay, I'll keep going. Okay, okay. [12:08.170 --> 12:12.450] So now this is all what we had in theory. This is what came up with the designs, [12:12.450 --> 12:17.090] and then we get it manufactured by our manufacturer, and then they come back, [12:17.090 --> 12:22.670] and now we actually get to implement it and go through all the crazy systems and actually do [12:22.670 --> 12:25.670] the reverse engineering and make sure that we can actually get this ADS-B receiver [12:25.670 --> 12:31.230] running inside of this badge. So you'd think the most challenging part of this whole design [12:31.230 --> 12:37.750] process would be the fully custom ADS-B receiver running with an ADC in an undocumented test mode, [12:37.750 --> 12:42.030] and then piping it into an audio DSP, which was never designed with the goal of actually doing [12:42.030 --> 12:49.210] ADS-B decoding. But that was actually the easiest part. We had the RF. Adam, being a mad lad, [12:49.210 --> 12:55.490] made a full zero to tri-band microwave RF in just four months. This is his first RF project. [12:58.050 --> 13:03.130] And then the TV decoder code, we got it working after a night of debugging, and we actually had [13:03.230 --> 13:08.530] a cool oscilloscope mode that we could actually read directly from the ADC in and get it plotted [13:08.530 --> 13:14.270] on our screen. And then we got the DSP code execution in a week, and then after that we did [13:14.370 --> 13:18.630] a week for Linux kernel dev, and then a week for algorithms, and we got ADS-B. That was the easy [13:18.630 --> 13:24.130] part. It was everything else that should have just worked that didn't, mainly which if any of you [13:24.130 --> 13:29.090] guys have ever worked with USB-C before can probably understand why it's USB-C. And then [13:29.090 --> 13:34.570] of course the AXP2585 battery management chip, which we will go into more detail later about [13:34.570 --> 13:41.510] the whole experience with that. So before we get into the more challenging parts, here's a quick [13:41.510 --> 13:50.550] guide on running code on your HiFi4 DSP. So the Allwinner T113, it has a HiFi4 DSP, and they [13:50.550 --> 13:54.430] advertise it as, oh, you have a third core. But what they don't tell you is that they only give [13:54.430 --> 13:58.730] you the firmware. It's like a blob that gets loaded in, and it's only for audio processing [13:58.730 --> 14:03.750] because it has an audio out, and it does all the codecs with that. And the mainline kernel doesn't [14:03.750 --> 14:11.010] even touch the DSP. But it is its own CPU core, it can be programmed, and if you find the right [14:11.010 --> 14:17.030] resources, you can actually program it. Because we're doing all of these ADSB processing, we want [14:17.030 --> 14:20.950] to try and get the maximum performance to get as high speed out as possible so we can increase the [14:20.950 --> 14:26.450] sample rate and have better performance. So we wanted to do the full SIMD vectorization and [14:26.450 --> 14:31.770] actually use the real HiFi4 toolchain from the vendor, rather than using a lot of like the [14:31.770 --> 14:37.650] open source ones you might find with ESP32 running with GCC. So if you find the extensive [14:37.650 --> 14:44.190] toolchain, you get the extensive toolchain and compiler with the vendor tools, but you also need [14:44.190 --> 14:50.470] to actually get the custom vendor IP block which was used to generate that exact silicon. The great [14:50.470 --> 14:55.850] part about HiFi4 is it can be exactly customized to the exact chip you want to build. So if you [14:55.850 --> 15:00.230] want to have all of these advanced vector units, you can add them in. If not, you can remove them, [15:00.230 --> 15:04.310] you can have however many registers you want, and it's all configurable to the silicon vendor, [15:04.310 --> 15:08.510] but that means that the compiler needs to know what it has available. And the way they do that [15:08.510 --> 15:13.870] is a full blob which has full Verilog for the chip that actually gets produced as just a giant [15:13.870 --> 15:18.530] zip file, and you load it all into the toolchain and it figures out how to program for your chip. [15:18.870 --> 15:23.110] So once you find that, then you have to compare that with the exact version of the extensive [15:23.110 --> 15:28.390] toolchain that it was built with, and then you have to locate all the drivers from Allwinner [15:28.390 --> 15:32.830] and source them and gather them up to actually do the interrupt controller, timers, mailbox, [15:32.830 --> 15:37.070] and then you just download the FreeRTOS port from GitHub. And you combine them all together, [15:37.070 --> 15:40.750] and you can actually get one of the most stable development environments we've had on this entire [15:40.750 --> 15:46.010] badge, where you just run Extended Explorer and it just works. So that's kind of the process for [15:46.010 --> 15:54.330] getting DSP. And now actually for Linux on the badge, we are again, we mentioned we're using [15:54.330 --> 15:59.250] mainline Linux, and that actually drastically sped up the dev time, where you don't have to do, [15:59.390 --> 16:04.570] a lot of the drivers came pre-baked, you just have to configure them correctly. It just works. [16:04.750 --> 16:09.010] But you have to figure out how to configure it, so a lot of the time it's finding magical [16:09.430 --> 16:13.670] incantations and device trees that you forget to set, that cause it to panic, all of that. [16:13.670 --> 16:16.730] And then if you put all the things together and you figure out that it should be working, [16:16.730 --> 16:20.710] but it's not, then it's a bug, and then you spend three weeks doing advanced kernel debugging, [16:20.710 --> 16:26.910] figuring out why your display is not working. Speaking of which, display trivia. Take a guess, [16:26.910 --> 16:31.170] which of these four options caused the artifacting of the clock being messed up, you have too large [16:31.170 --> 16:35.570] of a back porch, there's an unknown silicon bug that only happens when the Linux driver [16:35.570 --> 16:40.350] sets an undocumented bit, which just happens to exist in a sister chip, but is not in our [16:40.350 --> 16:44.910] system on chip, or the display controller registers were initialized in the wrong order, [16:44.910 --> 16:51.170] they never tell you the right order. The answer is E, you didn't seat the cable properly when [16:51.170 --> 16:55.570] you're trying to solve all the other previous ones, and you're trying to debug the issue above. [16:55.910 --> 17:02.870] This is the silicon bug. So this was just a fun thing, and we spent three weeks trying to solve [17:02.870 --> 17:07.510] this silicon bug right here, where actually the display would turn green, and it was because [17:07.510 --> 17:13.010] they were setting some, the driver for the sister chip had a bit which they were setting, but it [17:13.010 --> 17:19.210] caused this chip to glitch in a weird way, causing the MSB of that green channel to be set high, [17:19.210 --> 17:23.670] but it only occurred on this one, and you have to go through all 10,000 lines of the display [17:23.670 --> 17:28.650] driver and find the exact line you have to comment out which caused the display not to turn green. [17:28.650 --> 17:31.530] But if you do that, then you have a working screen. [17:33.950 --> 17:41.290] So here's a continuation of the meme. The AXV2585 has been the thing that has been battling us and [17:41.290 --> 17:49.170] fighting us for the entire badge. So this chip, it's just a USB-C negotiator, battery charger, [17:49.170 --> 17:53.690] BME all-in-one. It's actually a very unique chip, because there's not that many that do all of these. [17:53.690 --> 17:57.950] A lot of the time you have to get several chips and stitch them together. So there's no firmware, [17:57.950 --> 18:05.470] it's not like some embedded 8081 core, 8051 core, all that. It's just basic I2C registers [18:05.470 --> 18:10.490] you need to configure. How difficult could it be to program? It's just flip-flops, right? [18:12.110 --> 18:17.950] There were several bugs that we found in the AXV2585, and all of them battled us throughout [18:17.950 --> 18:22.430] development. From the first bring up, we've had battery detection, which says it should try and [18:22.430 --> 18:27.310] detect if there's a battery and not try and charge it if it doesn't see one. But they say it should [18:27.310 --> 18:31.310] always try and do that by default, but all of the chips we get actually are cleared and they assume [18:31.430 --> 18:35.930] a battery is present, causing weird instability until you program it in the boot loader and in [18:35.930 --> 18:41.030] Linux. There's also fun things where if you get power or any sort of hardware glitches, it causes [18:41.750 --> 18:46.890] undefined results in the silicon, where certain registers stop working or things stop writing. [18:47.610 --> 18:51.850] There's also the joys of USB Type-C, where we learned that if you plug it into certain model [18:51.850 --> 18:56.730] MacBooks, instead of the MacBook charging the badge, the badge will try to charge the MacBook, [18:56.730 --> 19:02.930] which does not work. And there's also the biggest thing that actually delayed us a lot right at [19:02.930 --> 19:07.330] DEF CON when we were trying to solve this, and we spent a big part of the time when we were trying [19:07.330 --> 19:12.490] to get things ready, trying to debug why the actual IRQ pin to interrupt the Linux kernel [19:12.490 --> 19:18.950] and say data is available, actually not going low. And this was all due to a certain manufacturing [19:18.950 --> 19:23.970] issue. It was not actually a bug in the chip or a configuration issue, but one of the pins was [19:23.970 --> 19:30.450] not soldered correctly by the board manufacturer. It passed all visual inspection, but one of the [19:30.450 --> 19:34.310] ground pins was not soldered well enough, and it got just enough of a ground pin connection [19:34.310 --> 19:39.730] through the other ground pad that it worked enough, but not enough to have a bunch of weird [19:39.730 --> 19:46.450] glitches and voltage dropping out and weird chip instability. So we have probably... this AXP2585, [19:46.990 --> 19:52.090] it's a great chip for the cost and everything, but the true cost for this chip is really in [19:52.090 --> 19:58.090] the development hours of all these bugs trying to solve the USB-C issues and bring up and try [19:58.090 --> 20:02.890] and figure out why the chip isn't booting. But if we wrangled it enough to actually get the badge [20:02.890 --> 20:07.430] running and we have a stable system, just make sure you have a battery in when booting up, [20:07.430 --> 20:13.390] because BMU gremlins will come up without it because of instabilities. So yeah. [20:17.450 --> 20:27.490] All right, so yeah, thank you so much for joining us for this overview. I know it's, [20:27.490 --> 20:32.270] as you can see, we've been battling gremlins for untold amount of time, [20:32.270 --> 20:38.290] so everything is a little bit rushed, but we have zero minutes. So if you have any questions, [20:38.290 --> 20:43.190] we will be more than happy to chat after either here at the village. Basically, [20:43.190 --> 20:49.410] come find us. We'd love to chat some more. And yeah, if you have a badge out there, [20:49.410 --> 20:54.690] tag us on the aerospace village Twitter. We'd love to see where they travel to [20:54.690 --> 20:59.190] and what planes are picking up. And with that, thank you.