1 / 41

Introduction to USB

Introduction to USB. - Madhav Singh-. Scope of Presentation. This presentation describe the basics of USB device and Host side i.e. descriptors, endpoints, device controller, root hub etc. It covers USB architecture in Linux. It does not cover protocol level details of USB. Agenda.

molly
Download Presentation

Introduction to USB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to USB - Madhav Singh-

  2. Scope of Presentation This presentation describe the basics of USB device and Host side i.e. descriptors, endpoints, device controller, root hub etc. It covers USB architecture in Linux. It does not cover protocol level details of USB.

  3. Agenda • USB Introduction • USB Host /Device Terminology • USB Host Controller • USB Topology and Root Hub • USB Device Basics • Endpoints • Descriptors • Linux USB Architecture Overview

  4. Introduction • USB stands for UNIVERSAL SERIAL BUS. • USB is host controlled. There can only be one host per bus. • Specification in itself, does not support any form of multimaster arrangement. • Topologically, a USB subsystem is not laid out as a bus; it is rather a tree built out of several point-to-point links.

  5. Introduction The links are four-wire cables (ground, power, and two signal wires) that connect a device and a hub. Up to 127 devices(7 bit device addressing scheme) can be connected to any one USB bus at any one given time. It was originally created to replace a wide range of slow and different buses—the parallel, serial, and keyboard connections—with a single bus type that all devices could connect to.

  6. Introduction • USB Implementers Forum(USB-IF): -USB Implementers Forum, Inc. is a non-profit corporation founded by the group of companies that developed the Universal Serial Bus specification. -The USB-IF was formed to provide a support organization and forum for the advancement and adoption of Universal Serial Bus technology. (http://www.usb.org/ official site) • The USB-IF, Inc. Board of Directors is composed of the following companies: • Hewlett-Packard Company • Intel Corporation • LSI Corporation • Microsoft Corporation • Renesas Electronics • ST-Ericsson

  7. USB Connector Types USB 1.x/2.0 STANDARD pinning

  8. USB Connector Types USB 1.x/2.0 Mini/Micro pinning

  9. USB Host /Device Terminology Host - The host system where the USB Host Controller is installed. Controller – This is the hardware entity that provides the USB interface. E.g. Host Controller, Device Controller etc. Device –Connected to Host controller, communicate using USB protocol eg. memory stick, digital camera, printer etc. Dual Role Devices (OTG) – Those devices which can function both as a host or as a peripheral.

  10. USB Host Controller USB Host Controller Types: • OHCI (Open Host Controller Interface) • Compaq's implementation adopted as a standard for USB 1.0 and 1.1 by the USB Implementers Forum (USBIF). • UHCI (Universal Host Controller Interface.) • Created by Intel, insisting that other implementers use it and pay royalties for it. • This competition required to test devices for both host controller standards. • For USB 2.0, the USBIF insisted on having only one standard.

  11. USB Host Controller • EHCI Extended Host Controller Interface. • For USB 2.0. The only one to support high speed transfers. • Significant Contributors include Intel, Compaq, NEC, Lucent and Microsoft.

  12. HOST Controller in IA CPU FSB North Bridge RAM Memory Controller Hub ( MCH ) HUBIF VDU Super IO COM, PS2 Keyboard IO Controller Hub( ICH ) LPC PCI SouthBridge USB Controller

  13. USB transfer speed • LowSpeed: • Up to 1.5 Mbps • Since USB 1.0 • Ex. Mouse, Keyboard etc. • FullSpeed: • Up to 12 Mbps • Since USB 1.1 • Ex. Pen drives, Printers etc. • HiSpeed: • Up to 480 Mbps • Since USB 2.0 • Ex. HDD, Network Adapters, Web Cam etc.

  14. USB Host controller Ports through which USB devices can be connected Root Hub Root HUB • - Other Operations: • Control Power to USB devices • Enable/Disable Ports • Recognize Device attached to Port Every Host Controller will have a Root Hub. Root hub enables connection of USB devices to the host A root-hub converts the requested Tx into low level protocols required by USB.

  15. Host Host Root Hub Root Hub Device Device HUB HUB Device Device Device Device Device Device HUB HUB Device Device Device Device USB HUB • Provides extensibility to USB network • Allows more than 1 device to be connected to the host • Can be self powered or Bus powered

  16. USB Bus Topology • Can have up to 7 tiers of devices. • Maximum number of devices that can be connected is 127 • Every use of a hub increases the tier of devices. • Every device in the tree has a “Device Address”

  17. USB Device Basics • Endpoint(EP) • Endpoints can be described as sources or sinks of data • A USB endpoint can carry data in only one direction, either from the host computer to the device (called an OUT endpoint) or from the device to the host computer (called an IN endpoint). • Physical entity. • Per Device max 16 EP are possible • All devices must support EP0, This is the endpoint which receives all of the devices control and status requests during enumeration and throughout the duration while the device is operational on the bus.

  18. USB Endpoints • USB support of 4 types of Endpoints • Control Endpoint • Interrupt Endpoint • Bulk Endpoint • Isochronous Endpoint

  19. Control Endpoints Used to configure the device, get information about it, send commands to it, retrieve status information. Simple, small data transfers. Every device has a control endpoint (endpoint 0),used to configure the device at insertion time. The USB protocol guarantees that the corresponding data transfers will always have enough (reserved) bandwidth.

  20. Interrupt Endpoints Transfer small amounts of data at a fixed rate each time the host asks the device for data. Transfers are guaranteed by the USB protocol to always have enough reserved bandwidth For devices requiring guaranteed response time, such as USB mouse and keyboards. Generally not used to transfer large amounts of data.

  21. Bulk Endpoint Bulk endpoints transfer large amounts of data. No guarantee on bandwidth or latency. Guarantee that no data is lost. Typically used for printers, storage or network devices.

  22. Isochronous Endpoint Also for large amounts of data. Guaranteed speed(often but not necessarily as fast as possible). No guarantee that all data makes it through. Used by real time data transfers (typically audio and video).

  23. END Points Data Flow

  24. USB Descriptors • All USB devices have a hierarchy of descriptors, which gives information to the host, such as what the device is, who is vendor, what version of USB it supports, how many ways it can be configured, the number of endpoints and their types etc. • Common USB Descriptors: • Device Descriptor • Configuration Descriptor • Interface Descriptor • Endpoint Descriptor • USB Descriptors Format: • All descriptors are made up of a common format. • The first byte specifies the length of the descriptor

  25. USB Descriptors • USB Descriptors Format: • If the length of a descriptor is smaller than what the specification defines, then the host shall ignore it • if the size is greater than expected the host will ignore the extra bytes and start looking for the next descriptor at the end of actual length returned.

  26. Device Descriptor • The device descriptor of a USB device represents the entire device. • As a result a USB device can only have one device descriptor. • Device descriptor includes information • USB revision the device complies to • Product and Vendor IDs used to load the appropriate drivers • number of possible configurations the device can have • Class of device i.e. storage, network, HID etc.

  27. Device Descriptor • Some important fields of device descriptor: • bcdUSB field reports the highest version of USB the device supports. • bDeviceClass, used by the operating system to find a class driver for your device, ex HID , Storage, Network etc… • idVendor and idProduct are used by the operating system to find a driver for your device. The Vendor ID is assigned by the USB-IF • bNumConfigurationsdefines the number of configurations the device supports at its current speed.

  28. Configuration Descriptor The configuration descriptor specifies how the device is powered. Therefore it is possible to have two configurations, one for when the device is bus powered and another when it is mains powered. USB device can switch to different configuration for changing state of device. Each configuration descriptor consists of no(s) of Interface Descriptor.

  29. Configuration Descriptor • Some important fields of configuartion descriptor: • bNumInterfacesspecifies the number of interfaces present for this configuration. • bConfigurationValue is used by the SetConfiguration request to select this configuration. • bmAttributes specify power parameters for the configuration, whether a device is self powered or bus powered. • bMaxPowerdefines the maximum power the device will drain from the bus.

  30. Interface Descriptor • The interface descriptor could be seen as a header or grouping of the endpoints into a functional group performing a single feature of the device. • Each interface encapsulates a single high level function, USB logical connection. • One driver is needed for each interface. • Important Fields: • bInterfaceNumberindicates the index of the interface descriptor. This should be zero based, and incremented once for each new interface descriptor. • bNumEndpoints indicates the number of endpoints used by the interface. • bInterfaceClasscan be used to specify supported classes (e.g. HID, communications, mass storage etc.)

  31. Endpoint Descriptor • Endpoint descriptors are used to describe endpoints other than endpoint zero. • Endpoint zero is always assumed to be a control endpoint and is configured before any descriptors are even requested. • The host will use the information returned from these descriptors to determine the bandwidth requirements of the bus. • Important Fields: • bmAttributesspecifies the transfer type. • bEndpointAddress indicates its address, its direction IN or OUT • wMaxPacketSizeindicates the maximum payload size for this endpoint.

  32. USB Descriptors Hierarchy

  33. USB device overview endpointcontrol endpointinput endpointcontrol endpointinput Interface Audio Interface Audio endpointcontrol endpointinput endpointcontrol endpointinput Interface Video Configuration Standby Configuration Active Configurati Configurati Interface Video Device USB WEB CAM

  34. USB Driver Overview

  35. Linux USB overview • The Linux kernel supports two main types of USB drivers: • Drivers on a Device Controller Side. • Drivers on Host Controller Side Drivers On Host Controller Side: • The USB drivers for a host system control the USB devices that are plugged into it, from the host’s point of view. • A common USB host is a desktop computer.

  36. Linux USB Overview Drivers On Host Controller Side: • USB core drivers • Architecture independent kernel subsystem.Implements the USB bus specification. • USB core provides an interface for USB drivers to use to access and control the USB hardware, without having to worry about the different types of USB hardware controllers that are present on the system. • USB host drivers • Different drivers for each USB control hardware. • Usually available in the Board Support Package. • Architecture and platform dependent.

  37. Linux USB Overview Drivers On Host Controller Side • USB device drivers • Drivers for devices on the USB bus. • Platform independent: you can use any USB device supported by Linux(cameras, keyboards, Wi-Fi dongles...). • USB drivers live between the different kernel subsystems (block, net, char, etc.) and the USB hardware controllers.

  38. Linux USB overview(Host Controller Side) User Application User applications LIBUSB Users System call interface Kernel Kernel subsystems USB device drivers Kernel subsystems Other kernel subsystems USB core USB host controller driver Hardware USB host controller USB device

  39. Linux USB overview Drivers On Device Controller Side: • USB drivers in a device, control how that single device looks to the host computer as a USB device. • As the term “USB device drivers” is very confusing, the USB developers have created the term “USB gadget drivers” to describe the drivers that control a USB device that connects to a computer • Typical example: Digital cameras, MobileYou connect the device to a PC and see the cameraas a USB storage device. • USB device controller driver: • Platform dependent. Supports the chip connecting to the USB bus.

  40. Linux USB overview Drivers On Device Controller Side: • USB gadget drivers • Platform independent • Ethernet gadget: implements networking through USB • Storage gadget: makes the host see a USB storage device • Serial gadget: for terminal-type of communication

  41. References http://kernel.org/ http://www.beyondlogic.org http://en.wikipedia.org/ Linux Device Driver Book by Alessandro Rubini

More Related