How does USB device discovery work?

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 มิ.ย. 2024
  • What happens when you first plug a USB device in? There's a whole bunch of negotiation where the computer discovers what a USB device is capable of. In this video I capture the conversation and walk through what's going on.
    Support these videos on Patreon: / beneater or eater.net/support for other ways to support.
    ------------------
    Social media:
    Website: www.eater.net
    Patreon: / beneater
    Reddit: / beneater
    Special thanks to these supporters for making this video possible:
    Aaron Todd, Aleksey Smolenchuk, Alexander Wendland, Andrew C. Young, Anson VanDoren, Anthanasius, anula, Armin Brauns, Ben Cochran, Ben Kamens, Ben Williams, Benny Olsson, Bill Cooksey, Binh Tran, Bouke Groenescheij, Bradley Pirtle, Bradley Stach, Brent Reusing, Brian T Hoover, Bryan Brickman, Burt Humburg, Carlos Ambrozak, Chris, Christian Carter, Christopher Blackmon, Dale Andrew Darling, Daniel Jeppsson, Daniel Tang, dans, Dave Burley, Dave Walter, David Brown, David Clark, David Cox, David House, David Sastre Medina, David Turner, David Worsham, Dean Bevan, Dean Winger, Dilip Gowda, Dissy, dko, Dmitry Guyvoronsky, Dušan Dželebdžić, Dustin Yelland, Dzevad Trumic, Eric Dynowski, Erik Broeders, Eugene Bulkin, Eveli László, George Miroshnykov, Harry McDow, hotwire33, Ingo Eble, Ivan Sorokin, James Capuder, james schaefer, Jared Dziedzic, Jason DeStefano, Jason Specland, JavaXP, Jaxon Ketterman, Jay Binks, Jayne Gabriele, Jeremy Cole, Jesse Miller, Jim Kelly, Jim Knowler, Jim Van Meggelen, Joe Beda, Joe OConnor, Joe Pregracke, Joel Miller, John Fenwick, John Meade, Jon Dugan, Joseph Portaro, Joshua King, Jurģis Brigmanis, Kai Wells, Kefen, Kenneth Christensen, Kent Collins, Kitick, Koreo, Lambda GPU Workstations, Larry, Lucky Resistor, Lukasz Pacholik, Marcos Fujisawa, Marcus Classon, Mark Day, Marko Clemente, Martin Noble, Martin Roth, Mats Fredriksson, Matt Krueger, Matthäus Pawelczyk, Matthew Duphily, melvin2001, Michael Tedder, Michael Timbrook, Michael Weitman, Miguel Ríos, mikebad, Miles Macchiaroli, Muqeet Mujahid, My Yiddishe Mama, Nicholas Counts, Nicholas Moresco, Not Yet Wise, Örn Arnarson, Paul Pluzhnikov, Paul Randal, Pete Dietl, Phil Dennis, Philip Hofstetter, Phillip Glau, PixelSergey, ProgrammerDor, Randal Masutani, Randy True, raoulvp, Renaldas Zioma, Ric King, Rick Hennigan, Rob Bruno, Robert Comyn, Robert Diaz, Robey Pointer, Roland Bobek, §çīŤøşHï ŇåĶąýŐbŕÔ, Scott Holmes, Sergey Kruk, Shelton, SonOfSofaman, Stefan Nesinger, Stefanus Du Toit, Stephen, Stephen Kovalcik, Stephen Riley, Stephen Smithstone, Steve Jones, Steven Zilberberg, Tayler Porter, TheWebMachine, Thomas Bruggink, Thomas Eriksen, Tii, Tim Walkowski, Tom, Tom Yedwab, Tommaso Palmieri, Tyler Latham, Vincent Bernat, Vladimir Solomatin, Walter Montalvo, Warren Miller, Wim Coekaerts, xisente, Yee Lam Wan

ความคิดเห็น • 627

  • @derekkonigsberg2047
    @derekkonigsberg2047 2 ปีที่แล้ว +615

    I'm just glad to see someone finally tackling USB. For too long, everyone's basically assumed that the hobbyist tinkerer is permanently limited to only understanding VGA and PS/2, even if no one else actually uses either anymore.

    • @trissylegs
      @trissylegs 2 ปีที่แล้ว +25

      The osdev wiki opens saying it's extremely complicated. But it doesn't look too bad if you just handle the easy paths. (Or maybe it's all xhci making it hard)

    • @LittleRainGames
      @LittleRainGames 2 ปีที่แล้ว +28

      Its definitely possible for any hobbyist, just depends if they want to spend a month reading documents and datasheets.
      Or you can simply use the Avr LUFA libraries, or the Atmel ones for their arm mcus, then all you really need to learn is how to make your own report descriptors(for HID), which you can easily just change the examples.
      For non HID, you can pretty easily write vendor drivers with libusb, start with a simple driver that turns an LED on and off. Or if you feel brave, can get the WDK(windows driver kit) for VS community, and write a driver without libusb, which is next on my list of things to learn.

    • @absalomdraconis
      @absalomdraconis 2 ปีที่แล้ว +1

      Microchip has also had USB code freely available for their USB capable PIC chips since before they bought Atmel.

    • @Stoney3K
      @Stoney3K 2 ปีที่แล้ว +19

      @@trissylegs If I look at this video, I wouldn't say it's "complicated". It may be a complex protocol, but it's all built up logically as a layered stack, making it fairly straight-forward if you understand the principles of each individual layer. Which is understandable given that it's supposed to be implemented by computers, not humans, and computers like stuff that is straight-forward.

    • @Stoney3K
      @Stoney3K 2 ปีที่แล้ว +18

      @@LittleRainGames The biggest hurdle for hobbyists trying to implement USB, is getting a vendor and device descriptor. You are strictly not allowed to release devices which use "for development" descriptors or re-use other people's vendor/device ID's, and the only way to get a registered descriptor set is by paying a lot of cash to the USB consortium.

  • @GilgaFrank
    @GilgaFrank 2 ปีที่แล้ว +470

    And that's what Windows means when it says "Failed to get device descriptior".
    Ben, you are to be congratulated on your entire series of videos. The clarity with which you explain some extremely complex concepts in computing, networking and communication protocols is remarkable. To make a complex process like this understandable in just over half an hour is some considerable achievement.

    • @gordug
      @gordug 2 ปีที่แล้ว +3

      We typically tell people to reseat the device, try it in another pc and replace it if it still fails

    • @YoutubeBorkedMyOldHandle_why
      @YoutubeBorkedMyOldHandle_why 2 ปีที่แล้ว +5

      Ben is to be congratulated for sure, for the mind boggling detail which he's managed to get his head around.
      As for, "To make a complex process like this understandable ..." What? Seriously? ... you understood this? Honestly, I fell asleep after 5 minutes. When I awoke, pretty much the only thing I 'understood' was that this is WAY more 'complex' than it needs to be. It would seem that these specs were created, not by engineers, but by bureaucrats.
      And now Ben is teasing us with the 'n-key rollover' keyboard, which is even more complicated.

    • @GilgaFrank
      @GilgaFrank 2 ปีที่แล้ว +5

      @@TH-camBorkedMyOldHandle_why I understood it only because I've dabbled with the Arduino USB host library to get at the USB endpoints. The USB negotiation process is a little daunting but there's a good reason for all the to-ing and fro-ing between host and device. There's actually a lot more to it like the device declaring its power requirements along with the descriptor, vendor ID, product ID but that's as deep as I looked into it.

    • @red03golf
      @red03golf 2 ปีที่แล้ว

      @@TH-camBorkedMyOldHandle_why If you ever take a university degree you'll learn in Psychology 101 your statement, here above, is a clear declaration you realise don't understand complex concepts, even if and when they're described in simple, layman's terms. Meaning, you know you have a simple mind, you'll forever be stuck in a menial job, and you'll never achieve greatness. You'll forever be an internet troll because you're tunnel-vision-fixed on picking apart perfectly logical information simply because you don't have the requisite foundational background knowledge to appreciate what is being simply explained from a knowledgeable source. Enjoy flipping burgers, it's probably the only thing at which you'll ever excel.

    • @renakunisaki
      @renakunisaki 2 ปีที่แล้ว +4

      That's technically what it means, but unless you're programming the device, 9 times out of 10 it means the cable is broken.

  • @Mammux
    @Mammux 2 ปีที่แล้ว +59

    It is comforting that even Ben Eater first tries to insert the usb disk upside down.

    • @drawapretzel6003
      @drawapretzel6003 2 ปีที่แล้ว +13

      Until USB C solved the problem, all USB cables are in a superposition and require being flipped over three times to get it in right. The fact he gets it in two shows a level of skill even physicists cannot demonstrate regularly.
      USB C is still in superposition, but it negotiates which pins are tx and rx internally, so we dont actually perceive them arguing on a quantum scale whether its right way around or not :P

    • @MrBluemoon74
      @MrBluemoon74 2 ปีที่แล้ว

      thanks to another techchannel i now know the correct way for usb plugs is suppose to be: with the usb logo on top.
      To bad the thumbdrive has no usb logo...

    • @grantofat6438
      @grantofat6438 2 ปีที่แล้ว +1

      @@MrBluemoon74 The correct way for a usb plug is always opposite of the first way you try to put it in. And I do mean always.
      Also many usb ports are mounted sideways, so there is no "on top".

  • @soumilparanjpay2731
    @soumilparanjpay2731 2 ปีที่แล้ว +322

    Whenever I watch Ben's videos I appreciate just how complicated modern operating systems and hardware is. We're all sitting on the shoulders of giants.

    • @evanlohning
      @evanlohning 2 ปีที่แล้ว +23

      and unfortunately most of us take it for granted. to some of us, computers might as well be magic.

    • @MrYerak5
      @MrYerak5 2 ปีที่แล้ว +2

      Just imagine 1000 years from now or one bilion

    • @retroretiree2086
      @retroretiree2086 2 ปีที่แล้ว +11

      @@evanlohning "Sufficiently advanced technology is indistinguishable from magic" - Arthur C. Clarke

    • @ytytiuiu2590
      @ytytiuiu2590 2 ปีที่แล้ว +3

      @@evanlohning Thanks to Docker Electron and VB before majority of programmers don't even know how computers works, this is computer illiteracy.

    • @murk959
      @murk959 2 ปีที่แล้ว

      And all the credit goes to software developers who fix bugs 🙄
      No offense to any software developers, obviously.

  • @MatthijsvanDuin
    @MatthijsvanDuin 2 ปีที่แล้ว +67

    23:26 There's a good reason for requiring explicit selection of the configuration even if there's only one: an unconfigured non-suspended* device is not allowed to draw more than 100 mA. So, if a bus-powered device requires more than 100 mA to function normally (this is called a "high-power bus-powered function"), it will have to keep part of its functionality switched off to limit its power consumption below 100 mA until the host has selected the configuration which declares this higher power requirement in its configuration descriptor.
    * A device which is suspended may draw only 0.5 mA, unless it is in a high-power configuration and remote wakeup is enabled in which case it may draw 2.5 mA.

  • @FedePantalonesGordos
    @FedePantalonesGordos 2 ปีที่แล้ว +458

    If this leads to usb compatibility on the 6502, I'll be stoked!

    • @theterribleanimator1793
      @theterribleanimator1793 2 ปีที่แล้ว +65

      thats gonna take a lot of clock cycles.

    • @PterippiGaming
      @PterippiGaming 2 ปีที่แล้ว +33

      Hm. With a bit of external logic like shift latches I see no problem to implement a low speed USB on 6502. I guess the most challenging part is clock syncing. But if you are a USB host then I understand that it is you who defines the clock so that is no longer an issue.

    • @akhilpathak
      @akhilpathak 2 ปีที่แล้ว +6

      That's a lot of cycles

    • @Some_Beach
      @Some_Beach 2 ปีที่แล้ว +1

      Maybe an external module

    • @paulstelian97
      @paulstelian97 2 ปีที่แล้ว +8

      Is the 6502 worse than an AVR? I've seen some serious bitbanging USB done on the latter...

  • @jackgerberuae
    @jackgerberuae 2 ปีที่แล้ว +90

    Imagine the clever guys that designed and developed the Scope with all that intelligence and options.

    • @kaukospots
      @kaukospots 2 ปีที่แล้ว +17

      that's why they cost as much as they do lol

    • @custardtart1312
      @custardtart1312 2 ปีที่แล้ว

      @@kaukospots lol. How we laughed. People who say lol are brain dead.

    • @PenguinCinema
      @PenguinCinema 2 ปีที่แล้ว +6

      @@custardtart1312 nice life

    • @davidl6354
      @davidl6354 2 ปีที่แล้ว

      @@custardtart1312 lol

  • @ThomasSIversen
    @ThomasSIversen 2 ปีที่แล้ว +95

    What I find really interesting seeing this is how old and yet advanced the protocol is. I remember in 1997 when I got my P55T2P4 board with both PCI and USB and now 24 years later I realize how utterly complex the shift from PS2 to USB was on a protocol level and how many chip designers and firmware engineers that have had to deal with the protocol... Very nice video Ben (as always)

    • @chris_0725
      @chris_0725 2 ปีที่แล้ว +5

      @@supernovahm1178 see the vid going through the usb protocol

    • @Mr_ToR
      @Mr_ToR 2 ปีที่แล้ว +17

      @@supernovahm1178 You're either trollin or have no idea about what you're talking. How can u think its simple? Using USB for attaching a device to your project is extemely complicated. If it's I²C or UART or 1-Wire or SPI, it's quite simple but with USB you'll have difficuly even attaching a simple numpad. Please enlighten us as compared to what other method do you find USB to be simple?

    • @ducksonplays4190
      @ducksonplays4190 2 ปีที่แล้ว +2

      @@supernovahm1178 Ok, if it's simple explain what ben eater did in this video.

    • @Mr_ToR
      @Mr_ToR 2 ปีที่แล้ว +9

      @@supernovahm1178 If you can easily and cheaply use USB instead of when you can use any of the other serial protocals i've mentioned, you're a lot smarter than any other person I've known in the last 20 years. I thought my question had the answer in it already but apparently you know better. You should make a video explaing why USB is a simpler choice than any of the other serial protocals I've mentioned. The question is not why it is complex, the question is why would anyone use USB when there are many simpler and cheaper serial protocols. If you have no experience with any of the other serial protocols, which obviously you do not, then you don't know what you're talking about. We are obviously not talking about attaching your usb keyboard to your windows machine :-)

    • @DFX2KX
      @DFX2KX 2 ปีที่แล้ว +12

      @@supernovahm1178 USB is not even remotely simple when compared with PS/2 or RS232. It was quite complex for it's time. Just because you can #include a library doesn't make it simple. it means all the hard work is already done for you.

  • @supersonictumbleweed
    @supersonictumbleweed 2 ปีที่แล้ว +90

    Now I want a keyboard with all those possible LEDs put on it - the usual three and Compose Key, Kana, etc.

    • @b2gills
      @b2gills 2 ปีที่แล้ว +10

      I don't know, I'd much prefer a Compose LED to a Scroll Lock LED.
      The only thing I use my Scroll Lock button for is sending commands to my KVM switch

    • @OrangeC7
      @OrangeC7 2 ปีที่แล้ว +8

      The Kana light is probably for Japanese keyboards, specifically ones which support typing directly in Japanese

    • @mihiguy
      @mihiguy 2 ปีที่แล้ว +9

      I doubt you can find all of them on one keyboard. The off-hook, ringing and mute LEDs are often found on the small "keyboards" inside the cable of an USB headset (that have volume up, volume down, mute and accept call buttons).

    • @supersonictumbleweed
      @supersonictumbleweed 2 ปีที่แล้ว +10

      It would look like nuclear plant control room wall lol

    • @mc-zu6bo
      @mc-zu6bo 2 ปีที่แล้ว +1

      @@OrangeC7 I'm not so sure. Japanese qwerty keyboards include a special key to disable turning input into kana. I personally don't know but that makes more sense to me.

  • @williamrutherford553
    @williamrutherford553 2 ปีที่แล้ว +93

    While some of this might seem ridiculous and jumping through hoops, I can only assume it's to ensure compatibility. Why do you ask for 2 bytes just to get the length, then ask the same command again with a different length? Only because devices might have SO much or so little info that you can't keep it at a certain size. When it only has one configuration mode why does it still set the mode the device should use? Because everything is set up so it's crystal clear what mode it SHOULD use. When you think about just how long USB has been around, and how many devices use it, you can imagine just how many edge cases they've had to deal with.
    What if a device has multiple configuration modes, but some aren't compatible with the host? Well, then the host wants to make sure it's using the compatible mode, in case the device assumed otherwise. What if two devices are using slightly different versions of USB? You always want them to be backwards compatible, so anything you add in the future is put ON TOP of the current spec. Therefore, you get a lot of stuff that seems needlessly complicated and long-winded, when the reason they're doing it that way is because early USB devices STILL function on modern systems, and a modern USB system should have SOME functionality on an old system. The fact that works is honestly amazing, and it's because they're so specific in their communication, even if it means repeating what should seem obvious.

    • @defenestrated23
      @defenestrated23 2 ปีที่แล้ว +4

      That's rather zany/clever that the same command (06 02 03 GET_DESCRIPTOR String N) works. Since all of the Descriptor structs always starts with 1 byte bLength and 1 byte bDescriptorType, GET_DESCRIPTOR len=2 always gives you the "head" of the structure. So it seems the standard way to get variable length structs is to get the head first, get the size, then get the N bytes of the struct.
      It's weird though that wLength is a uint16 but descriptors seem to have a max size of 255 (less 2 for the head), with no obvious way to get longer ones (the length isn't a bit-packed varint). GET/SET DESCRIPTOR is the only Setup request with variable length (all the rest are 0, 1, or 2), so nothing actually ever uses the wLength high byte. Maybe they wanted to leave the door open to bigger requests with entirely new bRequest types?

    • @jaysonl
      @jaysonl 2 ปีที่แล้ว +1

      Yeah, a lot of it is to ensure compatibility. There's certain minimum-capability modes that are defined that are designed so that things like the system BIOS can work with USB keyboards and mice. I forget the specific term they use (or, more likely, repressed it), but it's all there in the spec.

    • @Stoney3K
      @Stoney3K 2 ปีที่แล้ว

      @@jaysonl You could see that in the device descriptor as the "Boot feature" of the keyboard.

    • @jaysonl
      @jaysonl 2 ปีที่แล้ว

      @@Stoney3K That sounds about right. Now I just wish there was a "boot feature" for Bluetooth keyboards :)

    • @PetrGladkikh
      @PetrGladkikh 2 ปีที่แล้ว

      It is not only way to do that. An I am acually wonder why they did not have a way for device to just send a blob with all the description info encoded in something like ASN.1 or Protobuffers. That would simplify devices also. It would only need, maybe, some special case handling only for large descriptors (say, >5Kb).

  • @peterlinddk
    @peterlinddk 2 ปีที่แล้ว +455

    Showing the printout of the conversation:
    Ben: I won’t go through it in excruciating detail …
    Me: oh no, please, please do!!
    Ben continues to go through it in excruiciating detail
    Me (smiling and looking to the sky): Thank YOU!
    Excellent video, can hardly wait for the next part!

    • @enc4p
      @enc4p 2 ปีที่แล้ว +1

      Same

    • @dsconnectedn3uron324
      @dsconnectedn3uron324 2 ปีที่แล้ว +2

      the word "excrutiating".. i don't think it means what you think it means...

    • @ziggyinc
      @ziggyinc 2 ปีที่แล้ว

      I am so glad to know I am not alone in enjoying excruciating detail.

  • @rishi_d_mango
    @rishi_d_mango 2 ปีที่แล้ว +218

    This is both high level and low level at the same time...

    • @D4no00
      @D4no00 2 ปีที่แล้ว +16

      that's why it's called differential pairs :)

    • @RoamingAdhocrat
      @RoamingAdhocrat 2 ปีที่แล้ว +4

      Like Glasgow Central station.

    • @charleshwankong
      @charleshwankong 2 ปีที่แล้ว +3

      It's Ben's eye view

    • @drawapretzel6003
      @drawapretzel6003 2 ปีที่แล้ว +2

      Its explaining a high level concept in low level speak, but assumes you arent actually stupid, so ultimately its really high level explained to medium level.

    • @akaHarvesteR
      @akaHarvesteR 2 ปีที่แล้ว +2

      This is how the rubber meets the road in computing (or how the angry pixies meet the thinking sand)... It’s something I’ve wondered about for a really long time before I found Ben’s videos, and it’s completely fascinating to me.

  • @praetorprime
    @praetorprime 2 ปีที่แล้ว +56

    "HID Device is a Human Interface Device... Device" that second device is the attention to detail I love. Keep up the great work!

    • @Kopigan
      @Kopigan 2 ปีที่แล้ว +4

      21:24

  • @lifthras11r
    @lifthras11r 2 ปีที่แล้ว +134

    12:35 So we are using a USB flash drive to list the USB keyboard setup sequence. Meta.

    • @ikocheratcr
      @ikocheratcr 2 ปีที่แล้ว +8

      I can think of a meta-meta, where one uses a USB oscilloscope to analyze USB keyboard.
      And if you want the meta-meta-meta, run such oscilloscope on one PC, and via USB network transfer the captured file to analyzing PC ;)

    • @inceptsquad9516
      @inceptsquad9516 2 ปีที่แล้ว

      @@ikocheratcr ok what the fuck

    • @ButtKickington
      @ButtKickington 2 ปีที่แล้ว +4

      @@ikocheratcr for levels of meta not thought possible: use a USB rubber ducky to automate all this while it's being captured.

  • @erichobbs4042
    @erichobbs4042 2 ปีที่แล้ว +10

    I never realised that I wanted to know in excruciating detail what goes on when a USB keyboard is plugged into a port. But somehow this is truly captivating. Ben really has a gift for taking complex technical details and breaking them down into easy to understand bits, while at the same time not dumbing anything down to point where the explanation is totally useless.

  • @reminixiv888
    @reminixiv888 2 ปีที่แล้ว +24

    I recently gave up on a low-level USB client implementation because the USB spec was so complicated. This video is gold to me rn

  • @kepe__
    @kepe__ 2 ปีที่แล้ว +25

    You don't know how much this helped me with a project i'm making. Thank. You. So. Much.

  • @mikefochtman7164
    @mikefochtman7164 2 ปีที่แล้ว +4

    Whew!!! Brings back memories when I was helping develop specialized SCSI-2 devices. Lots of structures that hand-shake 'who are you?', 'What can you support?', 'What sort of speeds and data sizes do you support?' and more. And of course part of that is when the host 'learns' who you are, it goes off to find a suitable software driver that 'understands' all this.

  • @MatthijsvanDuin
    @MatthijsvanDuin 2 ปีที่แล้ว +30

    30:40 "This byte is reserved for OEM use. The BIOS should ignore this field if it is not used. Returning zeros in unused fields is recommended." - HID specification, Appendix B

    • @gargaj
      @gargaj 2 ปีที่แล้ว +1

      But if the device defines the report spec, could it just not send that byte?

    • @MatthijsvanDuin
      @MatthijsvanDuin 2 ปีที่แล้ว +4

      @@gargaj Normally the device defines the report spec, however since full HID support is fairly complex there are also two predefined "boot device" protocols (one for keyboards, one for mice) that a HID device may support specifically for very limited host implementations such as a BIOS (which is why the sentence I quoted mentions BIOS).
      Such HID devices identify themselves through their interface descriptor (subclass=1 (boot device) and protocol = 1 (keyboard) or 2 (mouse)) and are required to use the corresponding report format defined in Appendix B until the host uses SET_PROTOCOL to switch from "boot protocol" (use predefined report format) to "report protocol" (i.e. use the report format defined by the HID descriptor). The BIOS will simply recognize compatible devices based on interface descriptor and simply assume the predefined report format is used, they never invoke SET_PROTOCOL nor query or parse the HID descriptor.
      Cheap keyboards don't bother implementing two report formats and instead just use the boot keyboard report format as their only report format.

    • @MatthijsvanDuin
      @MatthijsvanDuin 2 ปีที่แล้ว +3

      @@gargaj Out of curiosity I checked whether UEFI (specifically tianocore edk2), bloated as it is, implements full HID... nope, boot protocol only.

  • @KangJangkrik
    @KangJangkrik 2 ปีที่แล้ว +16

    Ben Eater: **exists*
    a kid named "Ben": Oh no I'm in danger

  • @your_utube
    @your_utube 2 ปีที่แล้ว +16

    Ben's treatment of the subject matter makes a person feel like tackling this new subject with confidence. Thanks Ben!

  • @jeromethiel4323
    @jeromethiel4323 2 ปีที่แล้ว +61

    This was absolutely fascinating. I was never a fan of USB when it came out, but man, this protocol/standard has legs! The people who designed it were thinking waaaaay ahead of what was in use at the time. Which is sadly lacking a lot of time in standards. And probably goes a long way to explaining why things like firewire and the like never really caught on. Flexibility is key in a "universal" interface.
    Looking forward to more breakdowns of this.

    • @gdclemo
      @gdclemo 2 ปีที่แล้ว +2

      If they were thinking far enough ahead then maybe we wouldn't have umpteen different types of USB connector today. Firewire was more flexible in some ways, like it didn't assume that on one end of the wire was the host and on the other end was the device, a mistake that USB has had to backtrack on since.

    • @drawapretzel6003
      @drawapretzel6003 2 ปีที่แล้ว +1

      @@gdclemo Well ultimately "device" and "host" are just labels, they dont really mean anything, as long as you know where the packets are being sent from. USB hubs just add on endpoints for all the devices, and route the individual packets without colliding, whether you can hook up two usb storage devices to a usb hub and tell a computer to transfer files between them without those files going to the computer's ram i have no idea, but ultimately it doesnt actually matter if you call one host and the rest devices.

    • @drawapretzel6003
      @drawapretzel6003 2 ปีที่แล้ว +2

      I mean, considering we are still using USB protocol in USB C, which has more wires and more current options, so any USB C device can hook up to any usb device ever and still negotiate something, whether it be input from a keyboard or output of storage space, yeah, they really did a good job with the USB standards.
      I know that 2.0 and 3.0 added more than just speed, but thats the main difference most people think about, and considering that that is the biggest reason to increase the revision of USB, imagine if USB 1.0 had included space for increased data transfer speeds for future proofing.
      talk about universal, huh?

    • @johnburgess2084
      @johnburgess2084 2 ปีที่แล้ว

      As has been said, "One of the great things about standards is . . . there are so many to choose from."

  • @revealingfacts4all
    @revealingfacts4all 2 ปีที่แล้ว +12

    A video like this for the PCIe bus would be really cool! I have a couple of sabrelite boards connected across PCIe with jumper cable to decode PCIe (custom Linux driver). It works! I am studying the roles such as root complex, switch, direct memory transfers... would be good if a video existed on this topic similar to how you break down USB... food 4 thought. Really enjoy these videos!!!

    • @Roxor128
      @Roxor128 2 ปีที่แล้ว +2

      I'd like to see similar videos about ISA, PCI, and AGP first. I feel like going straight to PCIe is jumping into the deep end. We did, after all, get one about the AT keyboard before this.

  • @pradeepkumar.v1219
    @pradeepkumar.v1219 2 ปีที่แล้ว +18

    I m very glad to see u again

  • @petersansgaming8783
    @petersansgaming8783 2 ปีที่แล้ว +33

    This dude is just pumping out quality content like a maniac. One of my favorite channels.

  • @XxxGuitarMadnessxxX
    @XxxGuitarMadnessxxX 2 ปีที่แล้ว +3

    I'm in absolute awe and love with every video I've seen on your channel! I've always been mystified by a lot of what goes on with hardware and even started programming as a hobby to try to understand software at a higher level so I can't begin to describe how appreciative to have come across your channel and see the videos you put out - they're always incredibly interesting and informative! Again, thank you for all the great content you put out! I had no idea so much went into the USB spec and data transfers

  • @brandondowns5718
    @brandondowns5718 2 ปีที่แล้ว +1

    I'm always impressed by your tidy (and informative) notes. Keep up the great work!

  • @bjrnpollen3088
    @bjrnpollen3088 2 ปีที่แล้ว +4

    Just spent 300$ on your 8-bit kit!
    Love your videos keep it up! :)

  • @ddegn
    @ddegn 2 ปีที่แล้ว +16

    I'd love to see a similar series on CAN bus protocol.

  • @triffid0hunter
    @triffid0hunter 2 ปีที่แล้ว +7

    Fwiw, D+ being pulled high indicates a _full_ speed (12MBits) device, which is distinct from _high_ speed (480Mbits).
    High speed devices initially register as full speed, then later negotiate a speed upgrade over the data channel

  • @brilletjuh2
    @brilletjuh2 2 ปีที่แล้ว +19

    At 22:04, you say the keyboard is polled every 18ms, but it says 18 in hex, so shouldn't that be 24ms? Later in the video you do mention 24ms correctly though.

  • @JakeDownsWuzHere
    @JakeDownsWuzHere ปีที่แล้ว

    Thanks for breaking this down in your usual, thorough, yet easy to understand manner. I've been playing with Wireshark USB packet capture and WebUSB/WebHID and this has been a super informative series. Love your videos.

  • @superarcherg5320
    @superarcherg5320 2 ปีที่แล้ว +1

    Glad to see a new vid, very informative and inspiring! keep it up!

  • @VincenzOmaha
    @VincenzOmaha 2 ปีที่แล้ว +63

    Ben: Janet?
    Janet: *poof* Hi Ben!
    Ben: I need a black void, a ton of breadboards, infinite small wires, and every known chip with documentation
    Janet: Of course!

    • @gideonmaxmerling204
      @gideonmaxmerling204 2 ปีที่แล้ว +1

      Who is Janet?

    • @VincenzOmaha
      @VincenzOmaha 2 ปีที่แล้ว +6

      @@gideonmaxmerling204 from the TV show "The Good Place"

    • @nickwallette6201
      @nickwallette6201 2 ปีที่แล้ว +4

      That’s my girl!
      Janet: Not a girl.

    • @VincenzOmaha
      @VincenzOmaha 2 ปีที่แล้ว

      @@nickwallette6201

  • @amangarg9379
    @amangarg9379 2 ปีที่แล้ว +1

    Thank you for this wonderful description .

  • @Krik57
    @Krik57 2 ปีที่แล้ว +3

    This Channel twists my brain out by it's simplisity in electronics. Thank you. I hope that it will not end.

  • @kmpnelson
    @kmpnelson 10 หลายเดือนก่อน

    You do an amazing job of explaining these things, I really appreciate your videos and am actively trying to get my early teen nephew into them and will buy your kits. Thanks for passing on your knowledge in a manner that is very easy to follow and understand.

  • @wmhilton-old
    @wmhilton-old 2 ปีที่แล้ว

    I love these videos so much! It's wonderful to get to see behind the curtain at how devices work.

  • @12ricky04
    @12ricky04 2 ปีที่แล้ว +1

    the world needs more of your videos!

  • @Color-Theory
    @Color-Theory 2 ปีที่แล้ว

    Amazing work. Thank you so much for sharing!

  • @rnjdm23
    @rnjdm23 2 ปีที่แล้ว

    another epic video with detailed information in one understandable way that few people can achieve! Congrats!

  • @sergeant5848
    @sergeant5848 2 ปีที่แล้ว +4

    The effort Ben has gone into this video is phenomenal. Please Ben; don't stop your style, enthusiasm and production values! Your videos are A+

  • @kilimanjarocruz660
    @kilimanjarocruz660 2 ปีที่แล้ว

    Your content is ridiculously good. Thanks for all the work!

  • @fromscratch2654
    @fromscratch2654 2 ปีที่แล้ว +4

    I don't know how you do it but you are such good teacher. I never ever thought about looking into the USB specs because i was a bit scared of it. You took my fear. Thanks ;)

  • @MrVipulLal
    @MrVipulLal 2 ปีที่แล้ว

    Excellent! Thanks for sharing,

  • @HeiderSati
    @HeiderSati 2 ปีที่แล้ว

    Absolutely brilliant video, thank you for all your hard work making it

  • @hussainrizvi1887
    @hussainrizvi1887 2 ปีที่แล้ว +1

    Another half an hour well spent, as expected. Thanks Ben.

  • @periloot
    @periloot ปีที่แล้ว +1

    Amazing breakdown of the process! I'm jealous of that oscilloscope.

  • @LostDeadSoul
    @LostDeadSoul 2 ปีที่แล้ว

    I love that you do all that tedious work just to show fx how the data looks and what it means.
    I mean, I knew that that data must be shared and some kind of descriptor is used, but i had no idea it was that complicated for a simple keyboard.
    Knowing is power, so thank you Ben!

  • @truthsmiles
    @truthsmiles 2 ปีที่แล้ว +6

    I’d love to know if it’s feasible to ‘hack’ a keyboard to change the device description to “Grandma’s Toaster” or “A Very Small Rock”.
    Would be a fun prank to pull on a borrowed keyboard :)

    • @DaedalusYoung
      @DaedalusYoung 2 ปีที่แล้ว +4

      I guess you'd have to hack a firmware update.
      Windows: "A very small rock is having problems communicating to Windows."

  • @diogocruzdiniz3186
    @diogocruzdiniz3186 2 ปีที่แล้ว

    Loved how you take the time to convert all this to human readable, really helps! Would be cool if one day you could have a video on interfaces or protocols between media (like hard drives) and pc. Hope you're all good!

  • @savansanghavi7465
    @savansanghavi7465 2 ปีที่แล้ว

    Really cool video
    Thanks
    Please make more videos

  • @kaledbrahmi3442
    @kaledbrahmi3442 2 ปีที่แล้ว +2

    Yesterday I’ve seen the usb protocol video (awesome video btw) and now with another interesting video

  • @PecPur
    @PecPur 2 ปีที่แล้ว

    Thorough and informative.

  • @tommatthews3612
    @tommatthews3612 2 ปีที่แล้ว +1

    Loving the USB Keyboard videos. And I think it would be really cool to have a video showing lots of devices hooked up to the oscilloscope showing how they work, eg. a mouse etc... Great work though Ben, keep it up 👍

    • @Nuclear868
      @Nuclear868 2 ปีที่แล้ว

      USB protocol setup is performed by software, from the computer's perspective, so it can be viewed with any USB sniffer tool. Wireshark can do it. It will show all packets transmitted. Yes, it will not show stuff like the speed negotiation in the beginning, with setting the data line low or high, or any clock-related signals, which the oscilloscope displays. But for such large message exchange, it looks easier.

  • @wesleymays1931
    @wesleymays1931 2 ปีที่แล้ว +16

    I feel like Ben Eater is secretly the god of computing

  • @spark_coder
    @spark_coder 2 ปีที่แล้ว +2

    @BenEater Thank you so much for these amazing videos.
    I (and I am pretty sure many of your viewers) would love to see you interface a USB keyboard with the 6502 computer you built and show the text on a monitor (other than the small LCD Display).

  • @spbnick
    @spbnick 2 ปีที่แล้ว

    Very well done and explained! It took me much longer to figure all these things out, when writing the hidrd tool ☺ A few comments: it's just "Usage Minimum/Maximum", without "Local", although they're classified as "local" items. Constant inputs/outputs are normally used for padding. I would imagine you can also implement a keyboard without rollover by using one bit per key (like the modifiers are done in this one). Eagerly waiting for the next video, thanks a lot for your work 😁

  • @TheTelefaks
    @TheTelefaks 2 ปีที่แล้ว

    Thanks for your videos. Amazing, well explained professional engineering

  • @sonaxaton
    @sonaxaton 2 ปีที่แล้ว +1

    That scope is amazing with all the USB features. Also I had no idea USB was so complex! Great videos.

  • @superdau
    @superdau 2 ปีที่แล้ว +1

    I knew the video was 36 minutes long before starting to watch. But when you said you'd show the other keyboard in the next video I thought "NO... I want to see it now!!" and "no way this were 36 minutes!".

  • @medoomedoo1634
    @medoomedoo1634 2 ปีที่แล้ว

    TH-cam Channels like you are valuable, valuable, wonderful and useful

  • @syntaxerorr
    @syntaxerorr ปีที่แล้ว

    Awesome video. Thanks!

  • @noliiiivaldez7861
    @noliiiivaldez7861 2 ปีที่แล้ว +2

    thanks for making this kind of videos, i learnt a lot from you than college probably.

  • @thilinasundeepana7264
    @thilinasundeepana7264 2 ปีที่แล้ว

    finally great video about USB. Thanks sir. you video is very informative. Thank you sir for doing this kind of video.

  • @int16_t
    @int16_t 2 ปีที่แล้ว

    I've read other specification for file formats like wav for implementation and this is like it. I'm glad I had experience.

  • @najeebuddin6729
    @najeebuddin6729 2 ปีที่แล้ว

    your videos are pure gold

  • @FrankGraffagnino
    @FrankGraffagnino 2 ปีที่แล้ว +1

    geez... my first thought is that this is way overcomplicated... but seeing the success of the USB protocol and how well things work, I must accept that there were good reasons for these complications. Thanks for the great explanation.

  • @glitchy_weasel
    @glitchy_weasel 2 ปีที่แล้ว

    Insane video! Keep it up :)

  • @jestempies
    @jestempies 2 ปีที่แล้ว

    Great video, thank you.

  • @jrioublanc
    @jrioublanc 2 ปีที่แล้ว

    Amazing job, thanks.

  • @mukaschultze
    @mukaschultze 2 ปีที่แล้ว +8

    12:58 took me a while to realize the screen wasn't tilted

    • @gideonmaxmerling204
      @gideonmaxmerling204 2 ปีที่แล้ว

      why?

    • @mukaschultze
      @mukaschultze 2 ปีที่แล้ว +1

      @@gideonmaxmerling204 the oscilloscope is tilted prior to this, if you're focusing on it for too long it looks like the screen is tilted in the opposite direction

  • @MrLuigiBean1
    @MrLuigiBean1 2 ปีที่แล้ว +1

    This is a fantastic video! Only thing is that I have to turn my volume all the way up just to hear it. :P

  • @eliaseas
    @eliaseas 2 ปีที่แล้ว

    Love your videos! ❤️

  • @byronwatkins2565
    @byronwatkins2565 2 ปีที่แล้ว +2

    Thanks Ben! I have wanted to learn this for decades. A UNIVERSAL Serial Bus obviously must have an elaborate negotiation protocol. I am also curious regarding hub protocols; adding a USB device must not disrupt in-progress communication and USB addressing must transit specific hub(s). Others are probably interested in USB power protocols.

    • @Stoney3K
      @Stoney3K 2 ปีที่แล้ว

      I'd expect a hub to give a periodic report to the upstream host about each individual port -- whether or not there is a device connected, which address it has, the USB speed mode, and what power it consumes. So if a device is suddenly plugged in, the computer can detect that a previously unused port now has something attached with address 0, and start discovering it, while the other devices on that bus are unaffected.
      When the computer starts detecting devices, hub first and then downstream devices (which could also be hubs), it can start building up a tree of individual addresses, and each hub keeps track of which addresses are downstream of its ports, similar to the switching table in an Ethernet switch.

  • @TUTAMKHAMON
    @TUTAMKHAMON 2 ปีที่แล้ว +1

    I have that exact same keyboard (but the ultimate model). Really looking forward to the next video.

  • @karlmikko
    @karlmikko 2 ปีที่แล้ว +1

    I am keen for the next video - I have that same Das Keyboard (typing on it now)

  • @StephenHoldaway
    @StephenHoldaway 2 ปีที่แล้ว

    Loving this recent dive into USB - I've implemented a handful of USB devices for hobby projects and still learned a lot from this!

  • @corsonickerson9794
    @corsonickerson9794 2 ปีที่แล้ว

    That's perhaps the most interesting video of a kind - complicated stuff explained in easiest way possible, really enjoyed watchin' it.
    An idea for future: you've done several series about a homemade video card - how about building an audio interface?

    • @ilyadaemon
      @ilyadaemon 2 ปีที่แล้ว

      Simplest audio interface is COVOX: it's just resistor-based DAC 8 bit wide to mono output.
      But 8 bit is noisy, so if you want better sound you'll try to make 16-bit DAC and duplicate it to get stereo sound :)

  • @fahrizalu
    @fahrizalu 2 ปีที่แล้ว

    thanks for sharing and explaining USB (HID) Keyboard negotiation. It's like opening black box of USB spec. Explaining using real USB communication and oscilloscope it (and) also decode it, all new level.

  • @kamaliasc
    @kamaliasc 2 ปีที่แล้ว

    Thanks for the video... by the way I liked the functionality of your keysight oscilloscope...

  • @ChristieNel
    @ChristieNel 2 ปีที่แล้ว +39

    I've always been under the impression that the USB stack is incredibly complicated. But at least so far it looks benign. I do find it bizarre that the PC tells the keyboard how long a response it expects, though.

    • @byronwatkins2565
      @byronwatkins2565 2 ปีที่แล้ว +8

      They obviously must agree on data lengths somehow. Since the computer (host) initiates all contacts, it is most convenient to specify the length at that time. You might also note that the device replies with data lengths for the requested information, which the computer uses in the next request.

    • @ChristieNel
      @ChristieNel 2 ปีที่แล้ว

      @@byronwatkins2565 The usual way is to send all the data you need and just indicate the total size in the header. This also saves one round-trip and having to resend a portion again. I guess there might be a case for peripherals with very small memory, but seriously, it's not that much data.

    • @jeromethiel4323
      @jeromethiel4323 2 ปีที่แล้ว +2

      I bet that if the PC tells the keyboard to send more keys than it's electronics allow, the rest of the data will just be blank. If, for example, a keyboard can only have 4 key rollover, then requesting 8 key rollover will not magically enable the keyboard to do that many rollovers.
      I'm betting the device driver sets a lot of these settings, because the manufacturer can set up what the device can support.

    • @doctorbobstone
      @doctorbobstone 2 ปีที่แล้ว +13

      @@ChristieNel I think this let's the host have full control of scheduling. Imagine I have a real time device with strict timing requirements. If a keyboard can decide that it wants to give me 150 bytes this time, that variability may mean that I could not have it on the same USB bus. Or I might have to always leave space for its longest possible response. But if the protocol is designed where the host is in control, things can be much more rigidly controlled in systems which need it.

    • @byronwatkins2565
      @byronwatkins2565 2 ปีที่แล้ว +1

      @@ChristieNel How many bytes in the header do you need for the total size? Keep in mind that there are TB drives that might be at the other end. "The usual way" is not "universal."

  • @emrahsungu
    @emrahsungu 2 ปีที่แล้ว +1

    Thanks!

  • @EUPThatsMe
    @EUPThatsMe 2 ปีที่แล้ว +37

    22:00 "Polled every 18ms" - yet every other number is hex thus shouldn't the 18 indicate polling every 24ms?

    • @QueueTeePies
      @QueueTeePies 2 ปีที่แล้ว +2

      Maybe they represent individual digit like 0x1 for 10ms and 0x08 for 8ms.

    • @happysongs4kyrone
      @happysongs4kyrone 2 ปีที่แล้ว

      @@QueueTeePies ive got a whole 0x300000 ping

    • @ddegn
      @ddegn 2 ปีที่แล้ว +5

      It looks like it should be 24ms to me as well.

    • @EUPThatsMe
      @EUPThatsMe 2 ปีที่แล้ว +2

      @@QueueTeePies I suppose it could be BCD where each nibble (4bits) only represent 0..9 - now I got to go look up the USB spec - Although I'm assuming that the polling period would be obvious on the scope.

    • @EUPThatsMe
      @EUPThatsMe 2 ปีที่แล้ว +8

      34:30 A-HA! in the end the host tells the keyboard to IDLE for 24ms

  • @TobyAsE120
    @TobyAsE120 2 ปีที่แล้ว +3

    Ben didn't sleep since the last video, he read the entire USB spec...

  • @GudinVladimir
    @GudinVladimir 2 ปีที่แล้ว

    I checked 5 times, that I have liked this video. Extremely useful!

  • @alexlefevre8226
    @alexlefevre8226 2 ปีที่แล้ว

    Super interesting and informative... You answered many questions pertaining to USB that I had!
    Your videos are truly amazing. I just purchased some of the kits from your site and I'm far too excited for them to get here :)
    Also....
    That scope is dream worthy. I finally upgraded to a second hand 4 channel 500mhz Tek scope that I bought from a friend of a friend that he used maybe a dozen times for his small business that has been sitting in his office room for over 7 years. Paid $600 and he wouldn't take a penny more! (Easily $2000-2500++ right now, but he did well in life and is a generous person. He'd probably have just given it to me, but I'm not poor and couldn't have ever accepted that) Even my new massive upgrade, as much as I love it to the point my fiancee gives me weird looks, doesn't even hold a candle to that massive scope of awesomeness you use here! Something to work towards!

  • @standupmackan
    @standupmackan 2 ปีที่แล้ว +2

    (Also - when writing Braille it is not impossible to reach the key rollover...)

  • @largepimping
    @largepimping 2 ปีที่แล้ว +31

    Ben, are you going to explain to my wife why I'm not getting anything done this morning? :)

    • @markmaker2488
      @markmaker2488 2 ปีที่แล้ว +2

      If anyone can explain it Ben can!

    • @1pcfred
      @1pcfred 2 ปีที่แล้ว +2

      Just explain to your wife that someday when our Sun expands it is going to consume the entire Earth so it really doesn't matter what any of us do here.

    • @levyroth
      @levyroth 2 ปีที่แล้ว

      Your mum is not your wife, basement dweller.

  • @scose
    @scose 2 ปีที่แล้ว +3

    Whoa, I requested this on your other USB video yesterday, but I thought it might be too high level!

  • @PewDiePie777
    @PewDiePie777 หลายเดือนก่อน

    I can't stop watching this.

  • @FilipMilerX
    @FilipMilerX 2 ปีที่แล้ว

    These videos are goldmines.

  • @passenger000
    @passenger000 2 ปีที่แล้ว

    great video! thats where NKRO keyboard kick in, using one for past 10 years

  • @heitortremor
    @heitortremor 2 ปีที่แล้ว +1

    Amazing!

  • @TheJaguar1983
    @TheJaguar1983 ปีที่แล้ว +2

    Something I wonder is: if multiple devices are plugged in at once, how does the setup message not collide with all of the devices? Do the hubs forward the messages to each port in sequence?

  • @michaoj341
    @michaoj341 2 ปีที่แล้ว

    Thanks to your videos I started to enjoy low level computer science, which used to be my nightmare on university. Well done sir, keep it up!

  • @liviuflorinelanghel4267
    @liviuflorinelanghel4267 ปีที่แล้ว

    Good job Eater. Thanks a lot for details. Did you think to describe in the same way the mouse device protocol?

  • @md.farhadalam4912
    @md.farhadalam4912 2 ปีที่แล้ว

    Brother . your work really inspiring.you welcome everyone to learn how the internal mechanism really works! That's is what others don't do.If i could discover you 7 years back i would definitely took CSE as my major subject. Due to education system, age and social barrier i can't spend time until secure a good job to survive.But surely i will spend my times after i secure a job.Best wishes for you.

  • @chiblast100x
    @chiblast100x 2 ปีที่แล้ว

    Been meaning to dig into the USB HID spec for a while now as I've been wanting to do a set of custom USB input devices (8 button left handed trackball and scratch built fight stick being the big two), so this is a fascinating watch for me.

  • @Electronieks
    @Electronieks 2 ปีที่แล้ว

    Yess a new upload