I have a an Embedded Linux device and I would like to set the VID, PID and name. Where is this normally done? In 开发者_JAVA百科the file system or is the compiled into the kernel?
It is done in the kernel: I presume that you have a USB gadget driver that you have developped or that you are using so that your Embedded Linux device can be used as a USB device.
This driver certainly has a struct usb_device_descriptor
that is declared somewhere. As you can see, this struct has some idVendor
, idProduct
fields. The human readable strings are iManufacturer
, iProduct
and iSerialNum
. Here is the complete struct:
/* USB_DT_DEVICE: Device descriptor */
struct usb_device_descriptor {
__u8 bLength;
__u8 bDescriptorType;
__le16 bcdUSB;
__u8 bDeviceClass;
__u8 bDeviceSubClass;
__u8 bDeviceProtocol;
__u8 bMaxPacketSize0;
__le16 idVendor;
__le16 idProduct;
__le16 bcdDevice;
__u8 iManufacturer;
__u8 iProduct;
__u8 iSerialNumber;
__u8 bNumConfigurations;
} __attribute__ ((packed));
If you are using an already developped driver, some give you the possibility to set these fields with some values that you pass as module parameter, see drivers/usb/gadget/printer.c
for a very good example. This way, you could pass the values to the kernel, from userspace.
精彩评论