VARUN K
varunkpa@gmail.com
OVERVIEW
• Industrial standard developed in 1990s.
• Cable + connector + communication protocol
• Developed by group of seven companies-
Compaq, DEC, IBM, Intel, Microsoft, NEC and
Nortel.
• Packet based architecture with start
frame,transactions,ACK and NAK controls.
FEATURES OF USB
• Ease of Use
1.
SOME USB KEY TERMS
FEATURES
• 2 CONTROLLERS USB controller+ Root Hub.
• USB controller: Formats the data for the operating
system on read and write.
• Root Hub: connection point to the host.
• Host is always the reference
• IN: Host is going to receive the data; OUT: Host is
going to send the Data.
• 3layers:Lower,Middle,Upper
USB LOWER
LAYER
D+>D- =>Enumeration happen at
full speed, or vice versa
EXAMPLE :SET UP
TRANSACTION
TOKEN PACKET
DATA PACKET
HAND SHAKE
PACKET
PID+ADDRESS+END POINT NO
SUCCESS/FAILURE
HOST WANTS TO
READ/WRITE
USB
MIDDLEWARE
ENUMERATION
• Before the application can communicate with the device host
needs to learn about the device and has to assign the device
diver
• Assigning address to the device-reading descriptors from the
device-assigning and loading drivers-selecting
configuration(Device power requirement, end point).Then
device will be ready for data transfer with any of the
endpoint.
• Duty of HUB: detect attachment and removal using IN end
points. Host polls the root hub to find any device is
connected. After boot up also it continues the poll to find any
newly attached device.
ENUMERATION (cont..)
• Standard USB request: Host sends series request to the
device HUB .They are followed by control transfers. Endpoint
0.
• For a user enumeration process is completely invisible. But
get announcement of detection of new devices.
• When the enumeration is over OS adds new devices to
DEVICE MANAGER list in the control panel. When the user
removes device from the bus windows removes the device
from the device manager.
DESCRIPTORS
Data structures or formatted block of
information which enable the host to learn about
the device.
The device must store information in the
descriptors and should respond for standard USB
requests
Classification of Descriptors:
I. Device
II. Configuration
III. Interface
IV. Endpoint
bLength:The length of the bytes in the descriptor
bDescriptortype: 01H for the device descriptor
bcdUSB:The USB specification version that the device and its descriptor
supports currently.1.00100h;1.10110h
Idvendor:deivce manufacturer uses unique id to identify the device by
paying money.The host may have an INF file which contains this value to
load the drivers.
idProduct:The owner of the vendor ID assigns product id to identify the
device.
bcdDevice:it is the device release No.
iManufacturer:Index which points to a string describing the manufacturer
IdProduct:Index points a string describing the product.
iSerailNo: ’0’ Device with no serial No
To identify if the user has more than one identical device on
the bus
bNumconfigurations:The no of configurations that the device supports.
bMax Packet0:The maximum packet size for end point 0
LS:8 bytes;FS:8/16/32/64;HS:64
Device Class, Device Subclass
: The devices whose function is defined at device level, this field
specifies the device class
02h:Communications.
09h:Hub.
E0h:Wireless controller.
Device Protocol: It specifies protocol defined by selected class or
subclass
E.g.: What kind of transfer is going currently
ENUMERATION STEPS
12 STEP PROCESS
1.USER ATTACH DEVICE TO PORT
• Attachment of USB port to the device or
System power up with a device already
attached
• The port may be on the root hub at a hub
which connects the downstream from the
host
2.HUB DETECTS THE DEVICE
• Hub monitors the voltage on the signal
lines of each of its ports
• If a full speed device is attached D+ is
pulled up to V+
• If a full speed device is attached D- is pulled
up to V+
3.HOST LEARNS ABOUT NEW DEVICE
• Each hub uses its interrupt end point to
report events at the HUB
• Host sends Get_Port_Status request
.The returned information tells new device
is attached.
Get_Port_Status REQ
4.DETECTING … HIGH/LOW SPEED?
• Checks the voltage on D+ and D-
• D+>D- =>full speed device
• Hub sends information in response to
next Get_Port_Status
Get_Port_Status REQ
5.HUB RESETS THE DEVICE
• When the host learns of new device HOST
CONTROLLER send Set_Port_Request
which ask the hub to reset the port
• Port reset within 10 ms
• Reset means D+ and D- ‘0’
• Other USB device may not be affected
Set_Port_Status REQ
6.HOST CHECKS FULL SPEED DEVICE
SUPPORTS HIGH SPEED
• If the device supports High speed after
reset It will send chirp “K”
• A high speed capable hub detects the
chirp and responds with a series of
alternating chirp “J” &” K”.
• Device detects KJKJ..removes full speed
pull up, enumeration starts at high speed.
• If the Hub is not responding continues at
full speed
7.HUB ESTABLISHES A SIGNAL PATH
B/W DEVICE AND BUS
• Verification of reset state by sending
Get_Port_Status request
• Hub removes the reset  Default state
• USB registers are at reset state, Device is
ready for control transfer with endpoint 0.
• Device communicates to host using Default
address 00h.
• Can draw up to 100mA.
Get_Port_Status REQ
8.HOST SEND GET_DISCRIPTOR TO
LEARN PACKET SIZE OF THE DEFAULT
PIPE.
• Host sends request to device address
endpoint 0
• Enumeration of only one device at a time;
one device will respond if multiple devices.
• 8Th byte of the device descriptor contains
maximum packet size supported by
endpoint 0.
• After receiving one packet ,OS requests 64
bytes.
• Host begins status stage transfer
9.HOST ASSIGNS ADDRESS TO THE
DEVICE
• Host assigns a unique address to the
device by sending a set_Address
request.
• The device completes status stage of
request using default address-
Implementation of new address.
• Address is valid until the device is
detached, port is reset, system reboots.
• Next enumeration  new address.
Set_Address
10.HOST LEARNS ABOUT THE DEVCIE
ABILITY
• To read device descriptor Host sends
get_Discriptor request
• Request for the configuration descriptor
11.THE HOST ASSIGNS & LOADS
DEVICE DRIVER
• Tries to match PC,INF files with vendor
ID, Product ID &release No retrieved
from device
• If no match windows look class, subclass
& protocol values from device. If no
match user has to browse it externally.
• If already enumerated windows look
registry file instead of .INF file
• Once the driver is obtained it is installed.
After installation driver may request the
device to resend descriptors or other
class descriptors.
12.THE HOST DEVICE DRIVER SELECTS
A CONFIGURATION
• Device driver request configuration
by sending set configuration request .
• The device reads the request and
enables the requested configuration.
• The device is in the configured states
and interfaces are enabled.
USB Universal Serial Bus
USB Universal Serial Bus

USB Universal Serial Bus

  • 1.
  • 2.
    OVERVIEW • Industrial standarddeveloped in 1990s. • Cable + connector + communication protocol • Developed by group of seven companies- Compaq, DEC, IBM, Intel, Microsoft, NEC and Nortel. • Packet based architecture with start frame,transactions,ACK and NAK controls.
  • 3.
    FEATURES OF USB •Ease of Use 1.
  • 4.
  • 5.
    FEATURES • 2 CONTROLLERSUSB controller+ Root Hub. • USB controller: Formats the data for the operating system on read and write. • Root Hub: connection point to the host. • Host is always the reference • IN: Host is going to receive the data; OUT: Host is going to send the Data. • 3layers:Lower,Middle,Upper
  • 6.
  • 7.
    D+>D- =>Enumeration happenat full speed, or vice versa
  • 11.
    EXAMPLE :SET UP TRANSACTION TOKENPACKET DATA PACKET HAND SHAKE PACKET PID+ADDRESS+END POINT NO SUCCESS/FAILURE HOST WANTS TO READ/WRITE
  • 21.
  • 22.
    ENUMERATION • Before theapplication can communicate with the device host needs to learn about the device and has to assign the device diver • Assigning address to the device-reading descriptors from the device-assigning and loading drivers-selecting configuration(Device power requirement, end point).Then device will be ready for data transfer with any of the endpoint. • Duty of HUB: detect attachment and removal using IN end points. Host polls the root hub to find any device is connected. After boot up also it continues the poll to find any newly attached device.
  • 23.
    ENUMERATION (cont..) • StandardUSB request: Host sends series request to the device HUB .They are followed by control transfers. Endpoint 0. • For a user enumeration process is completely invisible. But get announcement of detection of new devices. • When the enumeration is over OS adds new devices to DEVICE MANAGER list in the control panel. When the user removes device from the bus windows removes the device from the device manager.
  • 25.
    DESCRIPTORS Data structures orformatted block of information which enable the host to learn about the device. The device must store information in the descriptors and should respond for standard USB requests Classification of Descriptors: I. Device II. Configuration III. Interface IV. Endpoint
  • 27.
    bLength:The length ofthe bytes in the descriptor bDescriptortype: 01H for the device descriptor bcdUSB:The USB specification version that the device and its descriptor supports currently.1.00100h;1.10110h Idvendor:deivce manufacturer uses unique id to identify the device by paying money.The host may have an INF file which contains this value to load the drivers. idProduct:The owner of the vendor ID assigns product id to identify the device. bcdDevice:it is the device release No. iManufacturer:Index which points to a string describing the manufacturer IdProduct:Index points a string describing the product. iSerailNo: ’0’ Device with no serial No To identify if the user has more than one identical device on the bus bNumconfigurations:The no of configurations that the device supports. bMax Packet0:The maximum packet size for end point 0 LS:8 bytes;FS:8/16/32/64;HS:64
  • 28.
    Device Class, DeviceSubclass : The devices whose function is defined at device level, this field specifies the device class 02h:Communications. 09h:Hub. E0h:Wireless controller. Device Protocol: It specifies protocol defined by selected class or subclass E.g.: What kind of transfer is going currently
  • 33.
  • 34.
    1.USER ATTACH DEVICETO PORT • Attachment of USB port to the device or System power up with a device already attached • The port may be on the root hub at a hub which connects the downstream from the host
  • 35.
    2.HUB DETECTS THEDEVICE • Hub monitors the voltage on the signal lines of each of its ports • If a full speed device is attached D+ is pulled up to V+ • If a full speed device is attached D- is pulled up to V+
  • 36.
    3.HOST LEARNS ABOUTNEW DEVICE • Each hub uses its interrupt end point to report events at the HUB • Host sends Get_Port_Status request .The returned information tells new device is attached. Get_Port_Status REQ
  • 37.
    4.DETECTING … HIGH/LOWSPEED? • Checks the voltage on D+ and D- • D+>D- =>full speed device • Hub sends information in response to next Get_Port_Status Get_Port_Status REQ
  • 38.
    5.HUB RESETS THEDEVICE • When the host learns of new device HOST CONTROLLER send Set_Port_Request which ask the hub to reset the port • Port reset within 10 ms • Reset means D+ and D- ‘0’ • Other USB device may not be affected Set_Port_Status REQ
  • 39.
    6.HOST CHECKS FULLSPEED DEVICE SUPPORTS HIGH SPEED • If the device supports High speed after reset It will send chirp “K” • A high speed capable hub detects the chirp and responds with a series of alternating chirp “J” &” K”. • Device detects KJKJ..removes full speed pull up, enumeration starts at high speed. • If the Hub is not responding continues at full speed
  • 40.
    7.HUB ESTABLISHES ASIGNAL PATH B/W DEVICE AND BUS • Verification of reset state by sending Get_Port_Status request • Hub removes the reset  Default state • USB registers are at reset state, Device is ready for control transfer with endpoint 0. • Device communicates to host using Default address 00h. • Can draw up to 100mA. Get_Port_Status REQ
  • 41.
    8.HOST SEND GET_DISCRIPTORTO LEARN PACKET SIZE OF THE DEFAULT PIPE. • Host sends request to device address endpoint 0 • Enumeration of only one device at a time; one device will respond if multiple devices. • 8Th byte of the device descriptor contains maximum packet size supported by endpoint 0. • After receiving one packet ,OS requests 64 bytes. • Host begins status stage transfer
  • 42.
    9.HOST ASSIGNS ADDRESSTO THE DEVICE • Host assigns a unique address to the device by sending a set_Address request. • The device completes status stage of request using default address- Implementation of new address. • Address is valid until the device is detached, port is reset, system reboots. • Next enumeration  new address. Set_Address
  • 43.
    10.HOST LEARNS ABOUTTHE DEVCIE ABILITY • To read device descriptor Host sends get_Discriptor request • Request for the configuration descriptor
  • 44.
    11.THE HOST ASSIGNS& LOADS DEVICE DRIVER • Tries to match PC,INF files with vendor ID, Product ID &release No retrieved from device • If no match windows look class, subclass & protocol values from device. If no match user has to browse it externally. • If already enumerated windows look registry file instead of .INF file • Once the driver is obtained it is installed. After installation driver may request the device to resend descriptors or other class descriptors.
  • 45.
    12.THE HOST DEVICEDRIVER SELECTS A CONFIGURATION • Device driver request configuration by sending set configuration request . • The device reads the request and enables the requested configuration. • The device is in the configured states and interfaces are enabled.