Linux USB Gadget Configfs usage

Source: Internet
Author: User

The use of the Linux 3.0 new USB Gadget CONFIGFS.C driver is as follows:

Mount the Configfs file system:

# mount-t Configfs None/sys/kernel/config

# Cd/sys/kernel/config

# ls

Usb_gadget

# CD Usb_gadget


Create the G1 directory and instantiate a new gadget template:

# mkdir G1

# CD G1

# ls

UDC bdeviceprotocol bMaxPacketSize0 Bcdusb functions Idvendor

Bdeviceclass bdevicesubclass bcddevice configs idproduct strings


Define the VendorID and ProductID of the product

# echo "0XABCD" > Idvendor

# echo "0x1234" > Idproduct


Instantiate English ID:

# mkdir strings/0x409

# ls strings/0x409

Manufacturer Product SerialNumber


Write the developer, product, and serial number string to the kernel:

# echo "0123456789ABCDEF" > Strings/0x409/serialnumber

# echo "Master" > Strings/0x409/manufacturer

# echo "Demo" > Strings/0x409/product


To create a feature instance, it is important to note that if there are multiple instances of a function, the extension must be numbered numerically:

# mkdir FUNCTIONS/ACM. GS0

# mkdir FUNCTIONS/ACM. GS1

# mkdir Functions/ecm.usb0


Create a USB configuration instance:

# mkdir Configs/c.1

# ls Configs/c.1

Maxpower bmattributes Strings


Defines the string used by the configuration descriptor

# mkdir configs/c.1/string/0x409

# ls configs/c.1/strings/0x409/

Configuration

# echo "2XACM+ECM" > Configfs/c.1/strings/0x409/configuration


Bundle feature instances to configuration C.1

# ln-s FUNCTIONS/ACM. GS0 Configs/c.1

# ln-s FUNCTIONS/ACM. GS1 Configs/c.1

# ln-s Functions/ecm.usb0 configs/c.1


Find the available UDC instances for this machine

# ls/sys/class/udc/

Msm_hsusb


Register the gadget driver on a UDC, plug it into a USB cable, and the computer will enumerate the USB devices.

# echo "Msm_hsusb" > UDC


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.