Professional Documents
Culture Documents
USB Tutorial
USB Tutorial
1
USB Tutorial
Objectives
■ Review USB functionalities
■ Be able to read a USB trace
■ Understand the enumeration process
■ Highlight that class drivers are part of the USB success
2
USB Tutorial
4
USB Tutorial
USB Topology
■ A unique device address is assigned to each USB device
■ Physical tiered start network:
HOST Dok @: 3
Hub @: 2
Root Hub @: 1 Mouse @: 4
USB transfer
■ A device has several endpoints
■ Each endpoint is assigned to a logical pipe with the host
■ Each pipe is characterized by:
- Device address SOF @5EP0 @6EP1 @6EP2
- Endpoint number
- Transfer type A 1ms USB Frame
■ Transfer type:
Type Direction Packets per frame M ax Packet Size
Control Bidir Several 64 Bytes
Bulk Unidir Several 64 Bytes
Isochronous Unidir One 1024 Bytes
Interrupt Unidir One max 64 Bytes
■ Control: configuration/command/status type communication
■ Bulk: large amounts of data at highly variable times
■ Isochronous: constant-rate, error tolerant transfers
■ Interrupt: send or receive data infrequently but with bounded service periods
6
USB Tutorial
USB pipes
■ Device address is affected by the host
■ Endpoint configuration depends on the device implementation
■ Time multiplexing of transfer is under host control
Device Address 3
Control Transfer
Bulk IN Transfer Ep0 Disk On Key
Bulk OUT Transfer Ep1
Ep2
Control Transfer
Device Address 4
Interrupt IN Transfer Ep0 Mouse
Ep3
Logical Pipe
7
USB Tutorial
8
USB Tutorial
USB transactions
■ A transfer is composed of one or several transactions
■ Example of control transfer (several transactions)
Setup Stage
Data Stage
Status Stage
9
USB Tutorial
10
USB Tutorial
Endpoint Address
Device Address
PID
Host Token
Data
Device Handshake
11
USB Tutorial
Summary
■ The host affects an address to the device
■ The device has several endpoints
■ To each endpoint corresponds a pipe and a type of transfer
■ Transfer is made of one or several transactions
■ Transactions are composed of 3 packets
Device Transfer
•Device address
Offers Handles
Control Bulk Iso Int
Pipe/Endpoint 2+ 1+ 1+ 1+
•Endpoint number
•Endpoint type Transaction
Token pkt
Data pkt
Handshake pkt
12
USB Tutorial
Control transfer
13
USB Tutorial
USB scheduling(1)
■ USB transfers occurs in a millisecond time-frame window
■ The host sends a Start Of Frame (SOF) Packet at the beginning of
each frame
■ This is the host which starts a transfer with a logical peripheral
■ Transactions are time multiplexed in one or several frames
■ This is the host which do the transaction arbitration
Time
14
USB Tutorial
15
USB Tutorial
Bandwidth
■ Theorically up to 1216 bytes can be transferred through a bulk
endpoint in a frame
■ In practice ~950 bytes
1ms frame
16
USB Tutorial
Device detection
■ The host (hub) downstream port integrates 2 pull-downs
(15Kohms). The bus state is SE0 (DP = DM = 0V)
■ When a device is connected, the bus state is idle (DP = 3.3V DM =
0V). DP is forced by the device pull-up (1.5Kohms).
■ The hub/host detects the port status change and forces a bus
reset to the new device (DP = 0V DM = 0V).
■ Then the host sends requests to the device through the default
control endpoint (endpoint number 0). A newly connected device
address is 0. 3.3V
HOST
1.5 Kohms
DP
15 Kohms DP
DM
DM
15 Kohms
Device
17
USB Tutorial
Enumeration
■ Enumeration is the Process of Assigning Addresses and Setting
Configurations
Host Hub Device
Status Change Connect Cable
Attached
Query Change
Port Enable Powered
Reset Device
Get Device Descriptor via default Pipe and Address Default
Assign a Unique Address
Configured
18
USB Tutorial
Enumeration trace
Default Address, default control endpoint
Enter Address State
19
USB Tutorial
Standard requests
■ A setup transaction includes an 8-byte formatted data packet
21
USB Tutorial
22
USB Tutorial
23
USB Tutorial
Device descriptor
■ The USB Host stacks uses the descriptor retrieved from the device
to find the corresponding driver.
■ Windows looks for a matching Vendor ID/Product ID in its .inf
library
■ If not found, it will search for a matching class driver
■ If not found then it will request the user to insert a CD to install the
corresponding driver
Device Descriptor
24
USB Tutorial
25
USB Tutorial
Objectives
■ Review USB functionalities
■ Be able to read a USB trace
■ Understand the enumeration process
■ Highlight that class drivers are part of the USB success
26
USB Tutorial
What is happening?
27
USB Tutorial
28
USB Tutorial
Answer
Bus Analyzer
Device Nb 3
Device Nb 2
USB Wire
The bus analyzer logs all downstream packets from the host
and only upstream packets from the new device
29