Live data from Hacker News

USB for Software Developers: An introduction to writing userspace USB drivers

werwolv.net

11–20 of 57 posts

Re: USB for Software Developers: An introduction to writing userspace USB drivers

#11
post #8
post #5

Earlier quoted context omitted.

Things which are relatively standard tend to get good generic support: Ethernet devices will generally be USB/CDC/ECM or RNDIS, for example. That may Just Work (tm) if it has the right descriptors. The userland approach is much more useful for weird or custom devices. In particular, on Windows you can do one of these user space "drivers" without having to bother with driver signing, and if you use libusb it will be p…

DFU - great example. If you have a USB device that has a DFU class that needs a custom driver, can dfu-util and the like hook into these userspace drivers? Or do you also need to maintain the application part?

Dfu-util is one of those "user space drivers", so if you have a nonstandard protocol you'd have to add it directly to dfu-util. There's no intermediate API.

It's not easy to set up a fake or "remapped" USB device on most OS as far as I'm aware, if you were trying to write an adapter program that modified USB packets.

Re: USB for Software Developers: An introduction to writing userspace USB drivers

#12
post #9
post #6

Earlier quoted context omitted.

Not to be too facetious but a great place for communicating with the kernel where there are a ton of other driver subsystems is... the kernel. Possibly a good addition to the article would be parallel development of an lkm. I guess it wouldn't have that windows interop but I would also be interested to see how this driver would be implemented on Windows. If it's idk 10x as many lines in the kernel vs userspace, that'…

Arguably all these other subsystems shouldn't be in the Kernel either but that's a different topic :) There are quite a few benefits to doing these things in userspace over the Kernel, not really necessarily just because of the code size: - The code is much easier to write and debug, you just write code like you always would. - Bugs don't have the possibility to taking down your entire system or introduce vulnerabili…

[dead]

Re: USB for Software Developers: An introduction to writing userspace USB drivers

#13
post #6
post #3

Earlier quoted context omitted.

On Linux you could create a tun/tap device from your application and translate data sent over that to requests sent to the ethernet adapter. Of course, when you're doing these things in userspace you either need some way of communicating with the Kernel or for the other subsystems to be in userspace as well.

Not to be too facetious but a great place for communicating with the kernel where there are a ton of other driver subsystems is... the kernel. Possibly a good addition to the article would be parallel development of an lkm. I guess it wouldn't have that windows interop but I would also be interested to see how this driver would be implemented on Windows. If it's idk 10x as many lines in the kernel vs userspace, that'…

Driver signing is a killer issue on Windows; if you put your machine into dev/unsigned mode you get an ugly banner that can't be turned off.

Much easier to design the device to avoid that. E.g. by abusing USB-HID. The desktop USB missile launcher toy is USB HID, for example.

Re: USB for Software Developers: An introduction to writing userspace USB drivers

#16
post #14

The C++ looks messed up. I have yet to come across a keyboard that can type an arrow.

It's just a programming font ligature. If you copy and paste it you'll see the actual characters e.g.

   auto main() -> int {
(It's also modern C++ trailing return type.)

Re: USB for Software Developers: An introduction to writing userspace USB drivers

#18
post #14

The C++ looks messed up. I have yet to come across a keyboard that can type an arrow.

Some developers like ligature based fonts. They combine 2 characters into one glyph

Thank you and the others who were kind enough to explain this. I've avoided such fonts like the plague. Didn't know it did arrows like that.
Post reply on HN