Sunday, December 10, 2006

usb gadget

GadgetFS ... since not every developer wants to program in the kernel,
or rely specifically on the Linux kernel APIs, a user mode API is
available. An example user mode driver is usb.c. (It also needs
usbstring.c and usbstring.h.) Notice how the device is initialized by
writing its configuration and device descriptors to a file (such
as /dev/gadget/$CHIP), and how the endpoints are initialized in similar
ways (writing descriptors to /dev/gadget/$ENDPOINT). After initializing
them, just read or write to the files to transfer data; or to handle
events including control requests to retrieve string descriptors,
configure alternate settings, and implement class or vendor requests. On
Linux 2.6 AIO (Async I/O) support is available, helping user mode
drivers avoid i/o latencies and letting them stream data as quickly as
in-kernel drivers can stream it. Note that user mode gadget drivers do
not necesarily need to be licensed according to the GPL.

1. Build kernel with GadgetFS support
2. Build kernel with USB client chip, e.g net2272
3. root:/> mount -t gadgetfs gadgetfs /dev/gadget

Will create user space device node: /dev/gadget/net2272.

Blog Archive