 Hello? Hello? Hello? I'm getting started a little early, so we'll wait a little bit longer than we normally do. If you're watching this after the fact, check the description for time codes and you'll be able to seek through the video. It generally is about two hours long, so that's really helpful to find interesting topics. Unless you're like me, where you kind of just want to like hang out and soak it in. So I'll just say hello's. I was sitting around being like, what can I do for five minutes? I was like, I'll just turn it on. So hello Rich Sad, hello Dexter. Eight inches of snow overnight in Massachusetts. Yeah, I played video games with a buddy last night. He had to get ready for it as well. Hello unexpected maker. Hello Slobodan Vitovic. Hello David. Hello Wolf Productions. Thanks for hi RCCNC. Happy Friday. So we're just gonna hang out for a little while before we get started and these streams are chill anyway, so it's all good. My sinuses have been not too pleased with me, so we'll see how. Yeah. Pull out the snowshoes for eight inches of snow. Hello the Englishmen. If folks have questions, I'm happy to answer them early as well. I want to talk more USB host stuff today, but we'll do that in a bit. I love answering questions, so it's pretty cool. Ham's Lab says, I did the same five minute thing, but I just sat by the window, but the sun hit my face. Yeah, I made sure and I just said hi to you, the Englishmen. Hello nanoraptor. Hello Patrick. Hello Andrew R. I went for a walk. I did get out. The sun is out. It's probably not gonna be out for too much longer because there's this fake spring here in Seattle and we're approaching the end of it where it turns gray and gray and rainy. I said hello to Patrick. Yeah, just trying to figure out what I'm gonna wrap up this week before I call it a week and then I'm taking Monday off, so next week will be a short week as well, just like this one was. Labie Hunt says it's 11 p.m. here. Yeah, you must be in Europe. I am. I'm not sure where I ended up now. Hello folks. Welcome, welcome, welcome. Rich says they lived in Seattle briefly. Did you fall for a fake spring when you lived here? So yeah, this stream will be about two hours. We've got a couple minutes before the normal time, so we'll keep chit chatting and if folks have questions, I'm happy to take questions at the start. Germany, I have relatives in Germany. Yes, it's late. We do have some Europe folks that say okay, good night. Thanks for staying up late. Hope I am entertaining and informative. We'll do a lot of talking here shortly. RCCNC says I'd take gray and rainy over below zero in snow. Yeah, totally. It tends to be either pretty chilly and pretty chilly and sunny or like it is now or it tends to be warmer and rainier. I am says there. It's 11 p.m. where they are as well. Fomy guy, welcome, welcome, welcome. Hello, Sea Grover. Rich says I love to beaver tin but had an apartment and spent weekdays there. I have cousins that were raised in beaver tin. I don't like that much snow. I like that in Seattle we can go to the snow, which is what we're doing this weekend while I'm taking Monday off. Although I assume they have snow. Maybe they don't. We're going into the mountains this weekend. It should be cool. I may have bought cheese from Ham's lab's other sister. Hello, Tammy. Oh, you went to Seattle for weekdays. Bruce says it's sunny here, rather cold this morning but nice now. Yeah, you you've exported all of that cold air down to here. That's why we're so cold down here. All that Canadian air. He can leave the snow and come home. It's true. I like going to the snow. I like going skiing. All right, let's get the show on the road, on this road here. Hello, everyone. If you don't know who I am, my name is Scott. I go by Tan Newt online and I work for Adafruit. Adafruit is an open source hardware and software company with an education focus based out in New York City. I work remotely for them from my house in Seattle here. You can see we have cat cam up here where Spook is currently deciding between the three cat beds, which one he wants to wants to be in. So I work on Circuit Python for them and for Adafruit. Circuit Python is a beginner friendly version of Python for little tiny computers called microcontrollers. So those are great. They're inexpensive. They're really good for beginners and they just do one thing. If you want to chat with me and a lot of others, you can join the Adafruit Discord server, which is the middle box here and I can never remember which way it is. The middle box there and you can join by going to the URL adafru.it slash discord. If you want to join that, that chat lasts kind of like all week, which means it's nice to just hang out and stuff. Deep Dives happen every week. Normally Friday is at 2 p.m. Pacific, which is just three minutes ago. It typically goes for two hours or more. We tend to hit the two hour mark and don't tend to go over very much because people have other things they're planning on doing. But because we have a lot of time, I'm happy to take questions. So if you've got questions about electronics and that sort of stuff, I'm happy to try and answer them. I make no promises that I can, but they're fun and I love covering different topics. I will be streaming next week, but that will be the last week for me to stream for a while because I will be on paternity leave sometime next month. The baby is due in a month from today, which is exciting. I didn't want to plan on streaming up until the baby arrived. I wanted to give myself some leeway. So Foamy Guy has generously offered to take over this spot on Friday, so we're going to keep streaming. We'll keep having streams here on Adafruit's channels at this time, but Foamy Guy is going to be doing those instead while I'm out. We do have notes that are taken. Thank you to David for taking those. They're available on github. You can go to github.com slash Adafruit slash deep-dive-notes. That will get you to a repo that has all of the different notes and there's time codes in there, thanks to Patrick's awesome scripts that add the links in there. Thank you to David and Patrick for making the deep-dive notes repo happen. That's it for housekeeping. That's all I've got. I had a couple other folks check in in the chat, so NanoRaptor said 30C and thunderstorms here a little later this week. I just might like a visit from Snow. Yeah, 30C is very warm, right? It's pretty warm. Tammy says, I know that in Arizona we get 50C in pouring rain days. I love the factory, says Ola from Fresh Powder in the mountains of Rado. And hello, Thomas. I didn't say hi to you yet. And David points out that we're chatting in the live broadcast chat channel on Discord here. That's what's showing next to me. And I am asked, are we going to make a heart with a microcontroller today? Not going to do that. Love the factory asks, is it true? Zinc is in the running for baby names. That is not true. We're not going to name our baby Zinc. We've not talked about that. It was supposed to come today, but I don't think it's actually coming today. I think it's going to end up coming next week. I checked the tracking and it was like not even in Seattle. It still says it. This app says that it will arrive today, but that it's also in North Dakota. Ooh. I ordered one of those Spotify car things because I got excited and I thought I knew what it did, but I didn't. I watched a video after I ordered it and was like, oh, that's not... How about Blinka? Baby name? No. I'm not going to... Well, we'll see. I have one nerdy thing about the the baby has tracking. Wouldn't that be nice? I mean, to some degree, the baby has a delivery date. Hamzab says, can you say some words about your shirt? Is that XKCD? So I'm a rock climber. This is a Prana shirt. It is not XKCD, but I think it's a Prana shirt. Yeah, the stork is fully wired with GPS. Yeah. I think it's just a design that... This is just a design that Prana had for clothes at one point. I've got it in... I was going to say orange. I might have it in orange. I have it in multiple colors of t-shirt. I wanted to pick... I thought about wearing black again, but the camera has more trouble if I wear a black shirt than if I pick a shirt that's more of a kind of middle tone. All right. Do folks have any questions before I get going? I guess I just answered two questions. Any more questions before we keep rolling? One. So long as the baby is not in North Dakota with the package. I don't think that's true. I think the baby is here inside of their mother. Oh, wow. Bruce says, I met an ice climber on the chairlift today. He lives to ice climb. That sounds scary, but I guess you have, just like when you're rock climbing, you have anchors and stuff. Okay. Well, I've been thinking a ton about wearing a nice green one so we can green screen stuff onto you. This is about as green as it gets. Rich says, any good examples of interrupt usage in Circuit Python. So we don't do interrupts in Python code itself. MicroPython does allow it, but there's memory allocation constraints around it that make it pretty tricky. So we don't allow it in Circuit Python. However, we do use it internally, and if I had to think of an implementation that uses it, I think of pulse in is probably an example where we're using it internally. They free climb and only anchor every five meters in ice. That's a little wild for me. It's a little wild for me. Okay. I think I answered Rich's question, but they're typing, so I will vamp. I thought there was new support in the latest stuff, my mistake. So what Dan has enabled is async.io. So async.io now allows for cooperative multitasking. And he does have an example. He might have an example where you're allowed to like await a pin changing, but we've been talking about that. So we're not, we haven't really talked about allowing interrupts, but we have talked more about like leveraging interrupts kind of under the hood to allow you to use async.io to switch between things and await something that is kind of like under the hood and interrupt. Yeah. The anchors are about 16 centimeters long. He says fairly secure, but if you lose your grip while you're placing the next one, it's a long drop. Yeah. Yeah, I bet lead climbing, they're not that far apart either. Lead climbing is kind of the same idea where you're climbing above the bolt, but they also tell you that like it's better for you to drop further because then the energy of the drop goes into the rope. If you are really held tight and not allowed to fall down, you'll whip around the bolt and like slam into the wall instead. So, so yeah, fun. Okay, so let's talk USB hosts. So last week we, maybe I should pull them up through the desktop in just a second. Let me just, I did screenshot or save, where did I save them? We drew some stuff out. They're kind of tiny. Yeah, of course. Tammy says, I imagine it's better to fall further is true within limits. Yes, definitely. I think some of the scariest parts of climbing, lead climbing, where you're above the bolt is like above that first bolt where you don't have much distance between the first bolt and the ground. So yeah, totally. Okay, desktop. So here's the writing I did last week when we're talking about the USB host API. UnexpectedMaker says, have you been practicing with your tablet? No, well, that's what I did last week. That was me practicing with my tablet. I'm not planning on using it again today. Yeah, not planning on it. So we had like a USB host class with port that would allow you to initialize stuff. And then it would have that devices, and then you would have a device class, it would have some stuff. And then here we'd have endpoint in out and control. And then this was kind of my example. So importing hosts and then listing the devices on it. Now, I was talking with Dan about this, I talked a lot of, I talked to a lot of people about this, I talked with tack as well. So tack is the maintainer of tiny USB. And both tack and Dan and I kind of came to the conclusion that this was a bit of a low level API. 49 inch screen, that's giant. So there was some concern, well, tiny USB doesn't provide an API that is quite this low level. Tiny USB has class drivers. So classes are like HID, mass storage, CDC, for example. And so, and then on top of that, Dan and I were talking. And both I was thinking about the work I would have to do in tiny USB to do generic stuff. And then, you know, Dan was pointing out that for device side, we really don't try to be super generic. We're okay being specific classes. And then on top of that, in circuit Python, we want, we'll probably want more native support for particular classes. So for example, when you plug in a keyboard, wouldn't it be cool if the keys that you pressed are put as like input into circuit Python? Which is something I definitely want to do. So, and then imagine that if you like plug a USB flash drive in, you would want a similar thing of like it shows up and it mounts and stuff. So I think, I think there's definitely a world where we want that specific stuff. And that was kind of like the conclusion that tech and Dan and I had come to. And so I started to be working it, but I've still, I was kind of hung up on getting started on it still. And I had a thought, but let me pause. David says, thanks for the links to Ben Eaters USB videos. Yeah, you're welcome. Those are great videos. And then Charles says, I was trying to understand the difference between host and peripheral devices. Peripheral is from a device to the controller and host is from the controller to the device. The USB UF2 boot loader has both, but tiny USB only provides the peripheral side of things to circuit Python. Is that right? I think you're mixing things up a bit. USB host is not only, it is okay to call the USB host the controller because the USB host is basically setting the, setting the, like pacing the whole transactions, pacing the transactions for everything on the bus. So it will say, so one thing the host has to do is every millisecond it has to say, okay, here's a new frame. There's a, there's a packet called start a frame that it's supposed to provide every millisecond. And chips like the samd21 will actually adjust their clock based on those, which is really fascinating. And so that's one thing the host has to do. And then the host is actually the thing that orchestrates all the traffic on the bus. So like USB devices can actually hear each other because it's like a shared bus. So what the, what the host kind of has to manage is it has to say, okay, this device or when a new device is plugged in, the host is responsible for saying, okay, now you have to be called this. Like this is now your, your number. So like default zero is like the default. And then the very first thing that happens is a new device number is assigned to a new device. And then from then on, what the host can do is say, like, okay, now I want to hear, I want to read this or, or, or send this data to this particular device number. Whereas like the peripheral side, the USB device thing is just kind of taking instruction from the host and replying to kind of like the standard stuff that the host is going to ask. And so hopefully that makes it a little bit clearer. So tiny USB can do both. If you're looking in the tiny USB code, you'll see like TUD is tiny USB device and then TUH is tiny USB host. And did I show, maybe I didn't show this, did I have the, I think I did. I think I did have this IMX demo working last week, right? Like I did show this dev board and show that demo working. That demo is now, that demo is now showing, or that, that demo is now checked into tiny USB. So if you want to try that, it's available there. Tammy asks, so how does collision detection work on USB bus? Do the devices just not communicate until the host asks it for a data packet? That is correct. The, the, the devices only reply after the USB host has requested some data. And there's a particular like, so, so USB is a differential protocol. And this, the Ben Eater videos are great for this. So there's like a particular differential state that indicates like when a packet is finished. And all the USB packets do also have CRCs, which are like individual bits that are used to, to basically check that all of the bits were transferred correctly. So you can manage to figure out whether like your data was corrupted and stuff. But, but yeah, generally the host is orchestrating everything. So, so for example, if you want to read data from a particular device, the host has to say, the host sends what's called an in token. I thought that USB three might allow a non-pulled peripheral. I don't know. So maybe I am not, I've never done USB three. So everything I'm talking about is really just USB two. And USB two has three different speed tiers. It's got low speed, which is one and a half megabits per second. Full speed, which is 12 megabits per second. And then high speed, which is 480 megabits per second. Whereas the first two were also kind of like USB 1.1 as well. I'll tell you what would know is that this thing that I have on this cat tree next to me is this USB complete book, which I don't think I actually plugged last week. But this is a great reference if you're ever doing USB stuff. And it does include USB three things as well. The only other thing I don't know enough about USB three to be able to tell you whether it's it's actually true that there's something that's not pulled. But I will tell you that there is an interrupt type of endpoint on USB two, which is very commonly used for HID devices. But it is actually still pulled. USB three simulates pulling. So USB two is still pulled. USB two, even for the interrupt, you say, okay, what is this concept of book? I really like reference books. If I was just to read it back and forwards, I wouldn't buy it. But yeah, so even if you think you have an interrupt endpoint, so endpoints are like kind of sub numbers of a particular device. So you can say like, I want to I want to write to this particular endpoint. Those, even if it's called an interrupt one, it's still actually pulled. And part of the description of that endpoint will tell the host how often to actually pull that. So interrupt does not really interrupt, even on USB. So hello, Beata. Welcome, welcome. Okay, so hello, AcoDroid. I don't really want to get political about Ukraine, but thank you for the donation. Let's see. So I was thinking about USB host, and we were thinking that we probably wanted to be above the class level or at the class level. And then I was like in the shower or getting in the shower. And I basically realized, you know what can do USB host already? Linux Linux can do a USB host, right? Like most of what Linux computers are doing is USB host. USB device is much weirder for a Linux computer than USB host is. And that got me thinking, oh, well, if Linux is doing USB hosts, then there's got to be an API in Python for USB host already. And I pinged DaShippu, who's an awesome community member, and I said, hey, do you know what? Yeah, well wishes for the folks in Ukraine. Hello, Michael. Good morning. Yeah, so I was like, oh, the real thing that we should do for a USB host API is match an API that exists on NC Python on Linux. And DaShippu pointed me to Pi USB, which is looks pretty awesome. So let's just pull it up. Not Pi USB. So this is USB access for Python, which sounds pretty much like what we want. And it's got a pretty good tutorial and stuff. So if we look here, there's definitely work to be done, but we could help with it too. It's 100% written in Python, it's platform neutral. So they've got other different backends. It's meant to be easy. So yeah, they have, so it's usb.core.util.control.legacy.backend. Just started sort of, yeah, we just started talking about USB. So here's what an example looks like. You can say usb.core, or you import usb.core and usb.util. And then you can do usb.core.find. And if you know the product you're looking for, you can do that. There's also a find all keyword arg that you can give it, and it will actually return multiple results back to you. And it was cool because I could just test it on my computer here. And then what you can do is you can do this configuration stuff, find a descriptor, and then you can just dot write to an endpoint, which is interesting. Interesting. I hadn't grok that fully. There's also, you can also do device.write, and then give it the endpoint number. This was the phrase in usb 2.0, the host controller pulls the bus for traffic. I mean, that's true, right? Where is that here? The host controller directs traffic flow to devices. So no usb device can transfer any data on the bus without an explicit request from the host controller. In usb 2, the host controller pulls the bus for traffic, usually in a round robin fashion. The throughput of each usb port is determined by the slower speed of either the port or the device. Because there are two separate controllers in each usb 3 host, usb 3 devices transmit and receive it three data rates regardless of whether usb 2 devices are connected to that host. Sounds like what I've been talking about. Usb 3 suspends device polling, which is replaced by inter-derived protocol. Where's that from? That's not from here. But yeah, I have not done any usb 3 stuff. I think probably the most likely direction I go into the usb 3 is probably doing power delivery first. Because I think it would be really neat if you could just have a microcontroller board that could just negotiate for a lot of power, even if it's not doing 3.0 data rates. I'm actually, let me open the window briefly because it's now 80 degrees in here, which is hot. This cat is all stretched out. It's cold outside, so I shouldn't have to leave it open. Yeah, so what I realized was like, oh, I don't need to design an API, I just need to reimplement one. And I also realized I was using PyOCD to connect to this IMX. So PyOCD is this really neat project that is kind of like open OCD, except it's written in Python. And nothing we're using is the usb 3.0. We don't even take advantage of usb high speed. Like we only have a few devices that are even usb high speed, the IMX being one of them. But that would be, it would be neat to take advantage of it. We could do like small video and audio stuff over it, I think is something I'd still like to do. Oh, SparkFun has a power delivery dev board. That's neat. I wonder how popular it is. Yeah, so PyOCD is really cool. It's like open OCD, but written in Python. It's an open source Python library for programming and debugging ARM Cortex and microcontrollers. And I was using this for this IMX and then I controlled seed it because I was done with it. And in the back trace was PyUSB. So this library uses PyUSB, which is really neat. It's really neat that this PyOCD is based on it. And then I was talking with Jimmo and he pointed out there's also PyDFU. DFU is a common way of loading code on the microcontrollers as well. And if we look here, it's got usb.core and usb.util as well. So it's also built on PyUSB. So I was like, this makes so much sense. It makes so much sense to support, to just have our API be a subset of PyUSB so that you can write PyUSB code here and then use it on Blinka or in CPython with Linux as well. We've gotten at least one person recently that's like, I want to do USB HID stuff in Linux. And that's pretty hard, but it makes so much sense. And it's so worth it to be portable between the two. Yesterday I was just kind of like, once I had this thought and once I found PyUSB, I was like, oh, obviously. It was funny. I checked with LadyAda about it. And I was like, LadyAda, have you ever done PyUSB? And what do you think about it? And she said no. And then I was like, well, no, that's not true. Like I had found a video of her talking about it. It's been around a while. So it just makes so much sense to just do PyUSB. It's not a perfect API in my mind. It's a little weird that you have find and then find takes a command called find all. And then there's a couple, read and write will also vary the way that they work depending on if you give them a buffer or a size. But besides that, it's okay. It's fine and it's well worth the compatibility to match. UnexpectedMaker says, my original Pro S3 design had power delivery on it, but I couldn't get any chips and redesign three times and then gave up and took it off. Yeah, chip shortage is real, right? Chip shortage is very real. And I'm like, I'm not even directly related to it. Although Dan and I were talking when we were chatting USB stuff of like, how there aren't a lot of new chips for us to add support in CircuitPython right now. Nice discussion about the USB 2 protocol. USB nut shell, right? So there's this like token packet and that's what the host writes. AcoDroid says, when do you think we can buy a Raspberry Pi? No stock ever Raspberry Pi 4 is a myth. Yeah, chip shortage is real. Just like I said, I mean, I'm an optimist. And so I think that I think in hope that once we're through the chip shortage, we'll have like too many chips, which will be fun. So a lot of new chip designs, a lot of availability ideally. But you know, we'll see. Depends on how COVID goes, I'm sure. But yeah, this has nice charts on kind of like the sequence of things. So yeah, so what I concluded was that the the best USB host API is the host API that already exists. And that is, and that is Pi USB. Rich said, says you can get them for over $100. Ham's lab says, I'm working on a project for an artist that I need a bunch of Pi zero 2W boards and I'm waiting for stock. RaspberryPylocator.com. And yeah, Dylan points out that you can always add power delivery later as a revision. Yeah. So I mean, I'm an optimist that like, it's going to be pretty neat at some point. It's going to be neat when we're out of this chip shortage, like it's not going to last forever. But until then, sit tight. And I think at Adafruit, we've been pretty happy that CircuitPython has given us a lot of flexibility. Right. It gives us a lot of flexibility because our software layer is standard. So yeah. Oh, Blink is also using Pi USB via Pi FTDI. Interesting. So we could do FTDI stuff from CircuitPython. That would be kind of neat. Yeah. I expect to make who's got design power delivery for sure. Yeah. Yeah. Same with these IMX chips. They're kind of hard to come by too, I think. I think, where did I see it? Maybe some folks have heard this, but I thought some of the some of the chip shortage was due to the fact that some older fabs were turning down old processes and like the chip manufacturers actually had to redesign them for like smaller nodes. But maybe I'm wrong. Oh yeah. And there's arpilocator.com too. Bruce says, I was talking to somebody today and he said buying a C container in Canada is about 14k now, but it was around 4k before. I'm sure it'll stop at some point. Until then, we can just make cooler software, which of course I'm biased because of a software person, but like there's a whole lot more software we can write for the stuff that we have already. Somebody was doing some interesting analysis of like iSquared C execution time on ESP32S2 and stuff. So, but yeah, I guess, I guess if you're not selling software that's not that comforting. UnexpectedMaker says, I thought things might have turned around that some of my parts became available and at reasonable prices, but speaking to other folks they seem to think it's getting worse. Yeah, I think like I know Lady Aida got a big order she did a year ago, so that's good. Yeah, and lots of lots of factors, not just one is what Rich is saying. So, Charles says, endpoints allow multiple devices to be one, i.e. the Raspberry Pi keyboards, which have a hub included. So, endpoints are different than having hubs, like hubs aggregate separate devices, but endpoints are a little lower level as well. There is an intermediate layer in, so one of the standard things with the USB devices that the host can request a descriptor, and the descriptor is what tells the USB host what kind of device it is. And so it will say, I have these different configurations, and then within those configurations I have different interfaces. And where was I looking at this? It's kind of, yeah, in the in the Pi USB stuff that I was looking at kind of has that. So, if we go back to this tutorial, I think it's here. So you can say, what configuration do you want? And then this is just trying to find a particular interface or a particular endpoint, but an interface can be a collection of endpoints. I don't know where that is covered here. But yeah, like a composite, yeah, so you're like, here's an interface number, a confluence of factors. HandsLive hasn't had too hard of a problem getting STMs. I thought STMs were hard to come by. Which STMs? Hey, Xarlin. Glad you could stop by. Bunch showing up in March. Higher end new stuff. Ooh, fun. Yeah, we'll see. I know the Raspberry Pi RP2040s have been available, but of course that's a microcontroller, not microprocessor. Okay, so let me show you what I've done. So now that I figured out what I want to do, I started doing the interface here. So let me just, do I want to use merge or text? I'll just use text. So I was laying out all of the, oh, I know it is too large. Yeah, we'll use merge. Let's use merge. New, new, new. Okay, so here's my diff program. And I just wanted to run, give an overview of what I got going so far. Remember whenever buying these microcontrollers, I always get two of them. Hello, Pierre. Thanks for joining. So okay, here's what I've got so far. I'm trying to get the kind of the shared bindings layers of everything set up. So, but of course, I did the common how part. So this is on the IMX port. And I'm just doing the boiler plate. So I still need a way of constructing the new port, like initializing it dynamically. So I still have a USB underscore host module. But the only thing it has is a port, is a port object that just stay like is there. There's not anything you can do with it. But you give it the D plus, D minus, and then it will construct it and you can de-initialize it as well to release it. And it has no entry entries yet. So this is, so in circuit Python, you have the VM and then the modules that are exposed there are C structs under the hood. And then those C structs have functions in them. Those functions are the thing that convert from Python land into C land. This is how circuit Python is structured. So what I was going for here is to get all of the, all of that boiler plate set up because I knew what the API would be now. And then I was thinking that one goal of mine could be to actually get that going, getting it to the point where I could list devices in from circuit Python, which is a bit ambitious. But we do also, we do also have a lot of time. So maybe we could actually do that. Aquadroids says, are you living near an airport? I do not live near an airport, but I do live in a city. So there are planes that fly overhead. And the window is open. So you might be able to hear stuff like that. Although I don't think I've had the window open with my thing here. My temperature sensor says it's above 80 even though the window is open. I only have one window open. So I'm not getting the cross breeze. Okay. So I did the common HAL stuff and then I had to add to the port the ability to turn it on. So that's what this is. Maybe I can get a bit bigger. No, I thought that's the right key. Sorry. I don't know how to make it bigger. So hopefully it's not too bad. So this is an MP config port. I am turning on USB host if it's a 1062, which is what I've got. Lake Union is an airport. That's true. So here's the build stuff. So this is saying, if you turn on USB host, we'll build everything from USB host and USB. And then we've got USB host port file. We have USB core and USB core device. Control plus wheel scroll. Oh, I have it mapped as... I have a weird setup. Can't figure it out. Sorry. Let me see. I could do preferences. Font size 12. There we go. That's a bit better, right? Okay. So here's our build file. We're saying if USB host is enabled, then we're going to build USB host, which is the port initialization, and then USB, which is the subset of Pi USB. And right now we just have core and device. This just says it's off by default, and we're going to pass it the value onto the C flags. And then we get into shared bindings. So there's a diff here because I had the older version of the API that I was working on. So it's going to be a little weird to read, but you can see I was starting with USB host and then I renamed it. So this is the top level for core. Oh, good. I'm glad that's better. If you need it bigger, let me know. So here's just... This is the table of names in the USB module. So dunder name tells you the name of it and then core maps to another core module. So this is when I say that objects in Python objects are actually C structs under the hood. This is a perfect example of that, where this USB module here is a C struct. It also has this... This is a pointer to the global's table here. So it's kind of like actually two different things. And then... Well, you know what? Can I show... I can show the combined diff. Let's do that. So this is all the IMX stuff that I showed. This is the build stuff and the build stuff. And now we're in... Yep. So this is the USB module and then nothing in the header. If there was any functions or something that were in that top level module, then the common howl versions would show here, but there aren't any. For device, you can see I copied the... I copied the copyright notice from PyUSB because it's BST3 and I was copying... I was like literally copying their function signatures, although I reworded some of it as well. So here's device. So there's a bunch of properties. There's ID vendor, ID product, which are the USB, VID, and PID, which is kind of what we call it. Those are properties. And then we have serial number, product, and manufacturer strings. And then we have write. So writing data out and then reading data in. And they have these weird... The read is a little weird in that you can say size or buffer. So if you give it a size, it will allocate. If you give it a buffer, it'll write into there. And the return argument changes, which is weird. Whereas in CircuitBy, then we have like read and read into, for example. I haven't looked at the stuff that builds on top of this yet to see which of those two it uses. I actually suspect we're going to want to support both, which is going to be kind of a pain, but it is what it is. And that's what you get for trying to be... We could support one or the other. And that would let you... That would let you move code from CircuitPython up to Py into CPython, but not the reverse. But ideally there's some... We'd like to do stuff the other way. Zarnlin says, is this all C, a mix, or a mix of C and C++? It is all C. One thing that's weird though is that these shared binding files have these... So the forward slashes, two forward slashes is a comment in C. And then this pipe is a special CircuitPython thing, which says, take all the lines that start with this and then treat it like a Python stub file. And that's how we get all of the CircuitPython.readthedocs.io documentation. And we generate Python stub information from this as well. Yeah, so the slash slash is a single line comment, whereas the slash star is the multi-line comment. So this... Yeah, so we have a script when we build CircuitPython stubs that takes from all of the shared bindings files any line that starts with the slash slash bar and then strips it out into a stub file, which is really handy for editors and things. So that's why what you're seeing here is kind of like a Python function declaration. And this has even some... I put some type annotations in it. So it says endpoint is an int. And then this is how Python annotates the return type. So it says it returns an int. It's not quite true. But one of my principles when I'm working on stuff, especially APIs, is that I like having the documentation, which is what this is next to the implementation. That's right. So this code here is C code that is implementing the conversion from Python land, which is what we're documenting, into C. AcoDroid says, what Diff tools can you recommend from Mac users? I do use Diff on the command line. There is a thing called Delta that I haven't gotten used to using yet, but that's kind of a cool command line thing. And that's... Oh, I guess you're talking Mac users. This is not actually Mac, but Sublime Merge, which I'm using right now, is available on Mac as well. That's where I started to use it. And Rich says, neat. Yeah, this is something I really wanted to do. It was an idea I had pretty early on. It was before we even started calling this circuit Python. This is something that I wanted to do. And this goes hand in hand that this shared bindings directory is shared amongst all the ports, which means that that Python API is identical between the ports as well. Do not teachers at school emphasize lots and lots of comments and code? I got formal computer science training at university, and I felt like they were a little bit all between that and when I went to Google. But it wasn't just that you have to comment everything, because if you tell people to comment everything, then they just comment... They write in English what you should be able to understand from a simple line of code. Yeah, maybe I got more of my comment philosophy from composite devices. Yeah. Yeah, Michael's like, yeah, comment, set X to 1. Bruce says I've been using Beyond Compare, which has a Mac version. Yeah, Rich says there's been an anti-comment movement in coding standards, but I agree with this philosophy. Google's philosophy when I was there was basically like you comment the API on what external people need to know, and then you comment the implementation, which summarizes the details of the implementation comment gives you any hints as to what's tricky. And they were all... Yeah. When I joined Google, Google has this idea of readability, because they want the code base that they have to be uniform, regardless of who wrote the code. And so they have style guides, and every time you check in code, you have to be approved by a reader, readability approval to make sure that you match kind of like the uniform style. Yeah, so Bruce says if you want to take a look at the discussion about DiffTools on Mac, there's a link there in the Discord. And if you want to join the Discord, I'll just drop the link. Readability is massively important. Yeah. And even since then, there's been more of a focus on code formatting, programmatic code formatting, I should say, and that's a huge win too. Okay, so we're going over this API. And so you can see that I've got like initial argument parsing stuff here, and then it's passing into common HAL USB core device read. So this is the function that's like kind of pure, pure, but not always pure, like C land. There are some cases where we need to like take or return Python level structs. But generally, that's not ideal. Like generally, you don't want to do that. And you can see here that like core device read is it's return thing is being converted. So there's np-obj, new small int, it's going from a C int object out to a Python object and returning that, which depending on the value will actually be different on how it does it. But yeah, this is the just with shared bindings. And we've talked about this before, but I think it's really helpful. Dexter says, circuit Python has helped me write better Python code. That's good. And Pierre points out, if you need to comment to explain non-code reasons why something is done this way, then okay. Doing this lowers power consumption. Yeah. Yeah. A long time ago, commenting your code as a way to not get stuck doing the same project forever, you need to be able to hand off your code. I think that's a huge, huge goal, especially for more, more experienced folks, is you just got to figure out how to not make yourself critical. And I'm feeling like I'm in that position right now as I'm like about to take six weeks leave is like I don't think I'm, I'm, I'm not really the bottleneck for anything. Like everything will keep going. So I didn't realize. Come on. There we go. Now I'm on eye tracking mode. I think it's really good policy to try to keep yourself redundant in a way so that when you leave, you can still, like everything still goes on without you. It's a whole lot less stressful if everything can be done by somebody else, which I'm lucky enough to be in that position. TAC really likes to have his hands on code. Like he checked in my, he checked in my example, but he redid some of it first and I went back and looked and it looks all good. So I don't mind it. He's a, TAC is very good. So generally it's like, I get something 80% away there and then he does the last 20%. Yeah. And Beata points out you need to be able to hand off to yourself. So it's also good to be able to comment your stuff so that when you come back three years later, you can still understand what you're doing, which I am definitely for my hobby projects, I'm definitely terrible at. Yeah, there's little value in being a single threaded bottleneck in any project or process. And yeah, Narodoc says the same thing, yourself one year from now as someone else. True, true, true. Okay, let's keep going. So read is this weird thing where you can give it a size or a buffer. So it's basically like a mix of read and read it, what we would think of as read into. So that's, that's sketched out there, control transfers are special things, I guess. And you can see they have data or length as well. Or two months from now, I'm a goldfish. I feel, yeah, especially if what's happened in those two months is like me taking six weeks off to learn how to parent and not get enough sleep. Comments are good. Comments, yeah. So generally, you should comment things that are confusing or non obvious, right? But you don't have to comment the obvious things. Yeah, see Grover says my philosophy has always been work myself out of a job. And it's worked nice a couple of times during their career. Yeah, I feel you. Okay, so here's the control transfer thing. Control transfers are also weird in that they can go either direction. So this this comment, which I have cribbed a lot from theirs is just as like, it depends on the requests type will will encode has a bit that encodes direction. Unexpected maker says I'm definitely the exception to the rule. I'm 100% the bottleneck and always will be. Do you want to grow more than one to be more than a single person company? Catney says the first time I did get blame and it was me, I was super excited, achievement unlocked. I had finally written enough code to have forgotten about something I wrote. That's totally like the thing that I asking Lamora about Pi USB and then sending her a link to a video where she's doing Pi USB. See ternary operators not that bad. It's when it gets nested that it gets a little hairy, I think. Okay, so you can see here that I'm doing this is I guess an interesting case in that we have to decide whether we're going to handle this and shared bindings or common hell. And the idea here is kicking and fighting to not grow. Hmm, trying to optimize things instead of growing in terms of employees. I know for me here, there's a lot less I have to do because I don't have employees. I don't know whether people are using Doxygen, but I know Sphinx is, we use Sphinx here, but we're also pretending this is all Python. Yeah, so how do I decide between shared bindings and common how? Well, I things that will be true for all implementations can go in shared bindings, right? So this request type check that decides whether our buffer needs to be writable or readable, like that's going to be a universal thing. That's kind of particular to the API. It's not particular to the implementation of it. I started using Basecamp for side projects because you folks use it. Yeah, we do. I tend to, I don't tend to use it very often, but that's because I'm more in the core. Other folks use it a lot more than I do. Oh, and then there's these last three APIs on this device class are is kernel driver active, detach kernel driver, and attach kernel driver, and you give it an interface number. And I thought this was super cool because like I said earlier, it would be really neat to have native support for certain devices in circuit Python. And that's true in Linux land already as well, right? So it's already true that like the Linux kernel might be using your keyboard as a keyboard. And how do you kind of say it like, no, I want to use it instead. And that's what these are for. And that's why I thought it would be neat to have them is because we'll use those same things so that you can say, hey, circuit Python, like, I want to use this keyboard instead, or whatever the device is. So I thought I'd add those in there. And that can help you like share the two. Okay, so that's it for the individual things. And then lastly, we have something similar to the module where we have the USB core device type. So this is like a type object, pretty much everything in Python is actually an object. So you have a type object, it tells you what the name. So this is just kind of like a string. And then it has a dictionary as well that it will look up stuff in. So these are kind of like the outer objects that reference all the things that we just went over. And I should I guess I could point out here that these MP defines are basically creating function objects that point to the C function here, which is super boilerplate, you could just copy and paste it. So that's device. And then in the in the device header, we've got all of the common howl APIs that that shared bindings is assuming are provided by someone else. Here's the USB core module where we have a find version of find it's it's more limited than than Pi USBs. But again, when we talk subset, we're really trying to just be if you write it in Circuit Python, it will work in the full version, not necessarily the reverse. Although in this case, because there's a lot of source code in the larger version already, it might be okay to like expand the the Circuit Python version for the other stuff. Just found an IBM presentation called documentation in the modern age that has a slide titled cool kids do Sphinx. And another title cool kids used to do Doxigen. I'd expect the maker says this was supposed to be my retirement gig, not my let's build and grow a new business. I've done that before a few times in the past didn't need to do it again. I'm failing at not needing to grow. Well, that's a good problem to have. But you're having fun. Cool. That's good. Okay, so this is the core and you can see in the core. So this is the USB core module, and it actually is registered as such. And you can see it has name in it again, which I guess this should be just USB. This should. Oh dear, wrong button. Oh, this is not an editor. This is my merge thing. I think this needs to be just core. And then you can see it points to the find object, which is the function and but also the device type. So that's core blah, blah, blah. And there's the common how find. Oh, this is the old version that I deleted. So now we have port and this is where we validate our pins and and claim them. And then we pass them in and we just allowed D in it and we allow context managers as well. Port should pretty straightforward. More module boilerplate, blah, blah, blah. Now we're in shared modules. So us the pie USB stuff should be built on tiny USB. So we can just put it in shared module. And so here we just have stubs. Everything's stubbed out. Returns kind of like the de facto thing. And here's the actual object. Oh yeah, AT makers. So the gist is that I think our USB host API should be pie USB, which is something you can use on Linux as well, which would be really cool. Let me just catch up a little bit here. Yeah, Rich said says fun and interesting are my requirements for job. Bruce S says when I retired, I consulted for 10 years, then I decided that I needed more time for all the other hobby projects. Darlin says I really need to have another look at sublime. I prefer sublime over VS code. Because VS code's really noisy. I don't like all the popups. It does cost money, but any tool I use as much as that, it's worth paying for. I should plug AT makers. So as most of you know, we were talking USB host APIs last week, and AT makers, it was nice enough to watch it and then actually did a kind of reply stream. Oh, sorry, WebBSK. I missed you on Twitch until just now. You might be around still says, is the readability check automated? So the readability check at Google was not automated in a sense. Like you actually had to have a person do readability for most languages. Although for example, Go had Go format. So the readability for Go was defined as like run Go format. So I think they're moving to a world where it is more automated. But readability did still involve comments and code style. WebBSK says I would love more auto code formatting on check-in rather than just nagging by the IDE. Yeah, so we have that in CircuitPython because we use pre-commit. So pre-commit will auto code format before you do a commit, which is pretty handy. Visual Studio Code now has a Zen mode. See gesture code. That's not what I want, though. Like I have other stuff open. I just don't want the stupid pop-up that's like, it looks like you're using a Python file. Do you want to install the Python extension? And Sublime Text is very quick. I'm happy with Sublime Text. I don't use a lot of IDE features of IDEs anyway. I do a lot of my other stuff through a command line. I work with a company that took many Google coding processes and commercialized them. Yeah, it's really common. It's really common to also see Google engineers go other places and like either reinvent things that Google had internally or like, yeah, stuff like that. I have not solved everything. Sorry, Todd, but. Okay, so here's the stub for find. So let's see. We've got 45 minutes. Every time I open a file with VS Code, it opens a pop-up about the new update instead of just focusing on my file. Great that I don't do it every day. Yeah, that's kind of my feeling about VS Code is like, it's probably better if you do use it every day and you have it set up like the way you want. But I've never gotten to that point. I've always gotten frustrated before I get there. Whereas with Sublime Text, just open it in the swine. Okay, so let's just see if we can't get it going. I guess first what I should try to do is just load CircuitPython onto this IMX board. I really liked so tiny USB has a flash command that you can just say like make flash and then it will copy it over. And the PyOCD worked really well with it. So maybe that's what I actually do. That's a prerequisite because it's going to make it easier. So Keyron McBean says very informative. If you have questions, I'm happy to answer them too. But thank you. So we have this IMX 1060 dev board. It's giant. This USB here is the dev USB. So this microcontroller is not the microcontroller that the board is actually for. It's like the one access like the debugger. And this is the main microcontroller here. So Tammy says you can bloat Sublime up with extensions and stuff too if you're so inclined. I get irritated by the constant package control pop-ups in Sublime Text. I don't feel like I get constant pop-ups with it. I know what you're talking about. I think it is also funny that a lot of editors have moved to the like what do they call it command palette. It's really undiscoverable in my opinion. I'm definitely one of those people that goes through the file menu to look for what I want. You know how many tiny USBs you can fit on this big dev board. This dev board is cool though because the 1060 has a megabyte of RAM, which is pretty wild. Okay. So let's just get CircuitPython running on this. And let's take a look at speaking of Sublime Text. Let's open that up. I just want to add this flash thing that is in tiny USB, which is really nice. Let me close you out single. Textmate started the command palette thing and everyone seems to have adopted it. Dexter says the VS Code suggestions wouldn't be so bad if you only got them when you wanted them. The original hotkey for Command Palette and Visual Studio Code was unintuitive. I mean, there's a Command Palette in Sublime Text too. I think it's Control Shift P. Like I'm having to contort everything, which is kind of nice that it's got like this big list. I don't need it. I don't need a Command Palette. I've got a Command Line that has commands on it that are agnostic to whatever ID I'm using. Okay. So let's look at the mic file for IMX and see if there's a flash command already in here. There's a print, but not a flash. And let's just pull up the equivalent in tiny USB and just crib it. Tiny USB hardware board support IMX family. Oh, you know, I think it does need to know is it in family? How can we force with a USB 2.0 connection without USB hubs? Not exactly sure what you mean. Arduino IDE. Right, we're starting the editor wars in the Discord. Arduino IDE is one reason I was very like we're going to make CircuitPython agnostic to IDE, which we've done a good job, but the Mew kind of has filled that role otherwise. So you can use Mew if you want, but you don't have to. I totally ran across this stuff before. Where was it? Is it in examples? Because it was actually the two example. Ah, yeah, here's flash jlink flash stlink flash pyocd options. Copy that and then I have too many files open. I'm just going to call it flash. It is specific to just the other day I needed to use a hub to force the USB speed. We don't need an editor war. Okay, so we're going to want to flash the firmware hex and then pyocd target in tiny USB, which I don't have open. Oh, here it is. Pyocd target. Is that what it is? So here we can see the appropriate numbers. So I'm just going to translate this. I could map it. Maybe I should map it because we have our own notion of if equals chip. So let's just start with the one that we've got. You know, I did something very similar. Something very similar for the USB host definition here. So we can do that. And now if we go back here and do or make flash pyocd know my virtual environment, what is going on in the discord here? Everybody got going. Editor wars are silly. I agree. But a bunch of folks are reminiscing about pre Linux days. I don't have any pre Linux days. I think there's something to be said for learning about computers when they're that simple. I think there's a there's definitely a world where we should have we should we should have simpler computing devices. I mean, that's basically what CircuitPython is trying to be right. So this is cool. Pyocd is like, oh, how do you want to do it? Do you want to do it with the evk or with the jlink? So I could unplug my jlink and then it wouldn't have to prompt me to be so young. You think I'm young. There's a lot younger people than me, which I'm learning more and more. That is exactly why Raspberry Pi was built. I know I'm wondering once I get USB host going, how I'm going to be able to stop myself from adding USB host to the Raspberry Pi port and learning all about PCI. I'll probably end up doing it. Let's be real. Be cool. Be cool to have the pi 400 as a CircuitPython only device. I think that'd be really neat. I was thinking it'd be cool. You know how when the terminal shows up, you get the blinker and then the empty column. One, I was thinking maybe we should reverse that and have it be an empty row, but then I was thinking we could have like a keyboard icon that ends up next to it. Hemslav says, am I constitutionally able to run for president? I am as of this year, like, yeah, I'm like 35 and a half. Why is it asking me again? I should unplug my, I don't know why it did in the race. Okay, let me just unplug the jlink because I'm not using it. Pyocd, so pyocd can also be a GDB server, which is neat too. I started campaigning on my 35th birthday, but yeah, I'm definitely not that young. Here's a lot younger, younger folks even in the industry now. Okay, so that went. Let me plug in another USB thing and see if we get CircuitPyDrive. So this should allow us to import the hub, but not perfect. So it just popped up. We've got code.py and let's reload to the different one. Hello world, how are you? We can connect to it via tio by id usb nxp. So one thing I had to do are the younger people working on whippersnapper. Yeah, Brent is younger than me. The chronological age-wise are emotional. You know you're young when you count your age in house. Yeah, you know you're really young when you count your age in days thinking about babies. Okay, great. So this is working. If we do this, we should be able to do import USB host and then do p equals USB host port. I'll say it takes two positional arguments import board. What does that board have in it? Oh, lots of stuff, but it doesn't look like it actually has the USB lines, which would be neat. Print statement fail. So yeah, I think what I want to do is I want to add some USB things here. So one thing that maybe you can't see, I don't know if my cables are long enough. But this one is the device is plugged into this one closer to the ethernet. But my the way that my otg adapter plugs in, it actually needs to go in that spot because it's a right angle. So one thing I'm going to have to do is I'm going to need to switch which USB yeah there's ethernet on here. These chips are awesome. They have tons of stuff on them. The imx 1060s. Have we shown this? I had this chart up in my other browser. Let me find it. I have probably in my many windows that I have open still. Oh, that's not it. So here's here's a I think I've shown this at some point on the stream, but this is an overview of this imxrt product line. And they're pretty wild. So look at this the 1170 is an m7 clocked at one gigahertz. Like that's ridiculous. And I don't actually have one of these. I don't have either of these. So I need to maybe I should order one. It'd be cool to be cool to support that memory wise two megabytes SRAM one megabyte SRAM graphics acceleration 2d GPU for i2 s for audio spd if d might d make which I don't know what that is two usb's with five two gigabit ethernets 100 megabit and three can so that's yeah these 1100 series which we haven't we don't have circuit python running on them yet they're ridiculous but then you can see the 1064 which is basically a 1060 the 1064 and 1060 are the same except they have this one or four megabytes flash on board and this is what i'm running on this dev board so it's a megabyte of SRAM it's got a p by p which I think is like a 2d dma this board is the the imx 1060 evk which is an older there's a new rev of this board but it's the evk from nxp the 1060 is also the chips that's on the tin c4 which is the the cheaper option but it doesn't break out swd which is kind of silly yeah and tamie says I feel like the boundary between microcontroller and computer with gpio lines is becoming blurrier and blurrier yeah and if you see that they're they're actually they call it a crossover so like it it is definitely geared towards that and then if you look at st what st has is an a series microcontroller that's trying to work the other way down which is pretty neat it's I think these crossovers were pretty wild I wish they were available but that's also what got me interested in actually bridging the gap into good bridging the gap into the cortex a level stuff as well for like the raspberry pi what do you think of jailbreaking it's your device do what you want that's what I think greg points out the tin c4 one has a header for the second usb port uh yeah and in fact I linked um at makers to that as well so if you look at tin c4 one oh wow 4.1 usb my my hands don't know where they are on the keyboard usb hosts you can buy this host cable and this is this is where it has it the best um I have the evk know the evk b but I would I don't know why the b is better but if I were to buy it again that's what I would do I just a lot of these imxrt boards I was really excited about the chip family so I bought them kind of when they came out tin c is great if you're not going to develop because it's cheaper but if you're going to develop these dev kits are a better option until we come out with imx boards um yeah so so tin c will sell for sell you for three dollars this host cable which is similar to the host cable that I've got from adafruit so like the one that I have from adafruit that I have hooked up to this rp2040 um has like the lines broken out they're not all together but they would work in the same way um so when I when I get this working on the dev board I'll then get it working on the tin c41 and you can see here this is a I don't know that might that might be a three six but um either way the tin c41 has it as well of this five pin header that you can plug into for host and these are cases where it's like it's built in so I we could like initialize the host port up front um which would make the keyboard stuff even cooler um so one thing I was thinking about with the api and maybe folks have an opinion but I was thinking about the way that the host port initialization should work you know how in displays if you initialize a display we keep it around after you're done with it until you call this release displays thing do you think we should do the same thing for usb host ports like should we not reset those for kind of the same reason and that like we're going to use the keyboard after you're done so you could like do stuff with it and then um yeah you basically wouldn't lose that keyboard access until later so hams lab has a question I have a question about the new esp 32 board since you had to use a new usb serial chip why didn't you use an ftdi to get a gdb interface over usb the expressive rover kit uses it and it's great um that's a question for a little more not for me I didn't design it generally I think ftdi's are complex and costly from what I've looked at but I don't know you'd have to ask her I didn't do the design design line says I have a teensy 4o board so the 4o board has pads on the back for usb host but it does not have um it doesn't have this five pin header so you could still do it you just have to solder directly to it um they are broken out on pads the usb pins are yeah sunday's a great time to ask her about design choices like that I'm sure she'd be that or or wednesday's for ask an engineer she didn't ask me about it so I don't have any background um okay so what are these pins let's figure out let's see if we can't find the 1060 evk I think the problem is a lot of these docs are for the new one like if you look here these usb plugs the microbe plugs are like spaced way farther apart than mine are so I don't know what changed but this is a picture of the b version um tile just made some noise yeah you can see that it's like there's the evk evk version that's what I've got but then they also have a b version and I don't know like they totally relate it all out you can see that like the j tags in a different spot like they redid it all and I'm not sure why maybe I should pick one up it's five volt ground d plus d minus it's not tx rx the the signals are differential regarding your keypost initialized on reboot would the endpoints and pipes need to be re-initialized on reboot reboot or would you remain the state too so if user code used it they you would need to release it and then get it back I think unless I unless we like looked it up and gave you the same object back for the same pins I guess we could probably do have done with displays as well but generally I feel like you want to start from the same state so it's probably better that you just do like a release or a d in it and then re-initialize it all because you can reset a usb device so so we could actually have the the device reset too I guess it's the host so yeah the host would reset everything I think I don't know we'll play around with it design resources design files evkb design files and then the evk design files I wish somewhere they would tell us why they redesigned it it sucks you have to have an account but it's a free account there is no consistency in usb labels and motherboard manuals it's definitely not txrx that's not what the pins are and if they're if that's what they say in those manuals that's just it's wrong so what I'm trying to figure out is the pinout because I want to add to board like the usb host d minus and d plus gain power onto test points button user led mcu pinout weird it's like middle mouse button there's the gytag pins usb host power maybe you can actually enable it and disable it here's usb otg-1 power oc i don't know what oc stands for ah here we go they're they're like oh that's interesting it's dn by their book but there's a separate set of pins names here that tdi chip is about two dollars more or that board's a candidate for pretty pins uh yeah that's a lot it's a lot okay so we're talking usb otg-2 let's see here we're doing boards imxrt1010 pins and I guess the name that we're gonna want to use is actually usb we might actually have to add like to find these as well I'm gonna call I'm gonna make a decision d plus 1 usb d minus 1 is that how we do it yeah you can see here that we have like the numbers at the end have a good one pier yes next week will be the last week I'm streaming and then foamy guy is taking over after me I'll probably stream again once I am a dad and have my feet under me but I I don't know when that'll be but Phil mentioned it like that I will with somebody I told them I was like if you want me to get more done then I can not go back to streaming we'll see join the deep divers role on discord if you're not in it and that's who I will we can notify oh webbsk did I miss you in the chat again no I didn't okay they usually sleep more at the start we shall see my sister had pretty easy easy kids thanks again aqua droid good luck to you too okay so these pin objects here are actually from the further out in the port so let's see what pins we've got they might actually be it's kind of silly because these I think this is the only thing these pins can be used for but each yeah so each series has pins so the 1060 is what we want get lots of hugs because they're only small for so little time and good luck thank you I was going to go with dm because that's what I've seen more often it's weird to me that it's dn I usually see it as plus and minus not positive and negative which I assumed is what the n is okay and 62 pins gpio emc so I wonder if we just want so here I'll use data sheet names pin object pin and I don't even think it has gpio in it maybe we should pull up the data data sheet as well to see what the data sheet calls it and s3 data sheet pretty sure I haven't downloaded mxrt 1060 consumer contextual overview maybe this doesn't have a pin out the imx trips have both kind of like data data sheets which is what this is and then they also have reference manuals so this is only 117 pages but it tells you like the the the naming or the the skewed numbering whereas if I do this processor manual somebody made a comment about a thousand page thing this is three and a half thousand pages it is a reference manual so for the reference manual we can see muxing options of port kind of curious to see if oh oh oh so the this is backwards though what I was thinking so the port on the left is the internal signal name and the pad is where it comes out so the right the pad name is the thing that we've been copying so if we go down here oh what come on there we go so we're looking for Piano says that's good light reading right before bed yeah I just I'm pretty sure that's what Lady Aida does she tucks in with a good data sheet before she gets to sleep or even a reference manual okay so so the board name is going to match our standard name but the internal MCU pin name is going to match the data sheet um Greg says evkb adds an m2 connector for radios and other headers for audio and other expansion thank you Greg okay so here we have uh otg one pins but these are not the plus and minus so we're looking for that looks like tests usb 5 I thought tst I would be like test input test output I wonder if we need to find external signals AT makers caught up I guess my question on pi usb is can we write a driver for the intelligent keys that sends the easy usb firmware at startup and then reads and writes like the driver gd sports wrote for Arduino on the M zero seems like that would be a yes but I don't know if there's a driver base class or the like um you should be able to do that yes I'm assuming I'm assuming you should be able to do that um in fact if you wanted to try it um i.e. how do we add a custom device well you just write you would just write python code that just reads and writes the to the device so you just end up reading a bunch from the had endpoint yep rpi using circuit python you might have to do the kernel detach thing if the kernel tries to take it over or yeah rpi using c python that's right I do have one on order I told you that but I didn't tell what I didn't finish my thought to the whole chat though so bill did a live stream over the weekend that is covering kind of the use case for doing usb host so bill has made this board where one side is a usb host and there's a url link between another trinket running circuit python that acts as a device and there's it does so there's this particular device that the intel keys is this pretty big basically touch screen that is like super old and so it has an old protocol that's like no longer necessarily supported by os's and so what bill is trying to do is use usb host to talk to a custom hid device and then translate the those commands into standard commands to to an os yeah yeah so I ordered one of these you can get them off ebay so it's it should become a next week sometime I think um yeah it should be should be double I got distracted from the data sheet yeah and there's a great teardown with bill and scan line as well I watched that that was really helpful if you want to see what's inside so these are just muxing options I'm wondering if if there is like it's not muxed where is the maybe it's in the package diagrams like usually it will actually tell you what pin is where package information and contact assignments so these are the names of the actual pins and these are the names that we've copied for our names in our api so so it does just use the usb and you can see that there's no like alternate functions or anything or default default state so we're just going to want um otg to dndp it uses jk flip flops to read the membrane I don't even know what that is I kind of skipped through I didn't watch the whole thing okay so that's what we're going to name them back to what I was actually trying to do so now we know that we don't need the GPIO suffix and let's just add I'm just going to do the four usb ones otg dndp what would happen if you connected a hub connected a hub to circuit python uh doing usb host you would just be able to find multiple devices some of what your typing is covered sorry about that I'm just writing the uh the full name full name there and then what we need to hear is so these are uh declarations of a variable and then in here we actually need to declare them and I'm not sure exactly what we want because they can only do one thing so they really just need to be objects with no data but I don't know what this pin stuff does like it doesn't have any GPIO so you wouldn't you shouldn't be able to yeah you shouldn't be able to pass these to digital IO because that won't work which is interesting so let's do one before we copy it anywhere else so let's find this pin macro which is probably in here so this is what a pin object looks like on the imx basically one bit memories yep greg says the usb pins are dedicated and the location is in the datasheet yep I think we found that all right well we've got four more minutes I'm not probably not going to finish this I'm going to make this pgpio basically null it all out hey johnny don't worry so we're going to do null zero we could also do it like the usb fi address as a way to validate it mux index oh dear that's not going to work okay here's what we can do instead so we can copy this and basically so the only thing we actually care about the rest can be zeros is um had reset so just to set up my weekend do you think if I get the intel keys driver ported to see python and pi usb I'll be on a useful path I do if that's how you want to spend your weekend um I do you think that should be useful yes that would mean that I'm committed to it but I'm pretty committed to it already because it makes so much sense it makes I mean bill it also gives you a ton of flexibility if you ever do want to use your at raspberry pies for it like I don't know what is involved for the driver the usb device side on linux like I don't I don't know what that is it can do it um so now we now we can add board objects to this and I'm actually going to make otg one be the host so that's going to be something different as well so going back to our board definition we're going to do oh I wasn't gonna I don't need both I don't need it to be changeable fast forwarder over the editor wars dp one is that what it was called it's easier to do this stuff when I can have bigger windows and stuff oh you know what it is it's otg one dp otg and then I think what we need to do is you know maybe we should like here's the init hardware oh this is weird what is that tg2 we're gonna have more work here that's okay it depends we're not defined in device mode why add them for host mode good question the reason that I'm having usb hosts dot port take pins in is because I'm anticipating host support on the rp2040 as well which is using pio which means that you could actually do multiple and you can do them on basically any pin any pair of pins um so tac who does tiny usb is has been tasked to do the pio host stuff in tiny usb so um tiny usb should support usb host at some point on rp2040 which is really what we're interested in because we can get rp2040s so that's why i'm wanting to have the api take pins in and I could I could allow like on the imx to just give it nuns but I think it's okay to be explicit even if there's only one option because perhaps there are there are cases where that's not the case I guess like I mean the rp2040 is kind of weird because it's all bit banged but but yeah that's why I that's why I'm going through this process of creating pins but you're right it is actually causing more trouble because now I've got to make digitalio through an error if you tried to like all of all of the other things that take pins need to make sure they're not given these pins they can't use um which I guess most of them will figure that out like iSquad C and UART and spy already do their like lookups but digitalio probably needs to check for that null now like because it takes the pin has a pointer to its GPIO instance so digital i digital in out should say oh by the way this doesn't do GPIO which is something that it's not completely unheard of all right any other um any other questions otherwise I'm gonna wrap it up because we're at our two-hour mark I see one person typing but two people typing we'll see all right I'll sit tight just a little bit longer oh no it's just a thank you all right uh let's wrap it up if there are more questions in the discord I can answer them after the chat is done or after the stream is done so this has been another uh deep dive with Scott uh there will be more deep dives in the future next week will be with me but then foamy guy will be taking over uh two weeks from now um because I will be a leave at some point and I didn't want to run up into leave and be like oh yeah I'm gonna do a dive oh wait no the baby's here I didn't want to have to deal with that um so yeah my name is Scott if you just tuned in uh thank you to Patrick and David for taking the time codes that are in the description and available in the github repo github.com slash Adafruit slash deep dive dash notes thank you to them for that um trying to find my notes um what else um if you want to support me you can do that by supporting Adafruit that's Adafruit.com there's lots of good stuff there that um helps me out and helps Adafruit out and they pay me to do these streams and work on Circuit Python so check that out um that's Adafruit.com if you want to chat with me and a bunch of other awesome people and get some help from awesome people the Adafruit Discord server is awesome I said awesome a lot but it is uh you can go to the URL adafru.it slash Discord um for that uh yeah next week I'll be here at Friday at 2 p.m. I think we're going to try to have FOMI guy be a guest on there so FOMI and I will be able to chat and ask questions and and just kind of do a handoff which I'm excited about not really chatted with FOMI guy so I'm looking forward to it um so that'll be next week at two that'll be the last stream that I do but then FOMI guy will be taking the slot over on Adafruit we've got FOMI guy set up to stream on Adafruit now um so the Friday streams I think will be on Adafruit although I think he'll be streaming on his own channel on Saturday still um so yeah that's the plan um thanks again for notes and uh you can also support him on GitHub I do uh yeah so you can support FOMI guy on GitHub so GitHub sponsors is great maybe you're talking about me you can support me on GitHub sponsors as well if you want and and fund my fund my digikey dev board habit uh which is one way I justified getting this new board maybe I'll try to show that off next week although I probably won't do anything um all right I'll put the cap and get out of here I'll see you all on the discord and I'll see you uh next week for a deep dive on Friday at two pacific let's cut a cat cave he's no longer stretched out because the window's open have a great weekend everyone