Advance of usb

39

description

Universal Serial Bus (USB) is an industry standard developed in the mid-1990s that defines the cables, connectors and communications protocols used in a bus for connection, communication, and power supply between computers and electronic devices.

Transcript of Advance of usb

Page 1: Advance of usb
Page 2: Advance of usb

AgendaUSB SpecificationsUSB BasicsComponentsOnion introduction

SignalingPacketsTransfersRequestsOperating System Interface

USB Resources

Page 3: Advance of usb

USB in 1996:Initially introduced as an additional connector for new applications.

USB

PC Connectivity Vision

Universal Serial Bus

Keyboard

Mouse

SerialPort

ParallelPort

SCSIPort

Sound/GamePorts

GraphicsPort

LAN Modem

GraphicsPort

LAN

USB Future:The PC evolves into a simpler, easier to use appliance. USB USB USB

Telephony, Modem, Keyboard, Mouse,Game ports, Serial ports Device,Digital Audio, Printer, Scanner

Page 4: Advance of usb

USB SpecificationsUSB 1.0 – The original spec, superseded

quickly by USB 1.1USB 1.1 – Minor enhancements to the

USB 1.0 spec, supported Low and Full speed devices

USB 2.0 – The Current Standard, added “high speed’ to USB 1.1

USB OTG – USB On-the-Go, a supplement to the USB 2.0 spec that added a form of device to device communications.

Page 5: Advance of usb

USB Founding CompaniesUSB 1.0 USB 2.0Compaq Compaq

Intel Intel

Microsoft Microsoft

NEC NEC

IBM Lucent

DEC HP

Northern Telecom Philips

Page 6: Advance of usb

USB 2.0 in a Nutshell Runs 40X faster than USB 1.1

Low speed: 1.5Mb/s Full speed: 12Mb/s High speed: 480Mb/s

Fully supports existing USB devices Forward compatible—plug existing 1.1 devices into

new 2.0 hosts Backward compatible—plug new 2.0 devices into

existing 1.1 hosts Uses the same cables as USB 1.1

Page 7: Advance of usb

Hardware Overview...

Topology Tiered Star (Distributes Connectivity Points) 127 logical connections (upto 5 meters per segment) Upto 6 tiers ...

Universal Serial Bus

USBMonitor

SpeakerPen Mouse

Kbd

Mic Phone

PC

HUBHUB

HOST/HUB

Page 8: Advance of usb

USB On-the-Go (USB OTG)

Connect two ‘peripherals’ togetherPC is not required (but still

supported) Allow peripherals to wake up hosts Allow two devices to exchange the host role New OTG devices can tap into the existing

900 million USB devices

Page 9: Advance of usb

USB OTG Example ApplicationsSource: Beeman: www.usbonthego.com

Exchange picturesUpload pictures to webPrint pictures

CameraCell PhonePrinter

Camera

Exchange songsMP3 playerMP3 player

Exchange Contact infoPrint call infoUpload pictures to web

Cell PhonePrinterCamera

Cell Phone

Synchronize phone list, meetingsUpload picturesDownload songs

Cell PhoneCameraMP3 player

PC

ApplicationsPeripheralHost

Page 10: Advance of usb

USB OTG DetailsDefines a new connector and cable

“Mini AB” receptacleMini-A to Mini-B cableCable establishes the default host

A-Device is the default hostDual-role USB devices:

Are sometimes a peripheral, sometimes a host

Must use the new AB connectorProvide limited host capability

Targeted peripheral listOperate at full speed (high speed

optional)

Page 11: Advance of usb

USB Basics

Page 12: Advance of usb

USB BasicsUSB is a Master/Slave Polled Bus (PC is the “Master”, Devices are the “Slaves”)

USB has a “tiered star” architecture that can USB can support up to 127 devices 7-bit address = 128 – root hub – reserved addr 0 for

enumerationUSB is “Hot Pluggable”USB connections can provide both data and

power to the devices

Page 13: Advance of usb

USB is not Simple

Outside, it is simple The “rich user experience” requires some

inner complexity Even though it replaces serial and parallel

ports, it’s not a drop-in replacement It’s electrically simple, but a whole protocol

layer is added

Page 14: Advance of usb

USB Projects Can Require a Significant Code Development Effort

Device side USB houskeeping firmware Application firmware

Host side Driver (maybe) Application software

Page 15: Advance of usb

USB Components

Page 16: Advance of usb

Components of USB SystemsUSB Host ControllersUSB HubsUSB CablesUSB Peripheral Devices

Page 17: Advance of usb

USB Host ControllersReside in PC on motherboard or add-in cardAre the “master” device on the USB busHost Controller has integral “Root Hub”Host Controller Interfaces:

Universal Host Controller Interface (UHCI) Open Host Controller Interface (OHCI) Enhanced Host Controller Interface (EHCI)

Page 18: Advance of usb

USB CablesTransport both Data and PowerFour wires: Vbus, GND, D+, D–Cables are 5 meters MAXTwo connector types, “A” and “B”

Prevents illegal topologies“A” connectors are the ones that goes to the

PC or Hub, “B” connectors goes to the device) (OTG adds Miny A and Mini B connectors)

Cables can be either “captive” (like mice) or detachable

Cables can be unshielded (Low speed devices) or shielded (Full Speed and High Speed devices)

USB extension cables are ILLEGAL

Page 19: Advance of usb

USB HubsA hub provides additional connection points

(ports) for devicesHubs can be:

Self-Powered (<= 500ma to each device) Bus-Powered (<= 100mA to each device)

Hubs contain most of the “magic” and differences between USB 1.1 and USB 2.0

Page 20: Advance of usb

USB DevicesDevices can be:

Self-Powered External Power Source (i.e. wall wart) Batteries

Bus-Powered Low Power Bus Powered (<= 100mA) High Power Bus Powered >100mA, <=500mA)

Devices are “self describing” Devices return data (USB descriptors) to host to

indicate its capabilities, configurations, and how the device is able to communicate

Page 21: Advance of usb

Compound and Composite Devices Composite Device

Multiple interfaces, independently controlledEach interface can have a different driver

Compound DeviceCollection of separate functions, each

with a USB address, connected to an internal hub

Example: Keyboard & Trackball in same package

Page 22: Advance of usb

USB is a Polled BUS

The Host (PC) initiates all transfers Devices respond to host requests Direction: OUT is host-to-device Direction: IN is device-to-host USB is NOT peer-to-peer (not even in

USB OTG)

Page 23: Advance of usb

USB Topology

PCUSB USB

“Tiered Star”

HubUSB USB USB USB

PCUSB USB

Device Device Device

Device Device

Page 24: Advance of usb

Host

Root Hub

Device

DeviceDevice

Device

HUB

Device

HUB

Hot Plug and Play feature

Device attachment on Hub port

Device is detected

Downstream port is enabled

Configuration of Device by Host

Device

USB Configuration ProcessEnumeration

Host Software is responsible for Device configuration

Host

Root Hub

Device

DeviceDevice

Device Device

HUB

Device

HUB

Universal Serial Bus, details

Process of Configuration is accomplished via Control Transfers

Page 25: Advance of usb

USB Transfer SpeedsUSB 1.1:

Low speed is 1.5Mb/sFull speed is 12Mb/s

USB 2.0Low speed is 1.5Mb/sFull speed is 12Mb/sHigh speed is 480 Mb/s

There is a VERY common misconception that say a device is USB 2.0 compliant that it means that it is High Speed device. It does NOT!

Page 26: Advance of usb

Device Abstractions...

- DeviceCommon features and interactions of devicesTypically controlled by system software

- Function Highest level I/F between device driver and function

- End Point Ultimate data source or sink at the device

end Each endpoint is unidirectional and has a

transfer type associated with it‘s Peripheral

Page 27: Advance of usb

Endpoints USB Spec: “a source or sink of data”

A Control Transfer Type endpoint is bi-directional

Others are uni-directionalFour address bits plus a direction bit

selects between up to 32 buffers (FIFOs)Different USB chips support

Various numbers of endpointsVarious buffer sizes

Each device must have 1 Control Type Endpoint (Commonly referred to as Endpoint 0 or the Default Endpoint)

Page 28: Advance of usb

PipesAn abstraction used by the USB spec used to

indicate that 2 endpoints are joined (one in the PC Host and the other in the device).

CONTROL pipe is bi-directional Others are uni-directional

Page 29: Advance of usb

USB DescriptorsDevice Descriptors

Contains the VID/PID/DID/Serial NumberConfiguration DescriptorsInterface DescriptorsEndpoint DescriptorsString DescriptorsDevice Qualifier Descriptors (USB 2.0)Other Speed Configuration Descriptors

(USB 2.0)USB “Classes” can add other class specific

Descriptors

Page 30: Advance of usb

OS Interface

Requests

Transfers

The USB Onion

Packets

Signaling

Page 31: Advance of usb

Signaling

Page 32: Advance of usb

USB SignalingUSB utilizes differential signaling on the

D+ and D- lines.Data is encoded in “non-return to zero

with bit stuffing” Bit stuffing is used to ensure enough

transitions for the clock recovery circuitry.Most designs use silicon that incorporates

an integral Serial Interface Engine (SIE) so you don’t have to worry about the decoding yourself.

PCB layout of D= and D- requires care (especially on High Speed devices).

Page 33: Advance of usb

The SIE (Serial Interface Engine)

SerialInterfaceEngine(SIE)

D+Bytes

USBTransceiver

D+

Page 34: Advance of usb

Packets

Page 35: Advance of usb

USB Packets

USB data travels in packetsIdentified by “Packet ID” (PID)Token packet tells what’s comingData packets deliver bytesHandshake packets report success or otherwise

Page 36: Advance of usb

Packet IDs (PIDS)Token Packets

IN, OUT, SOF, SETUP

Data Packets DATA0, DATA1 (USB LS/FS) DATA2, MDATA (USB HS)

Handshake Packets ACK, NAK, STALL (USB LS/FS) NYET (USB HS)

Page 37: Advance of usb

Handshaking PacketsUsed to ensure correct data delivery on

Control, Bulk and Interrupt TransfersACK – Received with out ErrorNAK – Device Busy, has no dataStall – Unsupported Request, Request FailedNo Response – Request not received or

corrupt, will be retried up to 3 times.

Page 38: Advance of usb

Packets: Identified by PIDSDATA0

DATA1

IN

OUT

ACK

NAK

SOF

SETUP

STALL

PRE

Page 39: Advance of usb

Three Packet Types

OUT

ADDR

ENDP

CRC5

Token Packet

HDATA0

PayloadData

CRC16

Data Packet

H

ACK

H/S Pkt

D