Live data from Hacker News

Raw Gadget is a kernel module that allows to emulate USB devices from userspace

github.com

1–10 of 26 posts

Re: Raw Gadget is a kernel module that allows to emulate USB devices from userspace

#5
A key bit of information that might clear up some confusion - USB gadgets are the main peripheral-side USB interface in the Linux kernel.

When you plug an embedded Linux device like a phone into something, it could use USB gadgets to expose internal storage as a mass storage device, create a tty and expose that as a USB ACM/CDC device, etc- and using the gadget mechanism, allocate USB endpoints to each of these functions, and enable or disable them at runtime.

So, this project seems to be allowing a Linux device to emulate arbitrary peripherals to an external USB host.

Prior work in this area: see Facedancer. Neat.

Re: Raw Gadget is a kernel module that allows to emulate USB devices from userspace

#6

Neat. Can you clarify what "emulate" means? Would this let me implement a USB gadget on a Linux board with a device-side USB port, without writing a kernel module?

That's already possible using usb functionfs.

Re: Raw Gadget is a kernel module that allows to emulate USB devices from userspace

#7

A key bit of information that might clear up some confusion - USB gadgets are the main peripheral-side USB interface in the Linux kernel. When you plug an embedded Linux device like a phone into something, it could use USB gadgets to expose internal storage as a mass storage device, create a tty and expose that as a USB ACM/CDC device, etc- and using the gadget mechanism, allocate USB endpoints to each of these funct…

No, this allows userspace to act as a USB gadget connected to the Linux kernel it's running on.

Re: Raw Gadget is a kernel module that allows to emulate USB devices from userspace

#8

A key bit of information that might clear up some confusion - USB gadgets are the main peripheral-side USB interface in the Linux kernel. When you plug an embedded Linux device like a phone into something, it could use USB gadgets to expose internal storage as a mass storage device, create a tty and expose that as a USB ACM/CDC device, etc- and using the gadget mechanism, allocate USB endpoints to each of these funct…

No, this allows userspace to act as a USB gadget connected to the Linux kernel it's running on.

It sure doesn't seem to.

That's why they have a separate subproject for it-

https://github.com/xairy/raw-gadget/blob/master/dummy_hcd/RE...

But you certainly could know more than me about it! Why do you think it's exclusively for acting as a USB gadget connected to the Linux kernel it's running on?

Re: Raw Gadget is a kernel module that allows to emulate USB devices from userspace

#9
Bit of clarification is apparently needed. The loopback USB emulation is already in mainline via CONFIG_USB_DUMMY_HCD

What this new module provides is new userspace API to the gadget subsystem, making the dummy hcd much more practical especially for testing USB driver code

Re: Raw Gadget is a kernel module that allows to emulate USB devices from userspace

#10
This is really fantastic. I am currently building my own keyboard with my own controller and it will be much easier for me to first implement mock controller in userspace before I try to get it right on external device. Especially because I will want to put some complicated functionality in it like steno.
Post reply on HN