Linux USB Device Driver Tutorial Part-1 - Basics
The USB System architecture consists of three main components:
USB Host is in charge of asking each and every USB device, if it has any data to send. A USB device can never start sending data without first being asked to by the host controller.
Which devices needs a Linux USB Driver and which do not?
USB Protocol specification define a set of standards that any device of a specific type can follow. If a device follows that standard, then a special driver for that device is not necessary. These different types are called classes (e.g. storage devices, keyboards, mice, joysticks, network devices and modems). Other type of devices that do not fit into these classes require a special vendor-specific driver to be written for that specific device.
USB Gadget Driver vs USB Host Driver:
USB Host: Driver running on the host (desktop for example) controlling the USB devices that are plugged into it.
USB Gadget: Driver running on the device controlling how the device looks to the host computer as a USB device.
Decoding a USB Device:
All valid USB devices contain one or more configurations. A configuration of a USB Device is like a profile, where the default one is the commonly used one. Linux only supports one configuration per device.
Each and every configuration can have multiple interfaces. You can assume interface as a feature or functionality of the device.
E.g. Mouse, Keyboard or audio interface.
Number of interfaces = Number of independent functionalities provided by the device.
E.g. Multifunction USB Printer can do printing, scanning, faxing then it would likely have three interfaces - one for each of the functionality.
USB Speaker might consists of two interfaces : USB audio stream, and USB keyboard for the button interface.
Each and every USB Interface needs a special USB Driver. So, a single USB Device can have multiple USB device drivers. It is common to have a single USB device driver handle all the interfaces of the USB device.
Each and every interface has multiple endpoints. Endpoint is like a pipe carrying information from the host computer to device (OUT endpoint) or from the device to the host computer (IN endpoint). Depending on the type of the information, the endpoints have four types:
- USB Host
- One or more USB Devices
- A physical bus represented by USB cable that connects devices with the host computer
USB Host is in charge of asking each and every USB device, if it has any data to send. A USB device can never start sending data without first being asked to by the host controller.
Which devices needs a Linux USB Driver and which do not?
USB Protocol specification define a set of standards that any device of a specific type can follow. If a device follows that standard, then a special driver for that device is not necessary. These different types are called classes (e.g. storage devices, keyboards, mice, joysticks, network devices and modems). Other type of devices that do not fit into these classes require a special vendor-specific driver to be written for that specific device.
USB Gadget Driver vs USB Host Driver:
USB Host: Driver running on the host (desktop for example) controlling the USB devices that are plugged into it.
USB Gadget: Driver running on the device controlling how the device looks to the host computer as a USB device.
Decoding a USB Device:
All valid USB devices contain one or more configurations. A configuration of a USB Device is like a profile, where the default one is the commonly used one. Linux only supports one configuration per device.
Each and every configuration can have multiple interfaces. You can assume interface as a feature or functionality of the device.
E.g. Mouse, Keyboard or audio interface.
Number of interfaces = Number of independent functionalities provided by the device.
E.g. Multifunction USB Printer can do printing, scanning, faxing then it would likely have three interfaces - one for each of the functionality.
USB Speaker might consists of two interfaces : USB audio stream, and USB keyboard for the button interface.
Each and every USB Interface needs a special USB Driver. So, a single USB Device can have multiple USB device drivers. It is common to have a single USB device driver handle all the interfaces of the USB device.
Each and every interface has multiple endpoints. Endpoint is like a pipe carrying information from the host computer to device (OUT endpoint) or from the device to the host computer (IN endpoint). Depending on the type of the information, the endpoints have four types:
- Control
- Interrupt
- Bulk
- Isochronous
As per USB Standard, all valid USB Devices will have control endpoint zero. This is a bi-directional endpoint
Hi, thanks for the article.
ReplyDeleteCan you please help in this error :
Accessory sent USB HOST HID COMPONENT with Interface Number 3, But not matching HID interface was seeing during USB enumeration.
Can you please Tell How to get correct Interface Number at time of USB enumeration.
this is a very nice post and very informative, thanks alot for sharing keep it up..
ReplyDeleteBest Linux Shared Hosting in USA