The kernel module for the DT7816 USB gadget driver is a simplified version of gadgetfs and has the same kind of functionality. When loaded, it enumerates as a USB gadget, creates a specified number of bulk USB endpoints, and exposes each end point as a virtual file in the /dev directory.
A user mode application can perform file operations on each virtual file to send data to the USB host through an IN endpoint and receive data from the USB host through an OUT endpoint. The module serves as a conduit for data and does not care about the data itself. Refer to the DT7816 File I/O Programming Manual for more information on virtual files and file I/O commands for the USB gadget driver.
Unlike gadgetfs, this module does not require you to initialize it with USB descriptors and to handle ep0 setup requests. All initialization is performed when the module is loaded with the modprobe command and is based on the values of the module parameters (modparms).
This page describes the following information for the DT7816 USB gadget driver.
How to Load the Kernel Module Automatically at Boot-Up
The following module parameters can be used in the modprobe command and are listed under /sys/module/g_dt78xx/parameters/. Default values are used if no modparms parameters are specified in the modprobe command.
Module Parameter (modparms) |
Description |
Default Value |
idVendor |
USB Vendor ID (ushort) |
0x0867 |
idProduct |
USB Product ID (ushort) |
0x7816 |
bcdDevice |
USB Device version (BCD) (ushort) |
0x0000 |
iSerialNumber |
SerialNumber string (charp) |
"0123456789" |
iManufacturer |
USB Manufacturer string (charp) |
"Data Translation" |
iProduct |
USB Product string (charp) |
"DT78xx" |
inPipes |
Number of bulk USB input pipes (ushort) |
1 |
outPipes |
Number of bulk USB output pipes (ushort) |
1 |
For example, the following command manually loads the kernel module for the DT78xx gadget driver, overriding the default value of the iManufacturer parameter with the value "ABCDefgh" and overriding the default value of the idVendor parameters with the value 100:
modprobe g_dt78xx iManufacturer="ABCDefgh" idVendor=100
To load the kernel module for the DT7816 USB gadget driver at boot-up, edit the file /etc/modules and add the following entries to the file (note that lines starting with # are comments):
# Load the DT78xx USB gadget driver
to enumerate as a DT7816 with
# 2 IN endpoints and 5 OUT endpoints
g_dt78xx idProduct=0x7816 iProduct="DT7816" inPipes=2
outPipes=5
Note: If you execute the lsusb command on the host after this gadget driver is loaded and connected to a Linux host, the command may report the manufacturer as unknown with a missing product string. However, if you execute lsusb -v and pipe the results to a text file, the strings specified by module parameters iManufacturer, iProduct and iSerialNumber are reported correctly. This anomaly is due to the fact that lsusb uses string definitions from the files /usr/share/hwdata/usb.ids and /var/lib/usbutils/usb.ids and ignores the strings reported by the USB string descriptors.