You are on page 1of 51

USB 2.

0
ARCHITECTURE Overview
KANWAR SAAD BIN LIAQAT
Research Assistant - UG
Main Features & History Main Features & History
Basic Definitions
Device Enumeration Steps
Data Transfer Modes
HISTORY
USB 1.0 (J an 1996) USB 1.0 (J an 1996)
USB 1.1 (Sep 1998)
USB 2.0 (Apr 2000)
USB 3.0 (Nov 2008)
FEATURES
Supported data rates : 1.5Mbps, 12Mbps, 480Mbps
No. of devices : 127 including hubs
Supports hot plugging Supports hot plugging
External bus
Max hub levels : 5
Uses tiered
BASIC DEFINITIONS
-- Bus Speeds
Speed Name USB version Data rate
Low Speed USB 1.0 1.5 Mbps
Full Speed USB 1.1 12 Mbps
High Speed USB 2.0 480 Mbps
Super Speed USB 3.0 4.8 Gbps
BASIC DEFINITIONS
-- Bus Topology
Tiered Star Bus Topology
BASIC DEFINITIONS
-- HOST
Master of the bus
Initializes all transactions.
Devices cannot communicate Devices cannot communicate
directly with each other.
The only exception is that a
suspended device can initiate a
remote wake-up call.
BASIC DEFINITIONS
-- Cables
Shielded cable containing 4 wires
Two of these D+and D- form a twisted pair, responsible for
carrying differential data and single ended signals.
Third one is the ground wire as a reference for D+and D- named
GND.
Fourth one is the 5V supply called VBUS
BASIC DEFINITIONS
-- Cable Length
Max cable length =5m
Since hub levels are allowed so a device can be at the most 25m
away from the host.
Hence for transferring data through USB the device should be
closer to the host.
BASIC DEFINITIONS
-- Connectors
BASIC DEFINITIONS
-- Powering
Bus provides 5V supply on a single wire.
Unit load =100mA Unit load =100mA
5 unit loads allowed at max. i.e. 500mA
Low power devices draw 1 unit load at max.
By default a device is configured low power device.
High power devices can utilize max unit loads supported by bus on
demand.
If the device requires more power than this then device should
arrange its own power and it is called a self powered device.
BASIC DEFINITIONS
-- Line States
Detached : No device plugged in. D+and D- are low.
Attached : Device is plugged in. Either D+or D- will go high.
Idle : State before and after a packet is sent. One of the D+or D-
line remains high and other remains low.
BASIC DEFINITIONS
-- J, K, SE0 and SE1
J : Same polarity as the idle state.
K : Opposite of K.
SE0 : Single Ended zero state is when both lines are pulled low.
SE1 : When both lines are pulled high. There is no such signal as
SE1, hence whenever such a signal comes, it shows an error. SE1, hence whenever such a signal comes, it shows an error.
BASIC DEFINITIONS
-- RESET Signal
Host Keeps SE0 state for at least 10ms. However device will
recognize it after 2.5us.
It is NOT a power on type reset. It is just a protocol reset to ensure
that the device signaling starts from a known state.
-- EOP Signal -- EOP Signal
End of Packet signal is sent whenever a packet ends.
It is an SE0 signal for 2 bit times followed by a J state for 1 bit
time.
BASIC DEFINITIONS
-- SUSPEND Signal
When there is an inactivity at the device then host keeps SE0 state
for 3ms. This sends the device to suspend state.
A suspended device may draw no more than 0.5 mA from Vbus.
A suspended device must recognisethe resume signal, and also the
reset signal.
-- RESUME Signal -- RESUME Signal
When a suspended device wants to wake up, it sends a resume signal.
This is achieved by reversing the polarity of the lines for atleast 20ms.
BASIC DEFINITIONS
-- Packets
Smallest Element of data transmission.
Each packet contains integral no. of bytes.
Least Significant Bit(LSB) is transmitted first.
The bus is in the idle state, before and after the packet.
Packet =synch +data bytes +EOP Packet =synch +data bytes +EOP
NRZI Encoding is used.
To ensure synchronized clock bit stuffing is used. A zero is inserted
after every 6 consecutive 1s.
BASIC DEFINITIONS
-- EndPoint (EPn)
Each USB device has a number of endpoints.
Each endpoint is a source or sink of data.
A device can have up to 16 OUT and 16 IN endpoints.
IN and OUT are referenced from Host.
EP0 is a special case. EP0 =EP0(IN) +EP0(OUT).
-- Pipe -- Pipe
A logical data connection between the host and a particular endpoint,
in which we ignore the lower level mechanisms for actually
achieving the data transfers.
A pipe is seen from upper layers.
Device Enumeration Steps
DEVICE ENUMERATION
Step 01 : Plug the device in USB port
Port may be in the host or hub.
Hub provides power to the port.
Device is in the powered state. Device is in the powered state.
Step 02 : Hub detects the device
The hub monitors the voltages of signal lines.
If there is change in any of the line voltages it means a device is
connected.
DEVICE ENUMERATION
Step 03 : Host learns of the new device
Each hub uses its interrupt pipe to report events at the hub.
The report indicates whether a port or a hub has experienced an event.
When the host learns of an event, it sends a GET_PORT_STATUS When the host learns of an event, it sends a GET_PORT_STATUS
request to the hub.
Hub replies of an event that a device is attached.
DEVICE ENUMERATION
Step 04 : Hub detects whether device is low or
full speed.
Hub has both D+and D- lines pulled down through 1.5k resistors.
A full speed device has a 1.5k pull up resistor on D+line.
A low speed device has a 1.5k pull up resistor on D- line. A low speed device has a 1.5k pull up resistor on D- line.
Initially a high speed device is also detected as a full speed device.
Hub detects which line is pulled up by the device. Based on the pulled
up line, the hub knows whether the device is full speed or low speed.
DEVICE ENUMERATION
Step 04 : Hub detects whether device is low or
full speed.
A Full speed device is connected
DEVICE ENUMERATION
Step 04 : Hub detects whether device is low or
full speed.
A low speed device is connected
DEVICE ENUMERATION
Step 05 : Hub resets the device.
Host learns that a new device is attached.
It requests the hub to reset the device.
Host gives a reset signal to the device. i.e. it keeps SE0 signal on lines Host gives a reset signal to the device. i.e. it keeps SE0 signal on lines
for at least 10ms.
DEVICE ENUMERATION
Step 06 : Host learns if a full speed device
supports high speed.
During the 10ms reset the device that supports high speed sends a
chirp K signal.
A hub that supports high speed responds with an alternating chirp K,J A hub that supports high speed responds with an alternating chirp K,J
signal. KJ KJ KJ .
When device recieves this signal it removes it full speed pull up and
performs rest of its communication at high speed.
All high speed devices must be capable of responding to enumeration
requests at full speed.
DEVICE ENUMERATION
Step 06 : Host learns if a full speed device
supports high speed.
DEVICE ENUMERATION
Step 07 : The hub establishes a signal path
between the device and the hub.
Thehost first verifies that thedevicehas exited thereset stateor not
bysendingaGET_PORT_STATUSrequest.
A bit inthedatareturnedshows whether thedeviceisinreset stateor A bit inthedatareturnedshows whether thedeviceisinreset stateor
not.
If necessary the host repeats the request until device exits the reset
state.
Whenthehubremovesthereset, thedeviceisinthedefault state.
Thedeviceisreadyfor control transfersthroughEP0.
Thedevicecancommunicatewiththehost usingadefault address of
00h.
DEVICE ENUMERATION
Step 08 : The Host learns about the max
packet size of the default pipe of the device.
The host sends a request to device 0 at EP0. Because the host can
enumerate only one device at a time hence only one device has an
addressof 00h. addressof 00h.
Thedevicereturns a8 bytedevicedescription that contains themax
packet sizesupportedbyEP0.
DEVICE ENUMERATION
Step 09 : The Host assigns an address.
Thehost controller assignsauniqueaddresstothedevice.
Thedevicereadstherequest andACKsit.
Thedeviceisnowinaddressstate. Thedeviceisnowinaddressstate.
Step 10 : The Host learns about devices abilities.
Thehost sendsget_descriptor request tothedeviceat newaddress.
Thedevicereplieswiththedevice_descriptor.
Device_descriptor contains max packet size of EP0, the no. of
configurations thedevicesupports and other basic information about
thedevice.
DEVICE ENUMERATION
Step 11 : The host assigns and loads a device driver.
After host learns as much as it can of the device, it searches for its
devicedriver sothat it cancommunicatewiththedevice.
Thevendor andproduct IDsretrievedfromthedevicescanbeusedto Thevendor andproduct IDsretrievedfromthedevicescanbeusedto
matchthecorrect devicedriver.
If thereisnomatchthenhost matchesany class, sub-classor protocol
values.
Whatever matches, the host the loads its driver for further
communication.
DEVICE ENUMERATION
Step 12 : The device driver selects a device
configuration.
Thedevicecansupport multipleconfiguration.
Thehost then asks fromtheuser for what configuration to load or it
mayselect thefirst one. mayselect thefirst one.
Whentheconfigurationisloaded, thedeviceisconfiguredandnowit
isreadytouse.
HUB ENUMERATION
HubsarealsoUSB devices.
A hubisenumeratedinexactlythesamewayadeviceisenumerated. A hubisenumeratedinexactlythesamewayadeviceisenumerated.
If thehubhasdevicesattached, thehost alsoenumerateseachof these
after thehubinformsthehost of their presence.
DEVICE REMOVAL
Thehost constantlypollsthehub.
When a device is removed, hub responds the host that an event has When a device is removed, hub responds the host that an event has
occurred.
Thehost sendsaGET_PORT_STATUSrequest tofindout what event
hasoccurred.
Thehost thenremovesthat devicefromitslist andtheaddressof that
deviceisassignedtoanother newlyattacheddevice.
DATA TRANSFER TYPES
Bulk Transfer
Interrupt Transfer
Isochronous Transfer
Control Transfer
1. BULK TRANSFER
Useful for transferringdatawhentimeisnt critical.
For sendinglargeamountsof datawithout cloggingthebus. For sendinglargeamountsof datawithout cloggingthebus.
Haslowest priority.
Examples: sendingdatafromPC toaprinter, transferringdatafroma
flashdiske.t.c
Whenthebusisidle, theyarethefastest modeof error freetransfer.
1. BULK TRANSFER
Availability :
Onlyfull speedandhighspeeddevicescandobulktransfer.
All devicesdonot needtosupport bulktransfers, onlyacertaindevice
classesneedit. E.g. massstoragedevices. classesneedit. E.g. massstoragedevices.
Data Size :
Maxpacket sizesof 8, 16, 32, or 64bytes.
If the data to be transferred do not complete in one packet then the
host completesthetransfer usingmultipletransactions.
1. BULK TRANSFER
Speed :
Host guaranteesthat thedatatransfer completeseventually.
Dont reserveanytransfer for thedatahenceif busisbusyit maytake
verylong. verylong.
When bus is idle, it is the fastest mode of transfer since it has the
lowest protocol overhead.
Detecting and handling errors:
Use handshake packets such as ACK, NACK e.t.c for error free
transmissionof data.
If adevicedoesnt sendhandshakepacket thenhost retriestwice.
Usedatatogglebitstoensurenodataislost.
1. BULK TRANSFER
Example transfer :
2. INTERRUPT TRANSFER
Whenadatahastobetransferredwithinaspecificamount of time.
Typical applications are human interface devices such as mouse, Typical applications are human interface devices such as mouse,
keyboard.
Limited bandwidth available in low and full speed but it becomes
400xinhighspeed.
It does not generates interrupt asits nameimpliesrather it alsoworks
thesamewaythat all other transfersdoi.ethroughpolling.
2. INTERRUPT TRANSFER
Availability :
All versionsof usbsupport thistypeof transfer.
All devices do not need to support Interrupt transfers, only a certain
deviceclassesneedit. E.g. HIDs. deviceclassesneedit. E.g. HIDs.
Data Size :
Lowspeed: 1 8bytes
Full speed: 1 64bytes
Highspeed: 1 1024bytes
If the data to be transferred do not complete in one packet then the
host completesthetransfer usingmultipletransactions.
2. INTERRUPT TRANSFER
Speed :
Noguaranteedtransfer rate.
J ust ensuresthat nomorelatencythanspecified.
Highspeedinterrupt transferscanbeveryfast. Highspeedinterrupt transferscanbeveryfast.
Detecting and handling errors:
Use handshake packets such as ACK, NACK e.t.c for error free
transmissionof data.
If adevicedoesnt sendhandshakepacket thenhost retriestwice.
Usedatatogglebitstoensurenodataislost.
2. INTERRUPT TRANSFER
Example transfer :
3. ISOCHRONOUS TRANSFER
Usedfor streamingandreal timetransfers.
Ensuresaconstant datarate.
At full speedit cantransfer moredatathanininterrupt transfer. At full speedit cantransfer moredatathanininterrupt transfer.
Examples: encodedvoiceplayedinreal time.
Ensures that a large amount of data gets through quickly on a busy
bus.
Completiontimeispredictable.
3. ISOCHRONOUS TRANSFER
Availability :
Onlyfull andhighsppeddevicessupport thistypeof transfer.
All devices do not need to support Isochronous transfers, only a
certaindeviceclassesneedit. E.g. videostreaming. certaindeviceclassesneedit. E.g. videostreaming.
Data Size :
Full speed: 0 1023 databytes
Highspeed: 1024bytespacket size
Amount of dataineachframedoesnt havetobesame.
If the data to be transferred do not complete in one packet then the
host completesthetransfer usingmultipletransactions.
3. ISOCHRONOUS TRANSFER
Speed :
1.023MBpsat max.
Leaves31%busbandwidthfor other purposes.
Protocol overheadis9bytesper transfer. Protocol overheadis9bytesper transfer.
Detecting and handling errors:
Noerror correction.
Intendedfor useswheresmall errorsareacceptable.
3. ISOCHRONOUS TRANSFER
Example transfer :
4. CONTROL TRANSFER
Twouses.
1. Carrytherequestsfor USB specifications.
2. Configuredevices. 2. Configuredevices.
Interactivetransfer. IncludeIN andOUT transactions.
4. CONTROL TRANSFER
Availability :
Everydevicemust support control transfer over default pipeEP0.
A devicemay haveadditional pipes configuredfor control purposes.
But additional control pipescanoffer noadvantage. But additional control pipescanoffer noadvantage.
Data Size :
Lowspeed: 8bytes
Full speed: 8, 16, 32, or 64bytes
Highspeed: 64bytes
If the data to be transferred do not complete in one packet then the
host completesthetransfer usingmultipletransactions.
4. CONTROL TRANSFER
Speed :
Host ensuresthat all control transfersget throughthebusasquicklyas
possible.
Reservedbandwidth: 10%for lowandfull speed, and20%for high Reservedbandwidth: 10%for lowandfull speed, and20%for high
speed.
Detecting and handling errors:
Tworetriesif nohandshakepacket isreceived.
After that host stops all transactions and informs the software that
thereisaproblemat thecontrol port whichmust berectified.
Usedatatogglebitstoensurenodataislost.
4. CONTROL TRANSFER
Example transfer :
Questions?
Thank you !

You might also like