start	end	text
0	4260	All right. Thank you, everyone, for coming out. And apologies, there's a little delay,
4260	11120	as happens with these things. But we're gonna go pretty fast. We have a lot to go over,
11120	19100	thanks in no part to our Silicon vendors, our supply chain, our DHL. But yeah, we're excited
19100	24640	to talk about behind the badge and a little on how we use an abuse hardware to create the ADS-B
24640	28700	receiver on a badge for the Aerospace Emotions here. My name is Adam Latorre. This is Robert
28700	36160	Bradford. And let's get into it. So we start off with some theory and some practice.
36340	47330	But the theory of the badge is when, yeah, the idea we have for the badge is actually one that
47330	51990	Aerospace Village has had kind of in the back pocket for a while, which is it wouldn't be so
51990	58410	super cool to do an ADS-B receiver on a badge, fully integrated and able to run without needing
58630	63390	a network connection from a service like FlightAware or anything that feeds community
63390	69990	crowdsource ADS-B. So for those of you that might not be aware, ADS-B is, or Automatic Dependent
69990	76470	Surveillance Broadcast, is a protocol. It's a type of signal that's a very important aspect
76470	81790	of aviation safety. It is transmitted between airplanes, between ground stations, and in some
81790	90230	cases even with satellites that can transmit a whole host of messages between different stations.
90230	94530	The most relevant for us are things like call signs, flight numbers, ICAO addresses,
95370	101110	altitude, headings, so information about planes that you can see flying overhead.
102010	109410	And while it's intended uses for safety and air traffic control, a common hobbyist and enthusiast
109410	115470	use case is it's just cool to be able to see a map of all the planes and aircraft around you overhead
115470	119890	and be able to see what flight number it is, it's heading, where it's going, flight plans.
120650	125870	And ADS-B itself can exist over multiple types of data links, but when we say ADS-B, the most
125870	132630	common physical medium that it's sent over is the MODIS downlink at 1090 megahertz. And if you want
132630	137010	more information on ADS-B or what it's used for, talk to the Aerospace Militia.
138450	143850	But where we come in as like hardware design and badge designers is how do we actually, we have
143850	148490	this signal, we know what we want to receive, but how do we actually implement and make a badge that
148490	155650	can receive this signal? So the most common like enthusiast receivers utilize SDRs or software
155650	161510	defined radios like the RTL-SDR. And because this was designed a long time ago, the protocol and the
161510	166530	modulation is actually fairly simple to demodulate and decode. It's on-off keyed, which is effectively
166530	172050	digital amplitude modulation. It's either on or off. You're either getting RF or you are not on
172050	176970	the 1090 megahertz. And the data bits themselves are Manchester encoded, meaning that the data
176970	184810	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
184810	190990	so-called real SDR receiver, the chips that are required for that is expensive. They are like very
190990	197830	high-end RF chipsets and it's way too expensive to put on a badge. Think of something
197830	208450	like a Hyper-RF, for example, as a proper SDR. The SDRs like the RTL-SDR uses a DVB-T, which is a
208450	214330	digital terrestrial broadcast television. And they overdrive those chips to run faster than they're
214330	219470	intended to, which lets you get into that 1090 megahertz band and then receive it and decode it
219470	224650	in software. One of the issues that we found when we started looking into using one of these DVB-T
224650	233510	tuner chips ourselves, though, is that they are very power-hungry, especially when being overdriven
233510	239710	to hit the 1090 megahertz band. And in addition to just getting really, really hot, the battery
239710	245930	life of the badge would be next to zero. So we had to come up with a new way to do it. And the
245930	252050	third major way of receiving ADS-B is the Log-Amp architecture. This uses a very fast RF power
252050	257330	level meter, which converts the logarithmic received RF power into a linear output voltage.
257730	264030	And in this mode, it can act as an envelope detector when filtered with some very tight
264030	271650	1090 megahertz saw filters. So the way that the architecture, the receive chain works,
271650	278690	is that you get the entire RF spectrum coming in through your antenna that gets
278690	284050	amplified and filtered and amplified and filtered again through very tight 1090 megahertz bandpass
284050	290090	filters. So we can extract only the very specific slice of the spectrum that is centered at 1090
290090	296250	megahertz. And then because the signal that we are trying to demodulate is just on and off,
296250	302130	the RF power meter will let us know, is it seeing no RF or is it seeing more RF?
302210	310450	And that lets us turn the 1090 megahertz ADS-B packets in the air into a two megahertz
311090	320890	baseband level output. And we actually used an amplifier and anti-aliasing filter chip from a
320890	330650	composite video receiver because it is very cheap. If you want to buy an eighth order Butterworth
330650	336810	filter with multiple channels and power amplifiers and clamp diodes, well, analog devices would love
336810	341570	to charge you a lot of money for that. But if you want the... I mean, no one uses composite
341570	345890	video anymore, right? But if you want this composite video amplifier with an eighth order
345890	352650	Butterworth filter implemented into it and multiple chains and an amplifier, well,
352650	360710	please take it. Who uses composite video? But the last step in this process is digitizing the
360710	366890	signal itself. Again, the common way of doing it is to put it into a fast analog to digital
366890	376730	converter, an ADC. But again, high-performance RF-intended ADCs are expensive. And when trying
376730	384450	to optimize design, the best chip is no chip. So the SoC that we're using for the main Linux
384450	390410	component of the badge is the Allwinner T113. It has dual Cortex-A7s, and we'll get into some more
390410	395370	of the specs a little bit later. But it doesn't have any fast ADCs on board, at least nothing
395370	402630	that's actually fast enough to demodulate ADS-B. Well, it is intended actually for automotive video
402630	409650	applications. So it has multiple video inputs and outputs. And one of the supported video input modes
409650	415170	is composite video. Well, if you know your composite video trivia, the baseband signal
415170	422410	has frequency components that require at least a 27-megasample ADC. And sure enough, if you look at
422410	428950	the block diagram we have in our datasheet, it says that on the left side next to the PGA
429610	435910	is an ADC block, because you must have a fast ADC to be able to digitize composite video.
438330	445550	And it's a fast ADC, but if you actually go back, you can see the ADC is not isolated. It's wrapped
445550	451970	inside a bunch of filters. You have the PGA. You have all the hardware blocks that are designed
451970	458150	to demodulate composite video. So you don't get raw samples from the ADC. You get pixels,
458150	462170	basically. So it tries to find the lock. It tries to find H-sync. It tries to find V-sync.
462190	470010	It has built-in filters to do color correction, which means that as it stands, it could not
470010	474050	receive ADS-B. It couldn't actually get you samples, because it would just always say,
474050	479210	oh, I can't find a signal. I can't see a video signal, and just do nothing. But the ADC itself
479210	483910	is in the silicon. And as we like to say, we paid for the whole silicon, and we want to use the
483910	490650	whole silicon. And, well, we had to do some reverse engineering on how to be able to disable these
490650	497170	filters. And we were able to discover certain undocumented registers that... some undocumented
497170	502070	registers in the all-owner chip itself that let you put it into this special manufacturing test
502070	508270	mode. See, making fast ADCs, the reason it's expensive and isolation is that it's kind of
508270	513970	hard to fabricate and then verify the harmonic performance of. So, the silicon manufacturer
513970	520390	will put in these modes that let you basically bypass out the actual video, the H-sync, V-sync
520390	524830	blocks, because those would probably work. But the ADC itself can then be isolated in the special
524830	530130	test mode, which can get you the true raw samples out. And then when you have the true raw samples,
530130	535710	you can verify the performance. So, that's exactly what we want, to be able to abuse this as a
535710	544250	standalone straightforward ADC. And that's exactly what we did. We did some reverse engineering,
544250	549750	we found the registers, and when we put into this test mode, as you can see from the trace,
549750	558230	that is pulled from a badge with the RF front end attached. That is the ADSB preamble and
558230	563250	the start of a data packet being received as raw samples from the onboard ADC.
563970	570530	And actually, I will go back. You see the preamble pattern, the 101-101,
571050	574150	and that's exactly what we're seeing on the output of our ADC.
574590	579410	And this was our proof of concept to say that, okay, we can actually do this. We can get away
579410	585850	with not using any external ADC or SDR chips or really anything intended to be used in this way,
585850	592490	except like the saw filters, and do it fully integrated on just the core Linux SoC.
594770	601050	Now, as I said, the specs of the badge itself, outside of just the RF, we are running full
601050	607170	mainline Linux 6.6. We thought it would be really cool to bring basically a Linux death kit on
607250	614210	a board. And since we have the power of our SoC to do the RF decoding, and we have to write a
614210	617070	bunch of software to manage the Wi-Fi and everything, we're like, hey, instead of writing
617070	621770	all the drivers ourselves, mainline Linux is out there, and it's great. Let's use it.
622330	628430	Our display is a 40 by 40 circular display, which we got custom manufactured for us.
630610	637670	A lot of people actually thought, it's not a smart watch screen. We actually don't really
637670	643050	know where it's from, but when our display manufacturer said, hey, guys, we have these
643050	648190	like cool, we have the circular displays you're talking about, and this 2.7 inch form factor,
648190	651850	what do you think? We're like, this is perfect. It looks like a radar scope,
651850	658970	it looks like an oscilloscope. Let's go. Outside of the ADC, on the core T113 SoC itself,
658970	665430	we have the dual core A7s running at 1.2 gigahertz each, and that's the application processor
666030	672450	cluster that is running Linux. And then another bonus that we got on our silicon is the HiFi4 DSP,
672450	677690	which we'll talk about a little bit more in a few slides, but that's a DSP core that's
677690	684170	designed to be an audio core processor that we are, again, reprogramming outside the manufacturer's
684170	689650	use case to actually do the demodulation, Manchester decode, and ADS-B bit slicing.
690890	697810	In the package, we have embedded 120 megs of DDR3 SD-RAM, 8 gigabytes of VMMC onboard storage,
697810	705310	and some other RF implementations. We have GPS and Wi-Fi, because why not? We're already going
705310	711810	all out. We're already doing full custom RF and printed PCB antennas. Let's go for broke. Let's
711810	720890	add GPS. Let's add Wi-Fi. So that's all in theory. Before that, I think there's a badge
720890	726070	giveaway that's going to be... Okay, I'll keep going. Okay, okay.
728170	732450	So now this is all what we had in theory. This is what came up with the designs,
732450	737090	and then we get it manufactured by our manufacturer, and then they come back,
737090	742670	and now we actually get to implement it and go through all the crazy systems and actually do
742670	745670	the reverse engineering and make sure that we can actually get this ADS-B receiver
745670	751230	running inside of this badge. So you'd think the most challenging part of this whole design
751230	757750	process would be the fully custom ADS-B receiver running with an ADC in an undocumented test mode,
757750	762030	and then piping it into an audio DSP, which was never designed with the goal of actually doing
762030	769210	ADS-B decoding. But that was actually the easiest part. We had the RF. Adam, being a mad lad,
769210	775490	made a full zero to tri-band microwave RF in just four months. This is his first RF project.
778050	783130	And then the TV decoder code, we got it working after a night of debugging, and we actually had
783230	788530	a cool oscilloscope mode that we could actually read directly from the ADC in and get it plotted
788530	794270	on our screen. And then we got the DSP code execution in a week, and then after that we did
794370	798630	a week for Linux kernel dev, and then a week for algorithms, and we got ADS-B. That was the easy
798630	804130	part. It was everything else that should have just worked that didn't, mainly which if any of you
804130	809090	guys have ever worked with USB-C before can probably understand why it's USB-C. And then
809090	814570	of course the AXP2585 battery management chip, which we will go into more detail later about
814570	821510	the whole experience with that. So before we get into the more challenging parts, here's a quick
821510	830550	guide on running code on your HiFi4 DSP. So the Allwinner T113, it has a HiFi4 DSP, and they
830550	834430	advertise it as, oh, you have a third core. But what they don't tell you is that they only give
834430	838730	you the firmware. It's like a blob that gets loaded in, and it's only for audio processing
838730	843750	because it has an audio out, and it does all the codecs with that. And the mainline kernel doesn't
843750	851010	even touch the DSP. But it is its own CPU core, it can be programmed, and if you find the right
851010	857030	resources, you can actually program it. Because we're doing all of these ADSB processing, we want
857030	860950	to try and get the maximum performance to get as high speed out as possible so we can increase the
860950	866450	sample rate and have better performance. So we wanted to do the full SIMD vectorization and
866450	871770	actually use the real HiFi4 toolchain from the vendor, rather than using a lot of like the
871770	877650	open source ones you might find with ESP32 running with GCC. So if you find the extensive
877650	884190	toolchain, you get the extensive toolchain and compiler with the vendor tools, but you also need
884190	890470	to actually get the custom vendor IP block which was used to generate that exact silicon. The great
890470	895850	part about HiFi4 is it can be exactly customized to the exact chip you want to build. So if you
895850	900230	want to have all of these advanced vector units, you can add them in. If not, you can remove them,
900230	904310	you can have however many registers you want, and it's all configurable to the silicon vendor,
904310	908510	but that means that the compiler needs to know what it has available. And the way they do that
908510	913870	is a full blob which has full Verilog for the chip that actually gets produced as just a giant
913870	918530	zip file, and you load it all into the toolchain and it figures out how to program for your chip.
918870	923110	So once you find that, then you have to compare that with the exact version of the extensive
923110	928390	toolchain that it was built with, and then you have to locate all the drivers from Allwinner
928390	932830	and source them and gather them up to actually do the interrupt controller, timers, mailbox,
932830	937070	and then you just download the FreeRTOS port from GitHub. And you combine them all together,
937070	940750	and you can actually get one of the most stable development environments we've had on this entire
940750	946010	badge, where you just run Extended Explorer and it just works. So that's kind of the process for
946010	954330	getting DSP. And now actually for Linux on the badge, we are again, we mentioned we're using
954330	959250	mainline Linux, and that actually drastically sped up the dev time, where you don't have to do,
959390	964570	a lot of the drivers came pre-baked, you just have to configure them correctly. It just works.
964750	969010	But you have to figure out how to configure it, so a lot of the time it's finding magical
969430	973670	incantations and device trees that you forget to set, that cause it to panic, all of that.
973670	976730	And then if you put all the things together and you figure out that it should be working,
976730	980710	but it's not, then it's a bug, and then you spend three weeks doing advanced kernel debugging,
980710	986910	figuring out why your display is not working. Speaking of which, display trivia. Take a guess,
986910	991170	which of these four options caused the artifacting of the clock being messed up, you have too large
991170	995570	of a back porch, there's an unknown silicon bug that only happens when the Linux driver
995570	1000350	sets an undocumented bit, which just happens to exist in a sister chip, but is not in our
1000350	1004910	system on chip, or the display controller registers were initialized in the wrong order,
1004910	1011170	they never tell you the right order. The answer is E, you didn't seat the cable properly when
1011170	1015570	you're trying to solve all the other previous ones, and you're trying to debug the issue above.
1015910	1022870	This is the silicon bug. So this was just a fun thing, and we spent three weeks trying to solve
1022870	1027510	this silicon bug right here, where actually the display would turn green, and it was because
1027510	1033010	they were setting some, the driver for the sister chip had a bit which they were setting, but it
1033010	1039210	caused this chip to glitch in a weird way, causing the MSB of that green channel to be set high,
1039210	1043670	but it only occurred on this one, and you have to go through all 10,000 lines of the display
1043670	1048650	driver and find the exact line you have to comment out which caused the display not to turn green.
1048650	1051530	But if you do that, then you have a working screen.
1053950	1061290	So here's a continuation of the meme. The AXV2585 has been the thing that has been battling us and
1061290	1069170	fighting us for the entire badge. So this chip, it's just a USB-C negotiator, battery charger,
1069170	1073690	BME all-in-one. It's actually a very unique chip, because there's not that many that do all of these.
1073690	1077950	A lot of the time you have to get several chips and stitch them together. So there's no firmware,
1077950	1085470	it's not like some embedded 8081 core, 8051 core, all that. It's just basic I2C registers
1085470	1090490	you need to configure. How difficult could it be to program? It's just flip-flops, right?
1092110	1097950	There were several bugs that we found in the AXV2585, and all of them battled us throughout
1097950	1102430	development. From the first bring up, we've had battery detection, which says it should try and
1102430	1107310	detect if there's a battery and not try and charge it if it doesn't see one. But they say it should
1107310	1111310	always try and do that by default, but all of the chips we get actually are cleared and they assume
1111430	1115930	a battery is present, causing weird instability until you program it in the boot loader and in
1115930	1121030	Linux. There's also fun things where if you get power or any sort of hardware glitches, it causes
1121750	1126890	undefined results in the silicon, where certain registers stop working or things stop writing.
1127610	1131850	There's also the joys of USB Type-C, where we learned that if you plug it into certain model
1131850	1136730	MacBooks, instead of the MacBook charging the badge, the badge will try to charge the MacBook,
1136730	1142930	which does not work. And there's also the biggest thing that actually delayed us a lot right at
1142930	1147330	DEF CON when we were trying to solve this, and we spent a big part of the time when we were trying
1147330	1152490	to get things ready, trying to debug why the actual IRQ pin to interrupt the Linux kernel
1152490	1158950	and say data is available, actually not going low. And this was all due to a certain manufacturing
1158950	1163970	issue. It was not actually a bug in the chip or a configuration issue, but one of the pins was
1163970	1170450	not soldered correctly by the board manufacturer. It passed all visual inspection, but one of the
1170450	1174310	ground pins was not soldered well enough, and it got just enough of a ground pin connection
1174310	1179730	through the other ground pad that it worked enough, but not enough to have a bunch of weird
1179730	1186450	glitches and voltage dropping out and weird chip instability. So we have probably... this AXP2585,
1186990	1192090	it's a great chip for the cost and everything, but the true cost for this chip is really in
1192090	1198090	the development hours of all these bugs trying to solve the USB-C issues and bring up and try
1198090	1202890	and figure out why the chip isn't booting. But if we wrangled it enough to actually get the badge
1202890	1207430	running and we have a stable system, just make sure you have a battery in when booting up,
1207430	1213390	because BMU gremlins will come up without it because of instabilities. So yeah.
1217450	1227490	All right, so yeah, thank you so much for joining us for this overview. I know it's,
1227490	1232270	as you can see, we've been battling gremlins for untold amount of time,
1232270	1238290	so everything is a little bit rushed, but we have zero minutes. So if you have any questions,
1238290	1243190	we will be more than happy to chat after either here at the village. Basically,
1243190	1249410	come find us. We'd love to chat some more. And yeah, if you have a badge out there,
1249410	1254690	tag us on the aerospace village Twitter. We'd love to see where they travel to
1254690	1259190	and what planes are picking up. And with that, thank you.
