1 00:00:00,000 --> 00:00:00,660 Hey, everyone. 2 00:00:00,660 --> 00:00:03,780 Welcome to our talk about Behind the Badge. 3 00:00:03,780 --> 00:00:16,080 And it's kind of a story on how we worked on improving our Aerospace Village badge from last year, as well as the design process and some of the challenges we've encountered while developing our SAO Charlie for this year. 4 00:00:16,080 --> 00:00:17,860 So I'm Robert Pafford. 5 00:00:18,620 --> 00:00:20,060 And I'm Adam Vettori. 6 00:00:21,020 --> 00:00:23,780 And yeah, this is a Behind the Badge. 7 00:00:23,820 --> 00:00:28,500 So a little kind of refresher on the badge we developed last year. 8 00:00:28,500 --> 00:00:32,740 So this is a Linux badge running with a nice circular screen. 9 00:00:32,740 --> 00:00:38,900 And its whole idea is it's designed to receive ADS-B packets that are sent out from airplanes. 10 00:00:39,040 --> 00:00:44,600 So it picks it up on an internal antenna or external antenna and displays it on the nice screen. 11 00:00:44,600 --> 00:00:45,940 It runs Linux. 12 00:00:45,940 --> 00:00:52,720 It's got a dual core ARM core, as well as a DSP which we use to receive all these ADS-B packets. 13 00:00:52,900 --> 00:01:00,120 So this past year, we've been kind of working on improving these algorithms to get better performance and be able to see more planes around you. 14 00:01:00,140 --> 00:01:02,200 And so we actually pushed a software update this DEF CON. 15 00:01:02,200 --> 00:01:09,680 So if you have a badge from last year and haven't gotten it, make sure to either stop by the village or check out our GitHub to get the links to update your badge to get these new improvements. 16 00:01:10,000 --> 00:01:15,360 But part of this process was kind of actually optimizing the assembly. 17 00:01:15,380 --> 00:01:20,580 So the HiFi 4 DSP has a lot of SIMD capabilities, but they weren't being used last year. 18 00:01:20,720 --> 00:01:29,420 So we did some work to kind of optimize all this assembly and really leverage the full capabilities of this core to get all the performance out of it. 19 00:01:29,620 --> 00:01:32,120 Additionally, we realized we had the cache turned off. 20 00:01:32,120 --> 00:01:36,920 So when we turned on the cache, we actually were able to hit real-time decode and actually faster than real-time. 21 00:01:36,920 --> 00:01:41,560 So we were able to receive all the packets and process all the data we have coming into the badge. 22 00:01:41,800 --> 00:01:49,480 So this was a big performance boost, and we kind of pushed it out as a soft update for some of our testers over winter. 23 00:01:49,480 --> 00:01:57,380 But we started to see some intermittent crashes every few minutes to actually every several hours on this new DSP firmware. 24 00:01:57,900 --> 00:02:03,960 And this made it really difficult to debug of when you have a crash every few hours and you try and see, oh, did this fix it? 25 00:02:03,960 --> 00:02:07,580 You have to wait six plus hours to see if it actually solved it. 26 00:02:08,040 --> 00:02:14,420 So the crash was a kernel panic would occur, but it wasn't really consistent on what the message was. 27 00:02:14,420 --> 00:02:17,180 You typically have a very corrupted stack message. 28 00:02:17,180 --> 00:02:19,220 You wouldn't get a lot of registers or dumps. 29 00:02:19,220 --> 00:02:21,720 Sometime it'd just be one or two lines of a panic message. 30 00:02:21,900 --> 00:02:25,860 And it didn't even seem to have to do with anything related to the DSP. 31 00:02:25,860 --> 00:02:33,120 And it appeared to be a memory corruption of some kind, some sort of issue on the TV decoder, some race condition. 32 00:02:33,120 --> 00:02:36,480 We weren't really sure, and it was really difficult trying to debug it. 33 00:02:37,780 --> 00:02:47,120 But after kind of working on this issue for several days, like a couple weeks, we were able to finally narrow down the bug. 34 00:02:47,120 --> 00:02:54,860 And the solution to solve it ended up just be the big hammer of dump 128 megabytes of DRAM over JTAG. 35 00:02:54,860 --> 00:02:58,280 It took around 45 minutes to get this whole dump out. 36 00:02:58,280 --> 00:03:05,360 But from there, we were able to actually start to figure out where is this kernel panic coming from, of all it would be is some random memory pointer. 37 00:03:05,360 --> 00:03:16,300 But when you searched for what that memory pointer was, you'd see that there's actually a large number of matches inside of the buffer that we get the raw ADC samples out. 38 00:03:16,400 --> 00:03:22,000 And you'd actually be able to see in the buffer region we assigned for the TV decoder, it was there. 39 00:03:22,000 --> 00:03:26,280 We'd also see a large number of matches at the start of DRAM, which was very interesting . 40 00:03:26,620 --> 00:03:34,880 At the start of DRAM, it's reserved for the Linux kernel to keep all of its important structures and needs to actually boot up and actually run the operating system. 41 00:03:34,880 --> 00:03:44,280 But if you inspected it on the crashed system, it actually looked like the start of DRAM was instead just a lot of signed 12-bit numbers , which looked a lot like the buffer from the TV decoder. 42 00:03:44,400 --> 00:03:58,440 And it seemed that there was some sort of one in a million chance of a hardware bug that the TV decoder DMA would just instead of writing to where it's supposed to go, just dump it to the start of DRAM, and then destroy all of the kernel memory, and you would actually crash the device. 43 00:03:59,100 --> 00:04:05,160 So this was a very difficult problem to actually like solve of like, well , it's a hardware bug, we can't really fix that. 44 00:04:05,160 --> 00:04:09,160 How do you go about preventing it from randomly writing to the start of DRAM ? 45 00:04:09,940 --> 00:04:14,940 The solution was to just move the DMA buffer to the start of DRAM , tell the Linux kernel to get out of the way. 46 00:04:14,940 --> 00:04:17,640 So if it glitches, it'll just go where it's supposed to anyways. 47 00:04:17,700 --> 00:04:21,600 And if you look at the memory map, it's kernels been moved out of the way. 48 00:04:21,600 --> 00:04:24,760 And that's what you're running, that we're running on these badges now. 49 00:04:24,760 --> 00:04:26,640 So we can now receive it. 50 00:04:26,640 --> 00:04:29,620 And we have solved the hardware bug with software. 51 00:04:35,430 --> 00:04:43,930 So a another hardware feature we want to revisit from last year and kind of add some extra polish on for this year was the our dual role USB C port. 52 00:04:44,370 --> 00:04:50,050 So we put when we put the C port on the badge, we have the intention of it being both a device and a host. 53 00:04:50,310 --> 00:05:00,370 So the intent is you get this badge, you plug it into your computer, and your computer is the host, this will act as a USB to Ethernet emulation gadget and lets you just SSH in kind of automagically. 54 00:05:00,630 --> 00:05:04,230 But you know, it's DEF CON, we're all hackers, we want to have some fun with this portable Linux device. 55 00:05:04,230 --> 00:05:12,230 If I have a flash drive or like a keyboard or some other smaller USB C device, I want to be able to plug it into this USB C port, have the badge act as the host. 56 00:05:12,510 --> 00:05:16,730 And our power management chip will give you the five volts boosted from the battery. 57 00:05:16,950 --> 00:05:21,230 And it should let you not use like, you know, any other normal USB device on Linux. 58 00:05:21,510 --> 00:05:32,710 But when we were doing hardware bring up, we started seeing these, like very, again, interesting transient flaws where, you know, maybe about, like 70% of the time, we'd have these USB enumeration errors, but only in host mode. 59 00:05:32,890 --> 00:05:43,450 And that tells us that it's likely not an issue in the actual hardware, like the signal integrity, since we can run high speed USB, like USB device 100% non like non stop, no problem. 60 00:05:43,850 --> 00:05:47,430 But it's only in this host mode that this issue actually occurs. 61 00:05:47,690 --> 00:05:55,270 So like, I was going into this thinking that there, okay, there might be some bug in the kernel driver, like, that would make sense, like, let's do some kernel debugging. 62 00:05:55,990 --> 00:06:04,870 And another like data point we thought we saw is that the original all winner vendor like PSP kernel, the USB host mode also work fine on the same board. 63 00:06:04,870 --> 00:06:09,930 So again, very likely not a PCB bug, just something in the mainline kernel might be bugged. 64 00:06:11,150 --> 00:06:28,870 And as we're looking into the implementation of how all winner specifically does the dual role USB device switching, they actually like with some of these other IP cores have a pretty interesting way of solving the problem, where they have two effectively host controllers, 65 00:06:28,870 --> 00:06:39,230 the main device controllers, the mentor graphics like the MUSB HDRC, it's a dual role controller, so it can do host and device mode in the same like a little like IP block. 66 00:06:39,230 --> 00:06:41,590 And this has been used in a lot of devices. 67 00:06:41,590 --> 00:06:44,310 So there's tons of info on it, like available online. 68 00:06:44,450 --> 00:06:48,330 And for some reason, all winner actually only uses this in device mode. 69 00:06:48,710 --> 00:06:58,410 They like on top of that, we'll glue on an EHCI OHCI, like second pair of host controllers, and add this like interesting UTMI mux. 70 00:06:58,410 --> 00:07:08,850 Well, they claim it's UTMI mux, we have some, like things we found in the kernel code and like the, the like other data sheets that make it sound like it's actually not exactly that simple. 71 00:07:08,850 --> 00:07:12,250 So how exactly they're doing the muxing and switching is not super clear. 72 00:07:12,250 --> 00:07:14,450 But, you know, it doesn't really matter for right now. 73 00:07:18,230 --> 00:07:28,730 And we, like, we see that, okay, the host mode itself works, sometimes when it enumerates, and the device works basically all the time. 74 00:07:28,730 --> 00:07:44,050 And so we were looking at the actual USB PHY, like the, the, like, basically undocumented IP core that talks to the physical differential pairs on the USB port, and then takes that information passes it to the host control like EHCI OHCI controllers. 75 00:07:44,230 --> 00:08:01,850 This interface is not your standard mem mapped like MMIO, it's a pretty cursed bitbang interface, where you can see that to actually read and write these, we call them like sub registers, like these very low level registers embedded deep in the the analog blocks of the PHY, 76 00:08:01,850 --> 00:08:08,950 you basically are bitbanging some sort of serial shift register interface through these otherwise MMIO registers. 77 00:08:10,190 --> 00:08:15,030 And, like, look, you're trying to debug the mainline kernel code, it seems to be using in a sane way. 78 00:08:15,110 --> 00:08:20,190 There's only two times that ever actually really talks to this PHY, it's when the board turns on and does the setup. 79 00:08:20,190 --> 00:08:24,930 And then when you do the actual roll switch, so sounds like we're on the right track. 80 00:08:24,970 --> 00:08:27,270 And, you know, we were looking at bugs in the driver . 81 00:08:27,770 --> 00:08:31,850 And it turns out that actually the entire mainline driver was the bug. 82 00:08:33,310 --> 00:08:36,330 Allwinner has a whole, like, plethora of chips. 83 00:08:36,330 --> 00:08:41,310 And they have these like code names, that's could be a whole other like our talk to explain that mess. 84 00:08:41,650 --> 00:08:48,590 But they have the they have a quirks table that let you like try and handle different quirks between different versions of the silicon . 85 00:08:48,590 --> 00:08:51,210 But overall, it's the same code for all the Allwinner SoCs . 86 00:08:51,330 --> 00:08:57,690 Well, what we found in looking through a specific version of the Allwinner BSP kernel is that they had these interesting comments . 87 00:08:57,690 --> 00:08:59,870 They're saying, Oh, yeah, we have this new PHY . 88 00:08:59,990 --> 00:09:01,030 It's for the new PHY. 89 00:09:01,030 --> 00:09:03,870 And it's for self developed by self. 90 00:09:04,190 --> 00:09:08,410 So we suppose that Allwinner actually made what we call a v3 PHY. 91 00:09:08,410 --> 00:09:11,870 They made their own in house, analog IP core. 92 00:09:12,010 --> 00:09:19,970 And as a result, you'd have you need new ways of controlling that, especially with a really, really silicon specific analog low level control blocks. 93 00:09:20,110 --> 00:09:23,470 And it seems that no one from like the mainline kernel actually noticed that. 94 00:09:23,470 --> 00:09:26,550 Or if they did, they thought that the old driver would just work. 95 00:09:26,790 --> 00:09:29,370 And it doesn't work at all, actually. 96 00:09:29,990 --> 00:09:35,010 Like the registers it sets in this analog interface sub block are completely wrong. 97 00:09:35,010 --> 00:09:37,250 Like they don't exist on the new v3 PHY. 98 00:09:37,490 --> 00:09:43,290 The trim algorithms that the mainline kernel uses from the v2 PHYs don't apply at all to the v3. 99 00:09:43,290 --> 00:09:46,390 Those actually done in factory now and loaded from fuse. 100 00:09:46,390 --> 00:09:49,650 And we saw that, of course, mainline doesn't touch the fuses at all. 101 00:09:49,650 --> 00:09:53,630 So we know that is completely not driving it correctly. 102 00:09:54,190 --> 00:10:04,110 So this actually seems like it could be a good like explanation that the analog trims were not loaded from fuse and were just running untrimmed. 103 00:10:04,110 --> 00:10:08,050 But actually no, that it somehow still actually just works fully untrimmed. 104 00:10:08,050 --> 00:10:14,790 The real for real issue was that the kernel drive was not switching the PHY power bit correctly. 105 00:10:15,250 --> 00:10:24,900 So regardless, we implemented both the like correct bring up initialization trimming functionality and the correct power switching. 106 00:10:24,900 --> 00:10:36,280 And now with an actual proper v3 PHY driver, we finally just have it just works both USB device and host dual role switch over in the in the kernel. 107 00:10:36,280 --> 00:10:41,740 So that's also packaged in a new new kernel update that we have shipped with our v2 firmware. 108 00:10:43,640 --> 00:10:54,180 All right, and with those winglet updates, or updates our main ADS-B badge brings us to Charlie, which is the new SAO hardware we designed and brought to DEF CON this year. 109 00:10:55,320 --> 00:11:02,840 So Charlie, as we call him, is designed to add some extra radio and like now audio capabilities to the Linux badge. 110 00:11:03,120 --> 00:11:09,880 And in the vein of aerospace, we want to come up with some cool things around, you know, around air space and radio. 111 00:11:09,900 --> 00:11:18,000 And we settled on trying to receive airband voice as a as an expansion of receiving the ADS-B messages from the planes with the base badge. 112 00:11:18,440 --> 00:11:22,700 We have a headphone jack to listen to it, which also doubles as our antenna , the headphone wire. 113 00:11:22,900 --> 00:11:29,500 And we figured like, hey, if we already are shipping headphones and audio processing, like, can we receive broadcast FM, that would be kind of cool. 114 00:11:29,500 --> 00:11:34,800 It's something that's kind of around you no matter where you go, even if you're not near an airport or you're not line of sight to a plane . 115 00:11:35,760 --> 00:11:42,040 And if we're going to do broadcast FM, we might as well do a nice stereo because we want only the best user experience. 116 00:11:43,240 --> 00:11:46,700 We also have a pretty neat menu system and animations on this. 117 00:11:46,700 --> 00:11:51,740 We are running full four color grayscale on the OLED, which we will absolutely get to in a little bit. 118 00:11:51,880 --> 00:11:58,360 And as I like to say , to make all this run on our little microcontroller, we are programming five out of the two cores on it. 119 00:11:58,560 --> 00:12:01,800 Because I mean, we need we need that much performance. 120 00:12:04,770 --> 00:12:08,470 Yeah, so this a very powerful five core microcontroller. 121 00:12:08,470 --> 00:12:09,570 Which one is that? 122 00:12:09,850 --> 00:12:15,570 This is the TI SimpleLink CC1312R RF microcontroller. 123 00:12:15,570 --> 00:12:25,310 It's a like sub gigahertz wireless microcontroller you might find in like, like wireless remotes or any sort of device that needs to communicate like long range over sub gigahertz. 124 00:12:25,550 --> 00:12:30,770 The actual core of the microcontroller is a pretty standard like ARM Cortex M4F. 125 00:12:30,770 --> 00:12:33,810 It's downclocked pretty low at 48 megahertz. 126 00:12:34,070 --> 00:12:38,710 And it's got a your standard basic set of peripherals of UART, SPI, things like that. 127 00:12:38,770 --> 00:12:42,370 So from the like a microcontroller point of view, it's pretty standard. 128 00:12:42,410 --> 00:12:47,870 One interesting part is it has a thing called the sensor interface in the bottom right. 129 00:12:47,890 --> 00:12:50,730 And that actually has a second core which you can program. 130 00:12:50,730 --> 00:12:52,590 They give you all the tool chain to develop. 131 00:12:52,590 --> 00:12:55,790 It's a sensor controller, they call it. 132 00:12:55,830 --> 00:13:04,450 And it's a 16 bit DSP that's 16 bit CPU core, which is just ultra low power, super basic, basic edition. 133 00:13:04,910 --> 00:13:07,870 But it's designed for like background sensor pulling tasks. 134 00:13:07,870 --> 00:13:13,490 And it's a very low power core that can run while the entire main rest of the system is like power gated and turned off. 135 00:13:13,650 --> 00:13:19,710 So that was very interesting, because you can actually use that for more features and adding more stuff into it. 136 00:13:19,910 --> 00:13:23,970 From the RF side, it's great because it can receive sub gigahertz. 137 00:13:23,970 --> 00:13:28,590 But there are a few short, few small issues when you're trying to develop with this . 138 00:13:28,590 --> 00:13:33,250 One, the TI SimpleLink actually can't tune to the frequencies required for it. 139 00:13:33,250 --> 00:13:37,690 So we wouldn't actually be able to tune to FM or airband if we chose this microcontroller. 140 00:13:37,970 --> 00:13:41,410 And the microcontroller is only designed to receive digital signals . 141 00:13:41,870 --> 00:13:44,450 But airband is an analog signal. 142 00:13:44,510 --> 00:13:49,310 So a few small challenges we had to overcome to actually make this possible for this SAO. 143 00:13:49,850 --> 00:14:00,090 So to actually do that, we have to kind of unlock more features of the RF core to convince it to receive analog and kind of go outside of what it's intended for by the manufacturer. 144 00:14:00,390 --> 00:14:04,670 So we needed to convince the RF chain to kind of go and receive analog. 145 00:14:04,670 --> 00:14:08,210 And the thing is that all the signals coming into the chip have to be analog. 146 00:14:08,210 --> 00:14:15,090 And looking at the block diagram that they show here on the right, you can see that it's actually pulling two ADCs for IQ sampling. 147 00:14:15,090 --> 00:14:20,890 So at some point in the signal processing chain, there should be raw IQ samples flowing through this chip. 148 00:14:20,910 --> 00:14:29,930 So if we could figure out how to actually pull the samples out early enough in the processing chain, we could get the raw analog samples and we could actually receive these analog signals. 149 00:14:30,050 --> 00:14:35,210 The problem is that there is absolutely no documentation on how any of this RF core works. 150 00:14:35,370 --> 00:14:38,230 Pretty much any RF microcontroller you'll work with is like this. 151 00:14:38,230 --> 00:14:40,750 They don't give you any of the register maps or documentation. 152 00:14:40,750 --> 00:14:44,490 They just say, use our APIs, use this pre-compiled blob. 153 00:14:44,490 --> 00:14:46,810 They don't even really give you source code to use it. 154 00:14:47,070 --> 00:14:49,070 This chip takes it an extra step further. 155 00:14:49,070 --> 00:15:00,190 And actually, the APIs, they give you the source code for, but all they do is talk to a mailbox to a third processor inside of this chip, which you can't, you're not supposed to run code on. 156 00:15:00,190 --> 00:15:01,950 They say, oh, just use our APIs. 157 00:15:01,950 --> 00:15:04,130 It's got a ROM with all the code it needs. 158 00:15:04,330 --> 00:15:11,290 And it actually makes it more difficult to reverse engineer because you don't actually have a reference for even like a pre-compiled binary to look at. 159 00:15:11,290 --> 00:15:14,030 It's just all in this walled off box. 160 00:15:14,370 --> 00:15:24,670 But being able to directly drive the peripherals would give us full control and being able to do it on a second core would even take load off of the main CPU and we could do more cool stuff with the main core. 161 00:15:24,670 --> 00:15:27,650 So that was kind of the objective for this. 162 00:15:28,190 --> 00:15:34,590 The nice part is that what allowed this to be possible is TI creates a thing called RF patches. 163 00:15:34,590 --> 00:15:41,290 So the whole idea behind this is they released this microcontroller when Bluetooth 5 was the latest and greatest. 164 00:15:41,290 --> 00:15:47,490 But Bluetooth 6 comes out and they don't want to respin the silicon and change a bunch of ROMs out just to support Bluetooth 6. 165 00:15:47,510 --> 00:16:00,190 So instead they created this concept of patches where in an SDK update they will give you some opaque binary blobs that you load in and it will put it in magic locations in the chip and it will actually be able to change the behavior of the RF subsystem. 166 00:16:00,370 --> 00:16:07,830 So this seemed to be the best way to actually change the behavior and actually implement our own custom RF control on the chip. 167 00:16:08,310 --> 00:16:12,950 So these are just after kind of looking through and reverse engineering these a bit. 168 00:16:13,010 --> 00:16:21,750 These patches are just executable code that gets loaded into various parts of RAM and hooked into the various parts of the RF core. 169 00:16:22,850 --> 00:16:36,290 Now the other interesting thing is that when you look through the RF patches, they talk about CPE patches, which stands for the Command Packet Engine, is that Cortex M0 in the previous slide that kind of all the RF libraries interact with. 170 00:16:36,290 --> 00:16:43,890 This has like the mailbox system and does all of that and does like the high level management and power up and power down of the RF subsystem. 171 00:16:43,890 --> 00:16:52,110 But there's two other types of patches, MCE and RFE, which are designed to do more real-time processing tasks on the chip. 172 00:16:52,110 --> 00:17:02,870 And these are a completely undocumented ISA, which required some reverse engineering to figure out how to actually create and develop code for these processing cores. 173 00:17:02,910 --> 00:17:14,050 But they are two additional CPU cores, which also run at a rather fast speed, and they're able to do a bunch of real-time decoding and management of the RF subsystem. 174 00:17:14,050 --> 00:17:21,010 So being able to leverage these cores, unlock even more capabilities and give you even lower level access into the RF subsystem. 175 00:17:21,930 --> 00:17:24,990 And so all these CPUs can be patched. 176 00:17:24,990 --> 00:17:34,750 And we had to create custom patches for all of these cores to be able to modify their behavior and actually start to pull out these analog samples and actually make all of these things possible. 177 00:17:36,130 --> 00:17:40,110 So how do we get it to work on Charlie? 178 00:17:40,110 --> 00:17:42,190 And how do we actually receive airband audio? 179 00:17:42,190 --> 00:17:48,510 So the actual chip itself has a hardware IP block called the magnitude estimator. 180 00:17:48,510 --> 00:17:52,590 So this converts the raw IQ RF samples into a magnitude. 181 00:17:52,590 --> 00:17:59,490 So this is effectively an AMD modulator, where you can just get the absolute magnitude of the incoming waveform. 182 00:17:59,610 --> 00:18:08,730 And if you were to take that audio out and play it, you would get roughly some sort of AM tape signal, and it would be very low quality, you could use that. 183 00:18:08,790 --> 00:18:29,670 So we take that magnitude block out and we use the MCE firmware, we made a custom patch to kind of periodically pull this magnitude estimator and use debug registers to pull the samples directly out of the chain at an early point, and actually get it before it goes to the digitizer and then just forward that out into the FIFO that's typically used for digital packets that are received. 184 00:18:30,570 --> 00:18:36,270 Then we create a custom CPE patch, which will be able to do all of the filtering of this data. 185 00:18:36,270 --> 00:18:42,670 So this will take the samples coming in from the MCE, and it will be able to do like basic filtering. 186 00:18:42,670 --> 00:18:50,570 So this hard audio doesn't sound as harsh, and you can kind of hear the airband voice and a little bit clearer, as well as it does the squelch algorithm. 187 00:18:50,570 --> 00:18:56,750 So you don't hear static in the background, as you're kind of listening to dead air, it'll actually kind of mute that. 188 00:18:57,070 --> 00:19:02,830 So part of that process, we were able to kind of talk to the RFE, which does all the power estimation. 189 00:19:02,890 --> 00:19:08,110 So having all of these systems work together, we were able to create the airband receiver. 190 00:19:08,410 --> 00:19:13,190 So when it's not, when you just have a transmission, you're able to pick it up, hear it rather clearly. 191 00:19:13,190 --> 00:19:16,050 And then when there's nothing going on, it just silently mutes itself. 192 00:19:16,430 --> 00:19:23,330 And this is all, once all this processing is done, you have audio samples written to a buffer , and it's sent to I2S. 193 00:19:23,330 --> 00:19:29,570 And so the main CPU allocates the buffer, but after it does the handoff to the CPE, it pretty much steps completely away. 194 00:19:29,570 --> 00:19:33,370 And so all the receiving is done with zero overhead to the main CPU. 195 00:19:33,370 --> 00:19:36,070 So we're able to do a bunch of other interesting stuff in the meantime. 196 00:19:36,970 --> 00:19:39,650 So that's the airband audio receiver. 197 00:19:40,390 --> 00:19:42,910 And that was, we got working. 198 00:19:42,990 --> 00:19:55,750 But we also wanted to make sure that we could receive FM, because you might not be directly near an airport, but it'd be nice to be able to still use Charlie and actually be able to pick up some sort of audio and kind of mess around with the SAO. 199 00:19:55,750 --> 00:19:58,890 So part of this was, we wanted to get stereo FM. 200 00:19:59,510 --> 00:20:02,410 Basic, like mono FM is pretty simple. 201 00:20:02,950 --> 00:20:13,590 At the, this is the spectrum view of your RF spectrum, or the post frequency demodulation, what your spectrum will look like when you, for an FM station. 202 00:20:13,630 --> 00:20:19,530 So everything below 15 kilohertz, you can kind of see is marked as L plus R. 203 00:20:19,530 --> 00:20:21,150 And so that is your mono audio. 204 00:20:21,150 --> 00:20:32,610 So your basic FM receiver will just put a filter, everything below 15 kilohertz, just put out over the speaker, everything above discard, and you can get a basic FM audio stream like that. 205 00:20:32,610 --> 00:20:37,690 And so the first implementations we had of FM on the development boards were just basic mono audio. 206 00:20:37,970 --> 00:20:52,230 But stereo actually sounds, even though you might not have the full high quality CD level audio you'd expect from modern digital electronics, stereo adds an extra sort of feeling to the audio that it makes it sound better. 207 00:20:52,230 --> 00:20:57,310 And so I was determined that, okay, we are going to get stereo FM on this thing. 208 00:20:57,330 --> 00:21:01,670 And we're going to figure out some way to get the signal processing chain to do this. 209 00:21:02,070 --> 00:21:09,930 So the way you actually receive stereo is a little bit more complicated, because again, the everything below 15 kilohertz is mono audio. 210 00:21:10,090 --> 00:21:16,370 So rather than to be able to separate the left and right channels, they don't have the left and right transmitted separately. 211 00:21:16,430 --> 00:21:25,970 Instead, they have up at the 39 kilohertz point, this left minus right signal, which allows you to do addition and subtraction operations. 212 00:21:25,970 --> 00:21:28,530 So if you add the two signals together, you'll get the left channel. 213 00:21:28,530 --> 00:21:30,970 And if you subtract the two signals, you get the right channel. 214 00:21:31,290 --> 00:21:39,190 So we would have to go in and kind of narrow out this sort of center left minus our region, and then add the two signals together. 215 00:21:39,190 --> 00:21:51,030 And you do this with this 19 kilohertz pilot tone, where you will be able to see this tone, if you filter it, that will give you a pure tone, which you can multiply by two to get the dead center of your left minus right audio. 216 00:21:51,070 --> 00:21:54,230 And then you're able to kind of go from there to actually receive it. 217 00:21:55,050 --> 00:22:01,550 So the actual algorithm to do this is we take in the raw FM demodulation from the MCE. 218 00:22:01,830 --> 00:22:08,430 And we first go through in the middle path to go through and I think I can do this. 219 00:22:08,430 --> 00:22:16,210 So you go through the middle path, which is the 19 kilohertz pilot band pass to kind of isolate this center carrier frequency. 220 00:22:16,230 --> 00:22:18,690 And then you run it through a phase lock loop. 221 00:22:18,690 --> 00:22:24,630 So this turns it from a very noisy 19 kilohertz tone, depending on how close you are to the transmitter or how much noise is present. 222 00:22:24,630 --> 00:22:33,890 This cleans it all up and does best effort to try and recreate this 19 kilohertz pilot carrier to then be used later in the chain. 223 00:22:33,890 --> 00:22:47,610 We then multiply it by two and then are able to get a 39 kilohertz, which is our reference for what we need to shift our like the L minus R band down to, to actually get the L minus R signal. 224 00:22:47,610 --> 00:22:51,450 So we shift the 39 kilohertz back down to zero and then filter it. 225 00:22:51,450 --> 00:22:53,570 So we just get the L minus R signal. 226 00:22:53,710 --> 00:22:55,970 So at this point right here, we have L minus R. 227 00:22:56,050 --> 00:23:00,030 For the L plus R, aka the mono audio, you just have to filter it. 228 00:23:00,110 --> 00:23:01,910 And then you get an L plus R. 229 00:23:01,910 --> 00:23:07,010 Then you do the addition and subtraction operations, and you will get your FM, left channel and right channel. 230 00:23:07,010 --> 00:23:15,030 And then after a little bit of the emphasis to correct the frequency response, you're able to get your left and right channels out of FM. 231 00:23:15,270 --> 00:23:20,790 So there's a lot of filtering steps and a lot of various math that needs to be done to do this. 232 00:23:20,950 --> 00:23:26,210 And there's a lot of demos online, and you can do this on your radio or on your computer with an SDR. 233 00:23:26,270 --> 00:23:31,610 But we have a 48 megahertz Cortex M0, which is not a DSP. 234 00:23:31,610 --> 00:23:33,570 We were lucky to get a multiplier. 235 00:23:33,630 --> 00:23:42,090 So we had to kind of create a whole custom patch system to do this DSP in a very small amount of time. 236 00:23:42,610 --> 00:23:51,070 So at this, we have a 200... at the audio rates we get, you need 200 kilo samples per second to get your 100 kilohertz of bandwidth required for FM. 237 00:23:51,110 --> 00:23:52,690 So this is the absolute minimum. 238 00:23:52,690 --> 00:23:56,510 You should really do 250, but we couldn't afford the cycles for that. 239 00:23:56,510 --> 00:23:57,770 So we got 200. 240 00:23:57,870 --> 00:24:10,330 And so this gives us around 240 cycles per sample to run an algorithm of two six-order IAR low-pass filters, a PLL , DDS, a bandpass filter, and two FM de-emphasis filters. 241 00:24:10,610 --> 00:24:22,010 So this was done with a very custom Cortex M0 assembly routine, where to actually save CPU cycles, a load and store on the Cortex M0 actually used two cycles per. 242 00:24:22,010 --> 00:24:32,370 We actually ended up moving the stack pointer and reusing it as a general purpose register to actually save CPU cycles while loading and storing to try and inch every piece of performance out of this chip. 243 00:24:32,510 --> 00:24:40,450 But we were able to squeeze it just under with 235 out of 240 CPU cycles are in use to receive this FM. 244 00:24:40,450 --> 00:24:42,670 And that leaves a few spare for bus arbitration. 245 00:24:42,670 --> 00:24:49,550 But with all of this, you are now able to enjoy stereo FM, which is something your car can do, but now so can your SAO. 246 00:24:59,880 --> 00:25:00,920 All right. 247 00:25:01,360 --> 00:25:02,980 So this is great. 248 00:25:03,060 --> 00:25:08,680 But to be able to like leverage any of this, we actually need to get the FM or airband signal into the chip. 249 00:25:08,680 --> 00:25:13,840 And as we mentioned before, that that's not really possible on the SimpleLink, even though it's a sub -G chip. 250 00:25:14,460 --> 00:25:19,440 FM requires you to tune to 88 megahertz, that's the lowest end that like we need to pick up. 251 00:25:19,720 --> 00:25:27,140 And even though it's a sub-G chip around TI officially says around 169 megahertz, and there's gaps, it's not a full continuous spectrum. 252 00:25:27,140 --> 00:25:32,460 But this chip will do 169 megahertz to about 1000 megahertz with some gaps in between. 253 00:25:32,740 --> 00:25:36,040 And that's not enough to 88. 254 00:25:36,600 --> 00:25:41,440 And we tried a few things to get this chip to tune down that low. 255 00:25:41,440 --> 00:25:48,540 And I assure you we tried everything we could, including actually throwing away the existing PLL driver. 256 00:25:48,540 --> 00:25:52,960 TI uses an interesting architecture called the ADPLL or all digital PLL. 257 00:25:53,220 --> 00:25:57,280 So there's a few papers and like IEEE talks, they did on this. 258 00:25:57,280 --> 00:26:15,080 And there's some cool stuff in there, like, this is interesting to you, where, for example, like they don't run the feedback loop in analog, in an analog mode, they actually run it as you can imagine, like a digital clock with just very, very fast, like up to 2.4 gigahertz fast counters as your phase comparators and all their PLL stuff . 259 00:26:15,460 --> 00:26:25,580 But we were thinking, okay, well, if the existing PLL driver code does not let you tune this low, what if we write our own PLL driver code and see how low we can push the silicon? 260 00:26:25,740 --> 00:26:30,660 And the answer is around 140 megahertz, which is still not even close enough to 88. 261 00:26:31,060 --> 00:26:49,160 And for some other reasons in the hardware, like we have pretty good reason to believe that silicon physically cannot support this, this low frequency, like we're missing a few extra gates, we're missing a few extra divider chains, we're missing enough hardware in the actual RF core where there's realistically no way that this can happen in silicon. 262 00:26:49,420 --> 00:26:51,680 So begrudgingly, we had to add some parts. 263 00:26:51,740 --> 00:26:53,980 And one of those is external mixer. 264 00:26:54,580 --> 00:27:02,500 Usually when you start buying discrete RF parts, they get expensive because the companies that make them know that you're probably pretty smart if you're buying RF parts, and you can afford it. 265 00:27:02,720 --> 00:27:08,160 But we found a nice old, decently old part, it's called a max 2671. 266 00:27:08,160 --> 00:27:15,900 It's a up converter mixer for I believe, like decked cordless phones, but they operate in about the right frequency range. 267 00:27:15,900 --> 00:27:26,040 Because they have multiple part numbers that's effectively the same silicon, and we're jellybean parts in like the late 90s, there's still enough stock floating around where you can get these quite cheap for like what they are. 268 00:27:26,780 --> 00:27:33,640 And because these are dedicated mixer ICs, we do get the benefit of it being a proper like Gilbert cell double balanced mixer. 269 00:27:33,660 --> 00:27:36,560 So the silicon quality of the mixer is very nice. 270 00:27:36,640 --> 00:27:41,960 And like, you know, we'll take every bit of dynamic range and noise, like low noise figure that we can. 271 00:27:42,540 --> 00:27:53,700 The downside to using a mixer though, like a discrete mixer is that we need to generate our own LO or like our own local oscillator frequency reference for how much we want to shift the incoming radio signals by. 272 00:27:54,360 --> 00:28:00,720 And to generate an LO, again, the off the shelf solution would be to buy a dedicated RF synthesizer chip. 273 00:28:00,720 --> 00:28:03,500 But once again, these are expensive and also quite power hungry. 274 00:28:03,660 --> 00:28:09,840 So we're thinking, well, if we don't want to buy a dedicated RF synthesizer, like what other options could we have? 275 00:28:10,120 --> 00:28:23,880 And as I was like looking through just any chip I could find that kind of does anything related to RF, I came across these series of chips, like really, really tiny SAW 23 guys used in like these ultra low cost AliExpress garage door openers. 276 00:28:23,880 --> 00:28:32,440 And it gives you these like random, like throwaway little, you know, you press a button and it receives it on the other end, like as like a GPI open basically, but it's over RF. 277 00:28:32,460 --> 00:28:39,880 And what these are, are either OK, like on off keying or like GFSK, little single transmitter receiver pairs. 278 00:28:40,240 --> 00:28:50,180 And the specific part we chose a CMT2119A, it's transmit only, but it has a like SPI retunable range of 240 to 960 megahertz. 279 00:28:50,380 --> 00:28:59,700 Now this is designed to where you have a data pin that you clock in your digital data on and it, you know, translates that to like, it modulates that into RF, then you receive it on the other end. 280 00:28:59,700 --> 00:29:06,600 But I mean, if you think about it, like on off keying, where you just hold the data pin high forever, I mean, that's basically continuous wave, right? 281 00:29:07,500 --> 00:29:11,280 It's only on off keying if you turn it off and we don't turn it off. 282 00:29:11,280 --> 00:29:14,000 And you're like, there's no way this works, right? 283 00:29:14,000 --> 00:29:16,020 Like will the chip work? 284 00:29:16,040 --> 00:29:30,000 And so we like threw together a quick test board and like to our surprise, not only did like the chip work, like really, really well, like it, you know, handled it running indefinitely long, we found that our actual like phase noise and like our spur performance is really, 285 00:29:30,000 --> 00:29:30,640 really good . 286 00:29:30,960 --> 00:29:39,900 And would actually like quite handily beat my USRP, like SDR for both frequency stability, power stability and like spurs. 287 00:29:40,160 --> 00:29:52,160 So not only like what we like, we went into this thing that we might have a comp, like, we might have to make a compromise with this, like chip as our LO, but actually turned out to be a really, really good RF synthesizer. 288 00:29:52,400 --> 00:30:10,520 So with this RF synth chip, our mixer, and then the SimpleLynx front end and the demodulation and RF core, like that finally gets like lets us complete the entire signal chain and do antenna to up conversion to down conversion in the SimpleLynx demodulation, 289 00:30:10,520 --> 00:30:21,680 like the signal chain processing, audio DSP, all that, like all that good audio processing stuff that Robert was just talking about, and then DMA that out to our I2S stack and then finally get in your earbuds. 290 00:30:24,340 --> 00:30:30,020 So with that, there's one more feature that we want to talk about and that's our OLED. 291 00:30:30,780 --> 00:30:41,980 So pretty early in the design phase, we came up with the aesthetic choice to use this like commodity 1.3 inch I2C OLED, but commonly I2C, they support other standards, and we're using SPI. 292 00:30:42,320 --> 00:30:45,440 And they will be listed as SSD 1306. 293 00:30:45,440 --> 00:30:47,960 Although as we're about to find out that might not be true. 294 00:30:48,660 --> 00:30:52,160 But we like these because I mean, they look they look good, you have really good contrast. 295 00:30:52,160 --> 00:30:55,100 And they're also pretty common parts, they're fairly low cost. 296 00:30:55,100 --> 00:31:03,920 And we were thinking that, hey, this is, you know, tons of people use these in projects, like you can find 1000s of projects out there with this, like this little SSD 1306 screen. 297 00:31:04,040 --> 00:31:10,520 So sure, like this will be great, because we can save a bunch of time, we don't have to reinvent the drivers from the ground up, and it'll just work, right. 298 00:31:12,640 --> 00:31:19,140 So we wanted to do SPI and DMA as the highest possible FPS interface to the screen to get a nice fluid UI. 299 00:31:19,340 --> 00:31:23,600 And right away, we noticed a problem that, well, yeah, you have really bad screen tearing. 300 00:31:23,760 --> 00:31:29,520 And this is to be expected, like we're throwing pixels at it as fast as our SPI, like in DMA can do. 301 00:31:29,600 --> 00:31:31,160 And there's no sync. 302 00:31:31,340 --> 00:31:35,820 So we like until we are synchronized, the displays frequency, of course, we'll get screen tearing. 303 00:31:36,060 --> 00:31:39,760 So sure, this works, just how do we turn on screen tearing. 304 00:31:39,880 --> 00:31:45,320 So we started looking into this, maybe we should have looked at this before we committed to it. 305 00:31:45,380 --> 00:31:46,780 But we started looking at this. 306 00:31:46,780 --> 00:31:48,260 And what do I see? 307 00:31:49,140 --> 00:31:54,780 Oh, apparently, this is unsolvable. 308 00:31:57,200 --> 00:32:00,460 So what are we up against? 309 00:32:00,840 --> 00:32:11,340 Well, in theory, the SSD 1306 controller outputs a sync signal on this pin they call FR, like frame, I don't know what it is, they don't think they actually ever tell you what it stands for. 310 00:32:11,600 --> 00:32:28,860 But this is really actually interesting and kind of an inversion of the normal paradigm with like screens, because this screen, not the host is what control sync, the pixel clock for the screen is not is not something you feed to the screen, it's actually generated internal to the screen with a little like RC oscillator. 311 00:32:29,160 --> 00:32:45,140 And like any other like any RC oscillator, that's like the actual exact frequency of that is subject to trims, like, you know, the exact temperature, time, like humidity, a bunch of environmental factors, process factors, just manufacturing variability, 312 00:32:45,140 --> 00:32:50,360 it's basically, it's a complete unknown and you would need like closed loop. 313 00:32:51,000 --> 00:32:59,900 Without a closed loop feedback system, such as this, like FR signal, you cannot know, like 100%, what the actual pixel clock is. 314 00:33:00,980 --> 00:33:05,920 And while this sounds great, and we saw this on the data sheet, like, oh, yeah, there's a signal, like, it'll be it'll be fine. 315 00:33:05,980 --> 00:33:13,180 It turns out that actually none of the panels that are manufactured have this signal broken out from the chip to the ribbon cable. 316 00:33:13,600 --> 00:33:17,800 And as we found, actually, a lot of them don't even have it broken out from the ASIC at all. 317 00:33:18,620 --> 00:33:24,260 So I went in search of this FR pin, and see, can we probe it at all, like even just for debugging. 318 00:33:24,740 --> 00:33:32,980 And my first thought was to probe the traces on the glass directly, like this metallization layer that's deposited on the glass, and then the chip is like kind of pasted on top. 319 00:33:34,020 --> 00:33:44,140 And something I found that we weren't expecting is that what all these little displays that they call like the SSD 1306, most vendors actually have no idea what they're selling. 320 00:33:44,160 --> 00:33:51,360 See, the SSD 1306 is not the only OLED controller, it's one of the OLED controllers. 321 00:33:51,700 --> 00:33:59,820 And a lot of people have been making clones, and then clones of the clones and clones of the clones of the clones, and then clones of those. 322 00:33:59,860 --> 00:34:08,680 So as we were trying to like back solve the device, the family tree of this controller, we found that there's multiple companies, some which are seemingly related and not. 323 00:34:08,680 --> 00:34:13,300 And there's this whole huge mess of like, what controllers could actually be on your panel. 324 00:34:13,300 --> 00:34:15,340 And the problem is the vendors generally don't know. 325 00:34:15,520 --> 00:34:23,840 And even things like the exact like the silk screening on the actual ribbon cable that's bonded to the screen, I found examples where even that is wrong. 326 00:34:24,040 --> 00:34:35,080 So because they, the manufacturers view this as compatible, like either 100% binary compatible, or like, you know, oh, you change one register and your code still works. 327 00:34:35,080 --> 00:34:36,840 Well, it's not the same chip. 328 00:34:36,840 --> 00:34:45,560 And as we're like finding out that there are like notable differences between them, that makes some things work on certain controllers, and some things work on only other controllers. 329 00:34:45,560 --> 00:34:50,380 And actually being able to know what controller you have is a very, very difficult problem. 330 00:34:50,580 --> 00:34:53,680 And I'm not sure there is a guaranteed way to know. 331 00:34:54,580 --> 00:34:57,340 But, like, why does this even matter? 332 00:34:57,340 --> 00:35:02,440 Well, it turns out the SSD 1306 is one of the earlier controllers and one of the more well featured ones. 333 00:35:02,760 --> 00:35:10,060 And while that has an FR pin, the clones do not, or the derivatives of that do not, the cheaper, lower cost controllers. 334 00:35:10,140 --> 00:35:11,920 And it's kind of like a cache 22. 335 00:35:11,920 --> 00:35:19,000 Because no one was bonding out that pin from the SSD 1306s, the clone guys like, well, we're gonna save the pin, we don't need it. 336 00:35:19,000 --> 00:35:26,480 So they actually just got like they get rid of the sink pad on the actual silicon, like the circuitry in the silicon just doesn't exist. 337 00:35:26,700 --> 00:35:33,880 So then the manufacturers like buying these cheaper chips will be like, well, there's no sink pin on the silicon, so we're not going to bond it out. 338 00:35:33,880 --> 00:35:40,020 And then that's like the feedback cycle of you end up with no OLEDs with this sink pin in existence. 339 00:35:40,740 --> 00:36:02,100 So as I took some microscope shots on the lower right picture, you can see this kind of like, little frowny face, that darks that the darker rectangle is the actual pad on the silicon where this FR pin on an SSD on an actual authentic SSD 1306 is, and it's not connected. 340 00:36:02,100 --> 00:36:04,520 So I can't probe that. 341 00:36:04,880 --> 00:36:08,240 Well, that led us to look for other ideas. 342 00:36:08,240 --> 00:36:12,280 If we can't extract timing information from the display, can we inject it? 343 00:36:13,540 --> 00:36:23,780 You actually can supply your own clock to these panels, which would actually solve all of our problems, because if I can give it the clock, I will always know like deterministically what that clock is. 344 00:36:24,200 --> 00:36:28,420 And it's called, you know, they give you a nice clock multiplexer so you can feed it in. 345 00:36:28,420 --> 00:36:30,420 And of course, no one bonds that out either. 346 00:36:30,460 --> 00:36:33,480 So that pin also exists and you can't get it. 347 00:36:34,460 --> 00:36:41,920 We've asked the manufacturers this is the kind of problem where they're like, okay, if you're not ordering 5 million of these OLEDs right now, we're not going to like entertain this idea. 348 00:36:42,600 --> 00:36:49,780 The SPI or I2C interface is read only because that saves like, you know, four more AND gates of not having to support register readback. 349 00:36:49,780 --> 00:36:57,920 So you can really only just throw data at the screen, you can set up a couple configuration registers, and really, they just wanted to throw data at it and you can't read anything back. 350 00:36:58,220 --> 00:37:09,340 So the any thoughts of like trying to find a register or like, maybe there's a register that has like a current scan line or anything of that sort is completely off the table because the digital interface to it is basically write only. 351 00:37:09,720 --> 00:37:12,920 And the only other pins that we have on the ribbon cable are for power. 352 00:37:13,060 --> 00:37:19,720 So we don't want to modify the OLED like and try to do something custom because that's unsolvably expensive. 353 00:37:19,880 --> 00:37:22,520 So we are effectively out of options. 354 00:37:22,520 --> 00:37:25,060 Now there's the sync pin doesn't exist on the ribbon cable. 355 00:37:25,080 --> 00:37:29,760 The like digital interface is write only and all we have left is power. 356 00:37:30,140 --> 00:37:33,260 So is there anything we can do with the power pins? 357 00:37:34,240 --> 00:37:46,680 Well, aside from 3v3 logic, like the actual digital interface to your microcontroller, the OLED needs like higher voltages to actually drive the pixels and make them glow, nominally like call it around six and eight and a half volts, like something in that neighborhood. 358 00:37:47,680 --> 00:37:56,720 And as a like little convenience feature, these controllers have charge pumps that will do a doubling and tripling of your 3v3 rail to generate these higher voltages. 359 00:37:57,040 --> 00:38:02,140 And so just so you don't have to do it, all you do is throw on two capacitors and like you're you're done. 360 00:38:02,500 --> 00:38:05,400 And charge pumps are a form of switching regulator. 361 00:38:05,440 --> 00:38:09,760 And the way that they do this is by switching the voltage on and off the capacitors. 362 00:38:10,280 --> 00:38:25,680 And well, as I was doing some testing, since there's a register you can actually set that margins the oscillator frequency higher or lower, I found that hey, the like, as I make the pixel clock go faster and slower, the charge pump clock happens to go a little bit faster and slower. 363 00:38:25,920 --> 00:38:28,800 deterministically with how I set the pixel clock. 364 00:38:31,300 --> 00:38:40,020 And it turns out like probing the actual charge pump capacitors that yes, the charge pump switching frequency is actually an exact integer ratio. 365 00:38:40,020 --> 00:38:42,620 It's like half the speed of the pixel clock oscillator. 366 00:38:42,620 --> 00:38:45,660 And this makes a side channel possible, right? 367 00:38:45,700 --> 00:38:54,660 That we can recover the clock we can do if we do clock recovery on this charge pump signal, we can actually recover the exact closed loop frequency that the pixel clock is running at. 368 00:38:54,940 --> 00:39:04,960 And there's only one other problem with this is that the density of the pulses since it's not on on the on all the time has to do with the contents of the pixels on the screen. 369 00:39:05,060 --> 00:39:13,800 So for example, if you're showing 100% all white pixels on the display, then you need the most current from the charge pumps to drive all of those pixels on. 370 00:39:13,800 --> 00:39:27,740 So the charge pumps will be running basically as a square wave of you know, constant, constant on time and duty cycle with 100% density, it's a square like it is trying to drive as much current as it can to the pixels. 371 00:39:27,820 --> 00:39:32,900 But if you make that display then all black, you're effectively requesting no current from the charge pumps. 372 00:39:33,120 --> 00:39:40,220 And because it's a power regulation loop, they will go to a very low pulse density and I mean, they don't need to drive current. 373 00:39:40,940 --> 00:39:45,620 And that's solvable with a PLL or like other clock recovery techniques. 374 00:39:45,620 --> 00:40:04,020 But as we already talked about, this is a 48 megahertz little microcontroller like doing this kind of like dynamic side channel and correlating that to the pixel contents of the screen and then doing that fast enough to know where we are in sync and then making sure we don't lose the sync like this is a this gets pretty pretty like yucky pretty fast. 375 00:40:04,200 --> 00:40:10,980 And then also a little bit like a side tangent that this technique also seems to only work on some of the controllers. 376 00:40:10,980 --> 00:40:19,220 So like the aforementioned SSD 1306 works, the very low cost CH1116 is also like has this effect. 377 00:40:19,220 --> 00:40:25,280 And we found that the maybe now more common SH1106 controller actually does not work like this. 378 00:40:25,280 --> 00:40:28,940 The charge pump frequency does not depend on the pixel clock. 379 00:40:28,940 --> 00:40:35,060 And we said, like we think that either it has its own, like completely separate way of clocking or there's just no clock and it's just done in analog. 380 00:40:37,000 --> 00:40:50,140 Well, going back to this, though, if we could get 100% pulse density, like not related to what's on the screen, instead of doing all this like complicated PLL side channel recovery timing shenanigans, like all you'd have to do is count edges, right? 381 00:40:50,140 --> 00:40:53,460 The number of pixels on your screen doesn't change per frame. 382 00:40:53,880 --> 00:40:55,660 And all you'd have to do is count edges. 383 00:40:56,520 --> 00:41:02,060 And as we like talked just like mentioned that the density of these pulses relates to panel current. 384 00:41:03,280 --> 00:41:11,560 And as we started looking into this, we went, maybe I went a little bit too far, because we started decapping these chips, found a way to pull them off the glass. 385 00:41:11,560 --> 00:41:19,280 And then we're just looking, just kind of like hunting around for anything we could find that might help us get more information on this and get closer to this achieving this sync. 386 00:41:19,840 --> 00:41:24,960 And the opcode space for this controller is like you send an 8-bit opcode. 387 00:41:25,100 --> 00:41:31,380 But of all the documented commands in the data sheet, if you kind of like, you know, graph them out, you'll see that there's a lot of holes in there. 388 00:41:31,580 --> 00:41:35,700 And a lot of undocumented or reserved space. 389 00:41:36,100 --> 00:41:43,880 And well, what do you do when you have a bunch of undocumented opcodes, we do automated fuzzing in hardware on an OLED controller. 390 00:41:44,060 --> 00:41:58,460 And after running this for a couple hours and a couple days, I was basically listening to the charge pump as an audio signal, trying to see, you know, can we get any change in these in the behavior of the silicon actually started yielding some very interesting findings. 391 00:41:58,940 --> 00:42:03,680 There's actually multiple undocumented charge pump modes, like in the register that sets voltage. 392 00:42:04,280 --> 00:42:15,640 For example, what that lets us do is instead of doing the pixel clock divided by two frequency, you can actually overclock your charge pump and run it at the pixel clock frequency doesn't really get us anything right now. 393 00:42:15,640 --> 00:42:22,320 But it is something interesting that to see results basically right away, that there are a lot of secrets buried in here. 394 00:42:22,320 --> 00:42:28,960 And then when we see that there's maybe one secret buried in here, then we're going to go all in and try to find all the secrets buried in here. 395 00:42:29,460 --> 00:42:35,240 I found another undocumented command that lets you well, I suppose lets you adjust the internal references. 396 00:42:35,260 --> 00:42:38,060 So kind of like your current and voltage references. 397 00:42:38,060 --> 00:42:45,860 And as you start tampering with that knob, if you make the chip believe that it's actually pushing less current than it really is, then it will run the charge pumps harder. 398 00:42:46,200 --> 00:42:50,100 And running the charge pumps harder, of course means increasing your pulse density. 399 00:42:50,280 --> 00:43:00,680 And that's when I found for the first time that on at least the screen I was testing with on a fully black screen, we could get 100% charge pump density, aka we win perfect sync of just edge counting. 400 00:43:01,220 --> 00:43:16,540 And while that is amazing, was really exciting at the time, certain screens then as like, again, depending on manufacturing tolerances, will then not do 100% density at that cranked up mode, like maybe we'll work on some but then on some other ones, it doesn't. 401 00:43:16,620 --> 00:43:19,520 So more fuzzing, more searching through opcodes. 402 00:43:19,680 --> 00:43:28,980 But then finally, we landed on the our final solution here, which is the burn in mode register or what we believe is the burn in mode register. 403 00:43:29,380 --> 00:43:35,180 And if you are interested in playing around this at home is command D zero and you set it to 01. 404 00:43:35,860 --> 00:43:43,200 But what this does is basically just tell the charge pumps to run at 100% all the time, like it does exactly what we need to do somehow. 405 00:43:43,580 --> 00:43:55,200 And regardless of the pixel contents, regardless of any other setting, this command mode will tell the charge pumps to just run 100% on all the time, max voltage, doesn't matter what's on the screen doesn't matter what else you do. 406 00:43:55,320 --> 00:44:05,960 And this lets us get our perfect sync, we have 100% guaranteed deterministic closed loop control, all we have to do is count edges, and which we know by just how many pixels we're clocking out. 407 00:44:06,020 --> 00:44:12,340 And then you take that through and a few other undocumented commands for good measure like that margining and some things to make it nice. 408 00:44:12,380 --> 00:44:22,280 And then that lets us finally for real achieve the effect we want to go for, which is our four color perfectly stable gray scale, regardless of pixel contents. 409 00:44:26,760 --> 00:44:34,520 So now that we've got this great display synchronization, we wanted to create a graphics engine to actually drive the OLED. 410 00:44:34,600 --> 00:44:42,880 We wanted to have a cool UI and some really nice graphics but didn't particularly want to write a full animation rendering engine in C. 411 00:44:42,980 --> 00:44:52,740 So instead, we wrote a virtual machine to run a full animation system to actually render all the animations, which we call ANSM or animation state machine. 412 00:44:52,920 --> 00:44:57,920 So the idea behind this was just create a sequence of multiple frames with the delay in between. 413 00:44:57,920 --> 00:45:01,400 But as all things do, it slowly started to gain more features. 414 00:45:02,060 --> 00:45:06,620 But the whole, we wanted to be able to allow graphics to be developed independently of firmware. 415 00:45:06,620 --> 00:45:16,120 So while we were doing all the development with the sort of, like OLED and the DSP, the frames and stuff and all the graphics can be generated. 416 00:45:17,100 --> 00:45:30,360 So some of the features we wanted to kind of ended up going in here was you could have multiple frames kind of be chained together of either grayscale or monochrome, but it's got your standard jumps, loops or randomness. 417 00:45:30,360 --> 00:45:32,020 It can also support input events. 418 00:45:32,060 --> 00:45:35,760 So allows like any sort of button presses to actually cause reaction. 419 00:45:35,760 --> 00:45:41,580 So every time in your main menu, when you hit the up button, that's not C code actually seeing the up button and doing the action. 420 00:45:41,580 --> 00:45:49,020 That is a virtual machine which forwards it into the ANSM script, which will then have a vector handler to then react to the button press. 421 00:45:49,180 --> 00:45:56,320 Then to actually allow multiple events to kind of exist and have different menu modes, you can actually chain multiple of these ANSM scripts together. 422 00:45:56,380 --> 00:46:06,200 So after you finish the button press animation, you can then go into another ANSM program for like the next menu item or the sub menu for like the airband player and things like that. 423 00:46:06,400 --> 00:46:15,660 There's also support for preemption to kind of every time you see a sleep animation, it's actually preempting and launching another ANSM script while another one is kind of in sleep mode. 424 00:46:15,880 --> 00:46:19,920 And it allows, it'll yield back controls to the previous script when it's done. 425 00:46:19,920 --> 00:46:21,860 And you can also send signals out. 426 00:46:21,860 --> 00:46:30,060 So on the actual, when you hit like the volume up button on the volume menu, that's the ANSM script actually saying, hey, to the firmware, please turn up the volume. 427 00:46:30,180 --> 00:46:36,780 So all of this, like the UI was actually not really developed in C, but it was developed in this ANSM scripting language. 428 00:46:37,040 --> 00:46:45,680 And so this just allows a lot of the UI to be offloaded and live in ANSM scripts rather than inside of the actual C code. 429 00:46:45,680 --> 00:46:47,740 And of course, there's also a host emulator. 430 00:46:47,740 --> 00:46:51,480 So you can run the VM and develop all this without even having an SAO. 431 00:46:51,480 --> 00:46:58,420 So this was one of those small creature comfort things that ended up spiraling into a full virtual machine. 432 00:46:58,420 --> 00:47:02,420 But that's what's running your, your UI on here, this ANSM script. 433 00:47:02,420 --> 00:47:24,120 So and one final small thing is the ITC support for this, we wanted to have the ability for winglet to control it, like the main badge, as well as so you have your basic tuning, but all the settings and presets we loaded in with presets for Vegas, but you're going to go home and you're probably going to want presets from your local region. 434 00:47:24,120 --> 00:47:29,100 So if you have a badge, you can program it with the UI, it'll give you settings to modify it. 435 00:47:29,100 --> 00:47:30,860 But it's also available over ITC. 436 00:47:30,860 --> 00:47:35,760 So we'll be looking at trying to release all the commands to do the reprogramming. 437 00:47:35,760 --> 00:47:39,800 So you can just have an Arduino or an ESP 32 and change all the presets yourself. 438 00:47:39,800 --> 00:47:43,180 So all this control is available over ITC. 439 00:47:43,540 --> 00:47:46,820 But the only issue with that is there's only one ITC interface. 440 00:47:46,820 --> 00:47:50,300 And we also need ITC to control the DAC. 441 00:47:50,540 --> 00:48:03,560 Now, the same thing would be to do the ITC device inside of the actual hardware peripheral, which is designed to be asynchronous clock and derive the clock from like the ITC controller with like bit banging it. 442 00:48:03,560 --> 00:48:09,220 But we wanted to use ARP to allow easy hotplug detection and make it kind of just work when you plug it in. 443 00:48:09,640 --> 00:48:21,720 So the we're using this fifth sensor controller core inside of the chip just to run an ITC controller, do all the clock recovery and clock synchronization to fully implement like an ARP compliant ITC device. 444 00:48:21,720 --> 00:48:23,760 So you can listen to two addresses at the same time. 445 00:48:23,760 --> 00:48:33,480 So it has auto hotplug detection, removal detection, you don't have to worry about colliding IDs, you can plug three of them on the same ITC bus and they will all just work and figure each other out. 446 00:48:34,360 --> 00:48:40,260 And it also we're also trying to work with other badge makers to kind of standardize this SAO identification and hotplug. 447 00:48:40,260 --> 00:48:46,140 So all the SAOs that have like microcontrollers on them can have this kind of just works experience and auto detection. 448 00:48:46,140 --> 00:48:49,140 So that's the thing for that. 449 00:48:49,140 --> 00:48:53,320 But yeah, that's our the work we've been doing this past year. 450 00:48:53,560 --> 00:48:54,680 Thank you. 451 00:49:04,120 --> 00:49:06,960 Yeah, I think we have at least around five ish minutes for Q&A. 452 00:49:06,960 --> 00:49:09,760 So if you have a yeah, if there's any questions. 453 00:49:15,100 --> 00:49:18,020 I don't believe we have any more right now. 454 00:49:18,020 --> 00:49:23,180 And I don't I have no, I don't know if we'll have any more. 455 00:49:23,260 --> 00:49:26,260 That's a ask their their space village leads question. 456 00:49:26,260 --> 00:49:29,220 But unfortunately, no, I think we are out of stock. 457 00:49:32,370 --> 00:49:33,330 Question. 458 00:49:37,790 --> 00:49:41,730 It can transmit I have removed all the transmit capabilities. 459 00:49:41,730 --> 00:49:44,490 So we aren't transmitting out on airband and things like that. 460 00:49:44,510 --> 00:49:44,830 So 461 00:49:48,290 --> 00:50:02,690 yeah , there is a some some things have been removed to make sure it's receive only but yes, it's a transmit capable and it would be interesting to do other projects with this to kind of create things because it's a very powerful chip and having this low level access would be really nice. 462 00:50:02,690 --> 00:50:12,210 One thing like maybe worth mentioning as a side note on like transmit is that while we can do arbitrary IQ receive these chips do not support arbitrary IQ transmit. 463 00:50:12,310 --> 00:50:13,630 They are quite flexible. 464 00:50:13,630 --> 00:50:18,290 And you know, the more like crazy you get with the low level firmware, you can make them do crazier things. 465 00:50:18,290 --> 00:50:23,970 But just like we also had that initial idea of like, hey, can we do IQ transmit? 466 00:50:23,970 --> 00:50:24,570 No. 467 00:50:24,770 --> 00:50:28,190 But it is quite flexible in the transmit modes regardless. 468 00:50:30,250 --> 00:50:31,130 Question. 469 00:50:32,210 --> 00:50:34,150 We will open source. 470 00:50:34,150 --> 00:50:41,470 I think the ANSM and then we'll like the all the ITC stuff but some of the we've been very busy. 471 00:50:41,730 --> 00:50:44,590 As you can imagine getting everything ready for this DEF CON. 472 00:50:44,590 --> 00:50:46,650 So we don't have things ready like right now right now. 473 00:50:46,730 --> 00:50:57,010 But we're hoping to trickle some stuff out in the coming, you know, coming weeks, as we as we recover on sleep, like like the ANSM toolkit, like I think that's pretty cool having like that animation framework. 474 00:50:57,470 --> 00:51:06,250 And you know, since we already made a virtual machine, if you can put it on anything else, like all the tooling, all the scripting is there and like, we'll go through what we can. 475 00:51:10,260 --> 00:51:11,140 All right. 476 00:51:11,300 --> 00:51:12,300 Thank you.