WEBVTT

00:00.000 --> 00:00.660
All right.

00:00.660 --> 00:02.500
Thank you, everyone, for coming out.

00:02.800 --> 00:06.460
And apologies, there's a little delay, as happens with these things.

00:06.500 --> 00:09.120
But we're gonna go pretty fast.

00:09.120 --> 00:17.940
We have a lot to go over, thanks in no part to our Silicon vendors, our supply chain, our DHL.

00:18.580 --> 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.

00:27.100 --> 00:28.000
My name is Adam Latorre.

00:28.000 --> 00:29.440
This is Robert Bradford.

00:29.860 --> 00:31.560
And let's get into it.

00:32.260 --> 00:36.160
So we start off with some theory and some practice.

00:36.340 --> 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.

01:05.030 --> 01:14.030
So for those of you that might not be aware, ADS-B is, or Automatic Dependent Surveillance Broadcast, is a protocol.

01:14.030 --> 01:17.830
It's a type of signal that's a very important aspect of aviation safety.

01:17.830 --> 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.

01:30.230 --> 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.

01:42.010 --> 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,

01:58.230 --> 01:59.890
where it's going, flight plans.

02:00.650 --> 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.

02:11.490 --> 02:17.010
And if you want more information on ADS-B or what it's used for, talk to the Aerospace Militia.

02:18.450 --> 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?

02:30.850 --> 02:37.790
So the most common like enthusiast receivers utilize SDRs or software defined radios like the RTL-SDR.

02:38.030 --> 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.

02:44.670 --> 02:48.230
It's on-off keyed, which is effectively digital amplitude modulation.

02:48.230 --> 02:49.410
It's either on or off.

02:49.410 --> 02:53.550
You're either getting RF or you are not on the 1090 megahertz.

02:53.550 --> 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.

03:01.370 --> 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.

03:09.390 --> 03:16.450
They are like very high-end RF chipsets and it's way too expensive to put on a badge.

03:16.910 --> 03:22.030
Think of something like a Hyper-RF, for example, as a proper SDR.

03:22.510 --> 03:30.790
The SDRs like the RTL-SDR uses a DVB-T, which is a digital terrestrial broadcast television.

03:30.950 --> 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.

03:40.830 --> 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.

03:56.010 --> 04:02.130
And in addition to just getting really, really hot, the battery life of the badge would be next to zero.

04:02.710 --> 04:04.870
So we had to come up with a new way to do it.

04:05.190 --> 04:09.690
And the third major way of receiving ADS-B is the Log-Amp architecture.

04:09.690 --> 04:17.330
This uses a very fast RF power level meter, which converts the logarithmic received RF power into a linear output voltage.

04:17.730 --> 04:25.950
And in this mode, it can act as an envelope detector when filtered with some very tight 1090 megahertz saw filters.

04:26.350 --> 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.

04:44.790 --> 04:51.210
So we can extract only the very specific slice of the spectrum that is centered at 1090 megahertz.

04:51.470 --> 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?

05:02.210 --> 05:13.730
And that lets us turn the 1090 megahertz ADS-B packets in the air into a two megahertz baseband level output.

05:14.450 --> 05:26.730
And we actually used an amplifier and anti-aliasing filter chip from a composite video receiver because it is very cheap.

05:26.730 --> 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.

05:38.730 --> 05:42.790
But if you want the... I mean, no one uses composite video anymore, right?

05:42.790 --> 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.

05:53.690 --> 05:55.570
Who uses composite video?

05:56.950 --> 06:01.850
But the last step in this process is digitizing the signal itself.

06:02.990 --> 06:08.290
Again, the common way of doing it is to put it into a fast analog to digital converter, an ADC.

06:08.390 --> 06:14.210
But again, high-performance RF-intended ADCs are expensive.

06:14.730 --> 06:19.810
And when trying to optimize design, the best chip is no chip.

06:21.970 --> 06:26.670
So the SoC that we're using for the main Linux component of the badge is the Allwinner T113.

06:26.670 --> 06:31.510
It has dual Cortex-A7s, and we'll get into some more of the specs a little bit later.

06:31.690 --> 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.

06:38.690 --> 06:43.630
Well, it is intended actually for automotive video applications.

06:43.630 --> 06:46.850
So it has multiple video inputs and outputs.

06:46.850 --> 06:51.190
And one of the supported video input modes is composite video.

06:51.190 --> 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.

07:01.250 --> 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.

07:18.330 --> 07:25.270
And it's a fast ADC, but if you actually go back, you can see the ADC is not isolated.

07:25.270 --> 07:27.970
It's wrapped inside a bunch of filters.

07:27.970 --> 07:29.250
You have the PGA.

07:29.250 --> 07:34.030
You have all the hardware blocks that are designed to demodulate composite video.

07:34.030 --> 07:36.390
So you don't get raw samples from the ADC.

07:36.390 --> 07:38.650
You get pixels, basically.

07:38.650 --> 07:39.750
So it tries to find the lock.

07:39.750 --> 07:40.850
It tries to find H-sync.

07:40.850 --> 07:42.170
It tries to find V-sync.

07:42.190 --> 07:50.890
It has built-in filters to do color correction, which means that as it stands, it could not receive ADS-B.

07:50.890 --> 07:54.870
It couldn't actually get you samples, because it would just always say, oh, I can't find a signal.

07:54.870 --> 07:57.590
I can't see a video signal, and just do nothing.

07:57.990 --> 08:00.610
But the ADC itself is in the silicon.

08:00.730 --> 08:04.870
And as we like to say, we paid for the whole silicon, and we want to use the whole silicon.

08:05.610 --> 08:11.370
And, well, we had to do some reverse engineering on how to be able to disable these filters.

08:11.370 --> 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.

08:22.790 --> 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.

08:31.730 --> 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.

08:42.050 --> 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.

08:48.490 --> 08:51.670
And then when you have the true raw samples, you can verify the performance.

08:51.830 --> 08:58.370
So, that's exactly what we want, to be able to abuse this as a standalone straightforward ADC.

08:59.070 --> 09:02.170
And that's exactly what we did.

09:02.170 --> 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.

09:15.370 --> 09:23.250
That is the ADSB preamble and the start of a data packet being received as raw samples from the onboard ADC.

09:23.970 --> 09:26.250
And actually, I will go back.

09:26.450 --> 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.

09:34.590 --> 09:38.770
And this was our proof of concept to say that, okay, we can actually do this.

09:38.770 --> 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.

09:54.770 --> 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.

10:02.990 --> 10:07.910
We thought it would be really cool to bring basically a Linux death kit on a board.

10:08.330 --> 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.

10:20.870 --> 10:21.770
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:35.070
A lot of people actually thought, it's not a smart watch screen.

10:36.050 --> 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?

10:48.750 --> 10:49.950
We're like, this is perfect.

10:49.950 --> 10:53.050
It looks like a radar scope, it looks like an oscilloscope.

10:53.050 --> 10:53.970
Let's go.

10:54.870 --> 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.

11:07.970 --> 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,

11:26.610 --> 11:29.650
Manchester decode, and ADS-B bit slicing.

11:30.890 --> 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.

11:41.770 --> 11:44.830
We have GPS and Wi-Fi, because why not?

11:44.830 --> 11:46.030
We're already going all out.

11:46.030 --> 11:50.370
We're already doing full custom RF and printed PCB antennas.

11:50.710 --> 11:51.710
Let's go for broke.

11:51.710 --> 11:52.650
Let's add GPS.

11:52.650 --> 11:53.830
Let's add Wi-Fi.

11:55.510 --> 11:57.850
So that's all in theory.

11:58.790 --> 12:04.930
Before that, I think there's a badge giveaway that's going to be... Okay, I'll keep going.

12:04.930 --> 12:06.070
Okay, okay.

12:08.170 --> 12:10.830
So now this is all what we had in theory.

12:10.830 --> 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.

12:28.690 --> 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.

12:43.430 --> 12:45.410
But that was actually the easiest part.

12:45.410 --> 12:46.890
We had the RF.

12:46.890 --> 12:53.430
Adam, being a mad lad, made a full zero to tri-band microwave RF in just four months.

12:53.570 --> 12:55.490
This is his first RF project.

12:58.050 --> 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.

13:09.950 --> 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.

13:17.910 --> 13:19.390
That was the easy part.

13:19.470 --> 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.

13:28.690 --> 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.

13:37.890 --> 13:45.310
So before we get into the more challenging parts, here's a quick guide on running code on your HiFi4 DSP.

13:45.610 --> 13:52.710
So the Allwinner T113, it has a HiFi4 DSP, and they advertise it as, oh, you have a third core.

13:52.710 --> 13:55.430
But what they don't tell you is that they only give you the firmware.

13:55.430 --> 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.

14:02.330 --> 14:06.630
And the mainline kernel doesn't even touch the DSP.

14:06.750 --> 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.

14:13.350 --> 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.

14:23.270 --> 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.

14:36.030 --> 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.

14:50.030 --> 14:55.310
The great part about HiFi4 is it can be exactly customized to the exact chip you want to build.

14:55.370 --> 14:59.170
So if you want to have all of these advanced vector units, you can add them in.

14:59.170 --> 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.

15:07.590 --> 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.

15:18.870 --> 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,

15:31.550 --> 15:35.610
timers, mailbox, and then you just download the FreeRTOS port from GitHub.

15:35.670 --> 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.

15:44.450 --> 15:47.430
So that's kind of the process for getting DSP.

15:49.570 --> 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.

16:03.310 --> 16:04.570
It just works.

16:04.750 --> 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.

16:13.670 --> 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.

16:23.370 --> 16:25.690
Speaking of which, display trivia.

16:25.950 --> 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,

16:39.610 --> 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.

16:48.510 --> 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.

16:55.910 --> 16:57.570
This is the silicon bug.

16:59.150 --> 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,

17:12.770 --> 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.

17:28.650 --> 17:31.530
But if you do that, then you have a working screen.

17:33.950 --> 17:36.410
So here's a continuation of the meme.

17:36.830 --> 17:43.210
The AXV2585 has been the thing that has been battling us and fighting us for the entire badge.

17:45.090 --> 17:50.270
So this chip, it's just a USB-C negotiator, battery charger, BME all-in-one.

17:50.270 --> 17:53.690
It's actually a very unique chip, because there's not that many that do all of these.

17:53.690 --> 17:56.490
A lot of the time you have to get several chips and stitch them together.

17:56.690 --> 18:03.230
So there's no firmware, it's not like some embedded 8081 core, 8051 core, all that.

18:03.230 --> 18:06.610
It's just basic I2C registers you need to configure.

18:07.210 --> 18:09.070
How difficult could it be to program?

18:09.070 --> 18:10.490
It's just flip-flops, right?

18:12.110 --> 18:18.650
There were several bugs that we found in the AXV2585, and all of them battled us throughout development.

18:18.650 --> 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.

18:26.070 --> 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.

18:36.870 --> 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.

18:47.610 --> 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.

18:59.430 --> 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,

19:14.070 --> 19:16.410
actually not going low.

19:16.790 --> 19:19.410
And this was all due to a certain manufacturing issue.

19:19.410 --> 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.

19:27.090 --> 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.

19:43.610 --> 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.

20:00.090 --> 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.

20:11.570 --> 20:13.390
So yeah.

20:17.450 --> 20:26.590
All right, so yeah, thank you so much for joining us for this overview.

20:26.590 --> 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.

20:36.750 --> 20:42.550
So if you have any questions, we will be more than happy to chat after either here at the village.

20:42.550 --> 20:44.090
Basically, come find us.

20:44.090 --> 20:45.530
We'd love to chat some more.

20:45.910 --> 20:53.030
And yeah, if you have a badge out there, tag us on the aerospace village Twitter.

20:53.030 --> 20:56.450
We'd love to see where they travel to and what planes are picking up.

20:56.790 --> 20:59.190
And with that, thank you.

