USB - 디에이큐 시스템

Transcription

USB - 디에이큐 시스템
USB 세미나
디에이큐시스템
2011. 11. 30
www.daqsystem.com
[email protected]
1
http://www.daqsystem.com
목 차
USB 소개




USB 개요
USB장치의 구성
개발에 필요한
정보
응용 제품
USB 응용




USB 프로토콜
H/W 설명
Firmware
Driver 구조
2
프로토콜 분석


USB 프로토콜
분석
질의 응답
http://www.daqsystem.com
USB 소개
USB 개요







1981년 IBM PC 발표 (Open Architecture)
i8086, ISA, Serial(RS232), Parallel(Centronics), IDE
Limited Device
1995년 PCI, USB by Intel
ISA -> EISA -> PCI->PCI-X (VESA, AGP, PCI-Express)
PCMCIA->Card bus
RS232,Parallel -> USB(Serial, Power, Speed, Device, PnP
Hot-plug)
3
http://www.daqsystem.com
4
http://www.daqsystem.com
USB 장치의 구성
5
http://www.daqsystem.com
 Host
- Over all management of USB bus
- Enumeration
- Device management
 Cable
Upstream B
Downstream A
6
http://www.daqsystem.com
 Device
- Add functional capability to Host
- Single upstream connection
- Data terminal (create or consume)
 Hub
- A Device has more usb ports
- Can connect more device through a usb port
7
http://www.daqsystem.com
 Feature
- Hot swap (do not require system re-booting)
- Maximum 127 Device
- High speed data rate(480Mbps, USB2.0 HS)
12Mbps(Full speed), 1.25Mbps(Low speed)
- Bus-powered operation(Max 500mA per a Device)
- 4-wire serial interface(+5V, GND, D+, D-)
- Power management(Power-saving, sleep mode)
8
http://www.daqsystem.com
9
http://www.daqsystem.com
개발에 필요한 정보
•
•
•
•
•
•
•
•
Device Functionality
Performance requirement (throughput)
Host system(PC, Operating system, Driver)
Power consumtion
USB support chip (Microcontroller, stand alone)
Chip manufacture
(Cypress, Philips, NS, Atmel, TI, Samsung, Microchips,
SMSC, Winbond, ST, Point chips etc.)
Development S/W (OS, Driver, Firmware, Compiler)
Protocol Monitoring
10
http://www.daqsystem.com
 응용 제품 1
카메라
지문인식
허브
모뎀
신서사이저
튜너
저장장치
카메라
11
http://www.daqsystem.com
 응용 제품 2
센서
GPIB
조이스틱
I/O expander
메모리리더
전화기
키보드
휴대폰
12
http://www.daqsystem.com
USB 응용
USB 프로토콜
 Topology
13
http://www.daqsystem.com
 Physical
14
http://www.daqsystem.com
 Signaling
15
http://www.daqsystem.com
IDLE
J state
K State
: D+(High), D-(Low)
: D+(High), D-(Low) after SOP
: D+(Low), D-(High)
16
http://www.daqsystem.com
17
http://www.daqsystem.com
 Device Detect
18
http://www.daqsystem.com
 Packet Type
PID Value
Packet Type
Packet Category
0101
SOF
Token
1101
SETUP
Token
1001
IN
Token
0001
OUT
Token
0011
DATA0
Data
1011
DATA1
Data
0111
DATA2
Data
1111
MDATA
Data
0110
NYET
Handshake
0010
ACK
Handshake
1010
NAK
Handshake
1110
STALL
Handshake
1100
ERR
Special
1100
PRE
Special
1000
SPLIT
Special
0100
PING
Special
19
http://www.daqsystem.com
•
•
•
•
Token ( For Device setup)
Data (Data Transmission)
Handshake (data acknowledgement)
Special
- PRE (For low-speed connection)
- SPILT/PING (For HS transaction)
20
http://www.daqsystem.com
 Packet Type
Type
Important Attributes
Maximum Size
Example
Interrupt
Quality
1024/64/8
Mouse, Keyboard
Bulk
Quality
512/64
Printer, Scanner
HDD
Isochronous
Time
1024/1024
Video, Audio
Control
Time and Quality
64/64/8
Device control
21
http://www.daqsystem.com
 H/W 설명
 USB I/O Device
22
http://www.daqsystem.com
Anchor Chips(Cypress) Ez-usb chip
23
http://www.daqsystem.com
24
http://www.daqsystem.com
 Firmware
25
http://www.daqsystem.com
Configuration0
Interface0
USB
Device
End Point0
End Point1
Other Interfaces
Interface1
Other Interfaces
Configuration1
Interfaces
Other Configurations
26
http://www.daqsystem.com
27
http://www.daqsystem.com
 Driver
USB Application
USB Application
HIDCLASS.SYS
HIDUSB.SYS
USBHUB.SYS
User Mode
Kernel Mode
USBD.SYS
UHCD.SYS
OpenHCI.SYS
PCI Enumerator
Physical Interface(Cable)
28
http://www.daqsystem.com
Host
Root Hub
HUB
HUB Keyboard
Speaker
Printer
Disk
2 types of peripherals:
- HUB
- Function
- Up to 127 peripherals
A master/slave architecture
USB 2.0 spec supercedes USB 1.1 spec
- USB 2.0 LS (  USB1.1 at 1.5Mbps)
- USB 2.0 FS (  USB 1.1 at 12Mbps)
- USB 2.0 HS (480 Mbps)
Power Management
- Different device class: bus powered or self powered
- Vbus > 4.35V. 100mA, (500mA after negociation),
500uA in suspend mode
- Host disables power to ill-behaved peripherals
29
http://www.daqsystem.com
•
The Transaction Protocol is Host Based
•
Host based token polling
– Data from host-to-function and function-to-host
– Host handles most of the protocol complexity
– Peripheral design is simple and low-cost
Robustness
– Handshake to acknowledge data transfer and flow control
– Very low raw physical bit error rate (< 10 –10)
– CRC protection plus hardware retry option
– Data toggle Sequence bits
Bounded transfer characteristics
– Data transfer bandwidth and latency prenegociated
– Flow control for peripheral buffer management
No asynchronous message/interrupt from the peripheral
•
•
•
30
http://www.daqsystem.com
• USB Topology
•
•
A unique device address is assigned to each USB device
Physical tiered start network:
HOST
Hub
Root Hub
Keyboard
@: 3
Mouse
@: 4
IP phone
@: 5
Root Hub
@: 1
Hub
@: 2
Dok
@: 3
Mouse
@: 4
IP phone
@: 5
Keyboard
@: 6
@: 2
@: 1
USB cable
Dok
@: 6
Logical network:
HOST
A driver has no information on the
topology of the physical network
HUB Driver
MSD Driver
Audio Driver
HID Driver
Logical link
Each device sees all traffic generated by the host
A device does not see data sent by another peripheral
31
http://www.daqsystem.com
• 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
Control
Bulk
Isochronous
Interrupt
Direction
Bidir
Unidir
Unidir
Unidir
Packets per frame
Several
Several
One
One max
M ax Packet Size
64 Bytes
64 Bytes
1024 Bytes
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
32
http://www.daqsystem.com
• USB pipes
• Device address is affected by the host
• Endpoint configuration depends on the device implementation
• Time multiplexing of transfer is under host control
Control Transfer
Bulk IN Transfer
Bulk OUT Transfer
Control Transfer
Interrupt IN Transfer
Host
Control Transfer
Iso IN Transfer
Iso OUT Transfer
Control Transfer
Interrupt IN Transfer
33
Device Address 3
Ep0
Disk On Key
Ep1
Ep2
Device Address 4
Mouse
Ep0
Ep3
Device Address 5
Ep0
IP Phone
Ep1
Ep2
Device Address 2
Hub
Ep0
Ep1
http://www.daqsystem.com
• Example of USB controller
34
http://www.daqsystem.com
•
USB transactions
•
•
A transfer is composed of one or several transactions
Example of control transfer (several transactions)
Setup Stage
Data Stage
Status Stage
Example of bulk transfer (one transaction)
35
http://www.daqsystem.com
•
USB Transactions (1)
•
A transaction is made of 3 packets
– Token: device address, endpoint number, transfer type
– Data : data to be sent
– Handshake: acknowledge
Token
Data Transfer
Example of bulk transaction:
•
36
Handshake
http://www.daqsystem.com
•
USB Transactions (2)
•
Example of bulk OUT transaction:
Token
Data Transfer
Handshake
Endpoint Address
Device Address
PID
Host
Token
Data
Device
Handshake
37
http://www.daqsystem.com
•
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
Transfer
Device
•Device address
Offers
Handles
Pipe/Endpoint
Control
2+
•Endpoint number
•Endpoint type
Bulk
Iso
1+
1+
Int
1+
Transaction
Token pkt
Data pkt
Handshake pkt
38
http://www.daqsystem.com
• Control transfer
The device is not ready…
The device does not
acknowledge the transaction
The host retries…
The device has
Acknowledged the transaction
39
http://www.daqsystem.com
•
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
SOF
@5
@3
@6
SOF
@5
@6
@6
SOF
@5
@2
SOF
Time
A 1ms USB Frame
-Host handles most of the protocol complexity
-Peripheral design is simple and low-cost
40
http://www.daqsystem.com
• USB scheduling (2)
• The bus allocation depends on the host controller
• A constant interval width is allocated to isochronous and interrupt
transfer
• A minimum interval width is reserved for control transfer
• The rest of interval is for bulk transfer
Valible width
Control
transfers
Variable width
Fixed width
Iso + Interrupt transfer
Bulk transfer
-A host can refuse a new peripheral which requests large
isochronous transfer size
-Such peripheral offers several configurations
41
http://www.daqsystem.com
• Bandwidth
• Theorically up to 1216 bytes can be transferred through a bulk
endpoint in a frame
• In practice ~950 bytes
1ms frame
42
http://www.daqsystem.com
•
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
43
http://www.daqsystem.com
•
Enumeration
•
Enumeration is the Process of Assigning Addresses and Setting Configurations
Host
Hub
Device
Connect Cable
Status Change
Attached
Query Change
Powered
Port Enable
Reset Device
Get Device Descriptor via default Pipe and Address
Default
Assign a Unique Address
Read all Configuration Information
Addressed
Configure and Assign Configuration Value
Configured
44
http://www.daqsystem.com
•
Enumeration trace
Default Address, default control endpoint
Enter Address State
Enter Configured State
45
http://www.daqsystem.com
•
USB Device State
After 3ms of bus inactivity
the device must enter Suspended state and drain less
than 500uA
46
http://www.daqsystem.com
•
Standard requests
•
A setup transaction includes an 8-byte formatted data packet
n
Standard requests are defined in Chapter 9 of the USB spec
47
http://www.daqsystem.com
• Device USB driver components
USB Device driver API
Power
Management
Attach/
Detach
Processing
Clock
Registers
Pull-Up
Resistor
Status
&
Control
Control Protocol
Endpoint Data
•Standard Requests
•Class Requests
•Vendor Requests
•Transfer Protocols
Bulk In/Out
•Isochronous In/Out
•Interrupt In/Out
USB Controller
Registers
48
Endpoint FIFO
Registers
http://www.daqsystem.com
•
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
Configuration Descriptor
Interface Descriptor
Endpoint
Descriptor
Endpoint
Descriptor
Configuration Descriptor
Interface Descriptor
Interface Descriptor
Endpoint
Descriptor
Endpoint
Descriptor
49
Endpoint
Descriptor
Endpoint
Descriptor
http://www.daqsystem.com
•
USB class drivers
•
Building on top of the USB specifications, there are Device Class Specifications
from the Device Working Group
Matching device class requirements allow use of standard host class drivers
provided by Windows or Linux
Each class driver specifies the endpoint configurations required
Existing class drivers:
– Audio class (speakers, …)
– HID (keyboard, mouse, …)
– Mass Storage (disk on key)
– Printer class
– Smart Card CCID
– Communication Data Class
– …
•
•
•
50
http://www.daqsystem.com
Thanks!
51
http://www.daqsystem.com

Similar documents

Mobile RFID Technologies and Standards

Mobile RFID Technologies and Standards Interconnection – Procedures for the operation of OSI Registration Authorities: Registration of object identifier arcs for applications and services using tag-based identification  X.672 | ISO/IEC...

More information