micriµm id 221c:usb for embedded systems viewed from the embedded target side christian légaré...

104
Micriµm ID 221C: USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Upload: melvin-roberts

Post on 24-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

ID 221C: USB for Embedded Systems Viewed from the Embedded Target Side

Christian LégaréVice-President

12 October 2010

Version: 1.0

Page 2: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Mr. Christian Légaré

Vice-President

PREVIOUS EXPERIENCE:

Twenty five years in the Telecom industry as an executive, Engineering Manager, Product Manager, and Engineer at various levels

Internation Insstitute of Telecommunication, Schlumberger, Telweb, Mincacom, Alphanet, Teleglobe Canada, Télésystème National, SMIS

I hold an MSEE from the University of Sherbrooke, Québec, Canada

2

Page 3: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm3

USB Products

Page 4: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Our Position

Micriµm is consistently recognized as a leader in embedded

software components. Micriµm products are created for

engineers by engineers and are designed to work with the

resources available on embedded systems.

Micriµm provides you RTOS and Tools. The industry surveys for

the last 5 years position Micriµm as the #2 RTOS vendor.

4

Page 5: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Agenda

Hardware architecture Mechanical specifications Electrical specifications Software specifications Compliance Final comments

5

Page 6: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm6

USB for Embedded Systems

Universal Serial Bus : Serial bus standard to interface devices. Peripheral communication protocol of choice for keyboards, printers, and memories

Automatic error detection and recovery.

Large number of devices. (127)

Replaced RS-232

This document covers USB and differentiate USB Host protocol stack from USB Device protocol stack and On-The-Go. It goes over the design implications and some solutions.

Page 7: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm7

Brief history

1969 Serial port (RS-232C)

1995 The USB consortium is formed by Compaq, DEC, IBM, Intel, Microsoft, NEC and Northern Telecom.

1996 USB 1.0 standard was released. Plug Fest

1999 USB 1.1 was released. Corrected bugs

2000 USB 2.0 was released specifying the implementation of a 480 Mbps bus

2001 USB On-The-Go (OTG) supplement was added which allowed devices to talk to each other

2005 Wireless USB standard was released which is a point to point wireless communications link

2007 USB 3.0 goal is to deliver over 10 times the speed of today’s connection

Page 8: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm8

Architecture topology

• Star network configuration

• Only one host

• Maximum of seven levels of tiers, hub at center

• Host schedules and initiates data transfers.

• Host and hubs provide power to slaves

• Maximum number of devices allowed to connect to the bus is

127

• Devices are referred to as functions

• Three rates: 1.5Mbps (Low), 12Mpbs (Full) & 480Mbps (High)

LS/FS

HS

Tier 1 Tier 2

...

Tier 6 Tier 7

Page 9: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm9

Mechanical specifications

Cable:• Cable is made of 4 28-AWG conductors:

– Vbus Power Red – Gnd Power Black – D+ Data Green – D- Data White

• Data pair is twisted• Maximum cable length is 5 meters• Low speed cables are attached to device

Connector:• Connector Type A connects to host• Connector Type B connects to device• Connector power pins are longer for hot-swap• Mini connectors were added in USB 2.0 and OTG supplement

1 2 3 4

Type A USB Connector

Type B USB Connector

12

3 4

Page 10: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm10

A mini-B plug and receptacle has also been defined as an alternative to the standard B connector on handheld and portable devices. The mini-B connecter has a fifth pin, named ID, but it is not connected.Mini-B Plug and Receptacle Pin Assignments

1 2 3 4 5

Mini-B USB Connector

Mechanical specifications

Page 11: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Contact

Number

Signal

Name

Typical Wiring

Assignment

1 VBUS Red

2 D- White

3 D+ Green

4 ID <10Ω = Micro-A

>100kΩ = Micro-B

5 GND Black

Shell Shield Drain Wire

Micro Plug Pin Assignments

11

OTG connectors

Micro-A USB Connector

Micro-B USB Connector

15

White insulator

15

Black insulator

Page 12: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Serial Interface Engine (SIE)

The complexities and speed of the USB protocol are such that it is not practical to expect a general purpose microcontroller to be able to implement the protocol using an instruction-driven basis.

Dedicated hardware is required to deal with the time-critical portions of the specification, and the circuitry grouping which performs this function is referred to as the Serial Interface Engine (SIE).

12

Page 13: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm13

Electrical specificationsDevice detection

Current is limited to 100mA Either the D+ or the D- line will be pulled high

D+ is high, the device is a full or high speed D- is high, the device is a low speed

High Speed negotiation protocol occurs during the Bus Reset phase After detecting the reset signal, the high speed device will signal the host with a 480 Mbps

chirp

Host Controller Device Controller

Vbus Vbus

D+ D+

D- D-

Gnd Gnd

1.5K

15K 15K

USB Cable

Current Limiter

Page 14: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm14

The USB bus 5V supply is a very attractive feature. A USB device with a single connection is also attractive to the user

Supply voltage can fall to 4.35V at the device When other devices are being plugged, there can be transients lowering

the supply voltage by 0.4V

Devices can be classified as:Bus poweredSelf poweredHybrid powered

Device Powering

Page 15: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Device Powering

Self-powered devices provide power requirements on descriptor (see descriptor in the software section). Initially provides 100mA, this can be increased up to 500mA (high power)

Self-powered hubs have a limitation on self-powered devices of 100mA

A device may draw up to 500mA after it has been configured as a high-power device. Being configured is dependent on the Hub being able to supply 500mA, which implies a self-powered hub. So there is always a degree of uncertainty whether more than 100mA will be available. It is a good design practice to offer the option of external power via a socket on such a device.

Devices requiring more than 500mA are obliged to be self-powered. (It is dangerous to attempt to draw power from two adjacent USB ports using a modified cable. It is not permitted by the specification and can easily damage the ports)

15

Page 16: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Device Powering

There is a suspend mode (no bus activity). In suspend mode, devices consume up to 500µA (where 200 µA already used by the pull up and pull-down resistors)

Devices containing a micro-controller need a sleep mode which meets this requirement. but do not forget that a badly placed resistor can very easily draw current which you hadn't expected. Measure your suspend current with a meter

High power devices (up to 500 mA) with remote wakeup feature enabled are allowed to draw up to 2.5mA during suspend

This suspend condition will occur at least once before the device is configured

16

Page 17: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Hot-Pluggable

Place a capacitance of at least 1uF across Vbus and GND to prevent from flyback voltage when unplugging a cable at the far end from the device

The maximum value of the shunt capacitor across Vbus and GND is limited by the specification to 10uF. This is to avoid other devices to crash because plugging device in, a capacitance between Vbus and GND will cause a dip in voltage across the other ports of the hub

For the same reason, the hub port supply must be bypassed with at least 120uF

17

Page 18: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Self-Powered Devices

If you pull, say D+, high in the absence of Vbus then you will risk faulty operation with On-The-Go hosts

When designing a self-powered device, you must not pull a D+ or D- line above the Vbus voltage supplied. This means that you must sense when Vbus is connected

The D+ or D- resistor should be pulled up to a 3.3V supply derived from Vbus, or controlled by Vbus in such a way that the resistor never sources current to the data line when Vbus is switched off

18

Page 19: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm19

More Power

On-The-Go and Battery Charging Specification both add new powering modes to the USB specification.

Powered USB (aka Retail USB, USB Plus Power, and USB + Power) +5 volts DC at up to 6 amps per connector (up to 30 watts) +12 volts DC at up to 6 amps per connector (up to 72 watts) +24 volts DC at up to 6 amps per connector (up to 144 watts)

Powered USB uses standard USB signaling with the addition of extra power lines for point-of-sale terminals

IBM owns the intellectual rights to Powered USB and charges a licensing fee for its use

Page 20: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm20

Physical layer signaling

Asynchronous communications Differential signal with a 4VDC sweep (300mV HS) Data on the bus is encoded using Non-Return-to-Zero-Inverted (NRZI) Use of bit stuffing to avoid loosing synchronization The bits are transmitted least-significant-bit (LSB) first.

SYNC PATTERN PACKET INFORMATIONIDLE

SYNC PATTERN PACKET INFORMATIONIDLE

SYNC PATTERN PACKET INFORMATIONIDLE

RAW DATA

BIT STUFFED DATA

NRZ ENCODING

Page 21: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Line States

Given that there are just 2 data lines to use, it is surprising just how many different conditions are signaled using them:

21

Bus State Levels

Differential '1' D+ high, D- low

Differential '0' D- high, D+ low

Single Ended Zero (SE0) D+ and D- low

Single Ended One (SE1) D+ and D- high

Data J State:Low-speedFull-speed

 Differential '0' Differential '1'

Data K State:Low-speedFull-speed

 Differential '1' Differential '0'

Idle State:Low-speedFull-speed

D- high, D+- lowD+ high, D- low

Resume State Data K state

Start of Packet (SOP) Data lines switch from idle to K state

End of Packet (EOP) SE0 for 2 bit times followed by J state for 1 bit time

Disconnect SE0 for >= 2us

Connect Idle for 2.5us

Reset SE0 for >= 2.5 us

Page 22: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Detached

When no device is plugged in, the host will see both data lines low, as its 15 kohm resistors are pulling each data line low.

22

Page 23: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Attached

When the device is plugged in to the host, the host will see either D+ or D- go to a '1' level, and will know that a device has been plugged in.

The '1' level will be on D- for a low speed device, and D+ for a full (or high) speed device.

23

Page 24: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Idle

The state of the data lines when the pulled up line is high, and the other line is low, is called the idle state. This is the state of the lines before and after a packet is sent.

24

D+andD-

Idle state

Page 25: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

J and K States

To make it easier to talk about the states of the data lines, some special terminology is used. The 'J State' is the same polarity as the idle state (the line with the pull-up resistor is high, and the other line is low), but is being driven to that state by either host or device.

The K state is just the opposite polarity to the J state.

The J and K terms are used because for Full Speed and Low Speed links they are actually of opposite polarity.

25

Page 26: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

SE0

The Single Ended Zero (SE0) is when both lines are being pulled low.

26

SE0

D+andD-

Page 27: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

EOP signal

The End of Packet (EOP) is an SE0 state for 2 bit times, followed by a J state for 1 bit time.

27

D+andD-

Idle state2 bits

EOP

1 bitLast data bits of packet

Page 28: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Single Ended One (SE1)

This is the illegal condition where both lines are high. It should never occur on a properly functioning link.

28

SE1

D+andD-

Page 29: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Reset

When the host wants to start communicating with a device it will start by applying a 'Reset' condition which sets the device to its default unconfigured state.

The Reset condition involves the host pulling down both data lines to low levels (SE0) for at least 10 ms. The device may recognize the reset condition after 2.5 us.

This 'Reset' should not be confused with a micro-controller power-on type reset. It is a USB protocol reset to ensure that the device USB signaling starts from a known state.

29

D+andD-

Idle stateIdle state>= 10ms

Reset

Page 30: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Suspend

With today’s emphasis on energy saving, the USB suspend mode is very useful. It allows to power down an unused device.

Suspending a device is achieved by not sending anything to the device for 3 ms.

A Start-Of-Frame packet (at full speed, see Packets section) or a Keep Alive signal (at low speed) is sent by the host every 1 ms to keep the device awake.

A suspended device must recognize the resume signal and the reset signal.

30

D+andD-

Idle state Suspended

>= 3ms

Page 31: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Keep Alive Signal

This is represented by a Low speed EOP. It is sent at least once every millisecond on a low speed link, in order to keep the device from suspending.

31

D+andD-

Idle state2 bits

Keep Alive

1 bitIdle state

Page 32: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Resume

When the host wants to wake the device up after a suspend, it does so by reversing the polarity of the signal on the data lines for at least 20ms. The signal is completed with a low speed end of packet signal.

It is also possible for a device with its remote wakeup feature set, to initiate a resume itself. It must have been in the idle state for at least 5ms, and must apply the wakeup K condition for between 1 and 15 ms. The host takes over the driving of the resume signal within 1 ms.

32

D+andD-

2 lowspeedbit time

>= 20 ms

Idle J state

Suspended

Kstate

Idle J state

Resume

1 lowspeedbit time

Page 33: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm33

Data Signaling Rate

Another area which is often overlooked is the tolerance of the USB clocks.

High speed data is clocked at 480.00Mb/s with a data signaling tolerance of ± 500ppm.

Full speed data is clocked at 12.000Mb/s with a data signaling tolerance of ±0.25% or 2,500ppm.

Low speed data is clocked at 1.50Mb/s with a data signaling tolerance of ±1.5% or 15,000ppm.

This allows resonators to be used for low cost low speed devices, but rules them out for full or high speed devices.

Page 34: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm34

Software specificationsUSB Protocols

• Packets• Transfer types• Transactions• Frames• Endpoints• Pipes

Page 35: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Packets

SYNCIDLE PACKET INFORMATION EOP

PID

35

The fundamental element of communications is the packet A packet is made of three parts: START, INFORMATION, and END-OF-PACKET (EOP) At the START of a packet will be a sequence of transitions which is called SYNC The SYNC pattern is a chirp of either 8 bits (full-/low-speed) or 32 bits (high-speed) where

each bit is a J or K state:KJKJKJKJKJKJKJKJKJKJKJKJKJKJKJKJKK

The INFORMATION varies from 1 byte up to 1024 bytes Packet Identifier (PID) – 4bits + complement Payload and CRC – Not present in handshake packets

The EOP is indicated by having both D+ and D- low for 3 bits (full-/low-speed) or 8 bits (high-speed).

Page 36: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsSYNC

SYNC

All packets must start with a SYNC field. The SYNC field is 8 bits long at low and full speed or 32 bits long for high speed and is used to synchronize the clock of the receiver with that of the transmitter. The last two bits indicate where the PID fields starts.

36

Page 37: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsPID

PID

PID stands for Packet ID. This field is used to identify the type of packet that is being sent.

37

Page 38: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsPID

38

Group PID Value Packet Identifier

Token 0001 OUT

1001 IN

0101 SOF (Start of frame)

1101 SETUP

Data 0011 DATA0

1011 DATA1

0111 DATA2

1111 MDATA

Handshake 0010 ACK

1010 NAK

1110 STALL

0110 NYET (No Response Yet)

Special 1100 PRE (Host-issued preamble. Enables downstream bus traffic to low-speed devices)

1100 ERR (Split Transaction Error Handshake (reuses PRE value))

1000 SPLIT (High-speed Split Transaction Token)

0100 PING (High-speed flow control probe for a bulk/control Endpoint)

0000 Reserved

The first 2 bits of a Token which are transmitted determine which of the 4 groups it falls into. SOF is officially considered to be a Token PID. Bits are transmitted LSB first.

Page 39: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsPID

The first byte in every packet is the Packet Identifier (PID) byte. This byte needs to be recognized quickly by the USB controller. This is why it is not included in any CRC checks. It has its own validity check.

There are 4 bits to the PID. The check method uses the PID 4 bits by repeating and complementing them, making an 8 bit PID field in total.

39

PID0 PID1 PID2 PID3 nPID0 nPID1 nPID2 nPID3

PID shown in transmission order, LSB first.

Page 40: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsADDR

ADDR

The address field specifies which device the packet is designated for. Being 7 bits in length allows for 127 devices to be supported. Address 0 is not valid, as any device which is not yet assigned an address must respond to packets sent to address zero.

40

Page 41: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsENDP

ENDP

The endpoint field is made up of 4 bits, allowing 16 possible endpoints. Low speed devices, however can only have 2 additional endpoints on top of the default pipe. (4 endpoints max)

41

Page 42: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Cyclic Redundancy Code (CRC)

A CRC is a value calculated from a number of data bytes to form a unique value which is transmitted along with the data bytes, and then used to validate the correct reception of the data

USB uses two different CRCs a 5 bits long (CRC5)

and a 16 bits long (CRC16)

The USB specification contains all the details for the algorithms used to compute the CRCs

42

Page 43: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet FieldsEOP

EOP

End of packet. Signalled by a Single Ended Zero (SE0) for approximately 2 bit times followed by a J for 1 bit time.

43

Page 44: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Packet Types

USB has four different packet types.

Start of Frame Packets Token Packets Data Packets Handshake Packets & Split Transaction Special Token Packets

44

Page 45: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Start of Frame Packets

PIDFRAME

NUMBERCRC

5SOF

8 11 5

0101

45

Start of frame packets indicate the start of a new frame. The SOF packet consisting of an 11-bit frame number is sent by the host every 1ms ± 500ns on a full speed bus or every 125 µs ± 0.0625 µs on a high speed bus.

The first transaction in each (micro)frame. An SOF allows endpoints to identify the start of the (micro)frame and synchronize internal endpoint clocks to the host.

Page 46: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Token Packets

PID ADDRCRC

5

INOUTSETUP

8 7 5

100100011101

ENDP

4

46

Token packets indicate the type of transaction to follow. They are always the first packet in a transaction, identifying the targeted endpoint, and the purpose of the transaction.

There are three types of token packets: In

Informs the USB device that the host wishes to read information.

Out

Informs the USB device that the host wishes to send information.

Setup

Used to begin control transfers.

Page 47: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Data Packets

Data packets contain the payload.There are two types of data packets each capable of transmitting up to 1024 bytes of data.

Data0 Data1

DATA0 and DATA1 PIDs are used in Low and Full speed links as part of an error-checking system.

When used, all data packets on a particular endpoint use an alternating DATA0 / DATA1 so that the endpoint knows if a received packet is the one it is expecting. If it is not the expected packet, it will still acknowledge (ACK) the packet as it is correctly received, but will then discard the data, assuming that it has been re-sent because the host missed seeing the ACK the first time it sent the data packet.

47

PID PAYLOAD DATA CRC16

DATA0DATA1DATA2MDATA

8 0 to 1024 16

0011101101111111

Page 48: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Data Packets

PID PAYLOAD DATA CRC16

DATA0DATA1DATA2MDATA

8 0 to 1024 16

0011101101111111

48

High Speed mode defines another two data PIDs, DATA2 and MDATA.

DATA2This data packet token has been added as part of a system for controlling multiple isochronous IN

packets during one microframe at high speed. For each isochronous IN packet requested, the suffix of the DATAx PID represents the remaining number of packets to be transferred during the current micro-frame.

MDATAThis data packet token has been added as part of a system for controlling multiple isochronous OUT

packets during one microframe at high speed. All but the last packet sent during a microframe use the MDATA PID. The last packet sent uses DATA0, DATA1 or DATA2 depending on whether one, two or three packets were sent.

Page 49: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

DATA packets

Isochronous IN When requesting IN transactions, the device packages them in

DATA2, DATA1 or DATA0 packets, depending on how many packets per microframe are specified, and which one it is.

49

One transaction per microframe

Two transactions per microframe

Three transactions per microframe

DATA0

DATA0

DATA0

DATA1

DATA1DATA2

Page 50: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

DATA packets

Isochronous OUT When sending OUT transactions, the host packages them

either in MDATA or DATA0 or DATA1 or DATA2 packets.

50

One transaction per microframe

Two transactions per microframe

Three transactions per microframe

DATA0

DATA1

DATA2

MDATA

MDATA MDATA

Page 51: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Handshake Packets

PID

8

ACKNAKSTALLNYET

0010101011100110

51

Handshake packets are used for acknowledging data or reporting errors. There are three type of handshake packets which consist simply of the PID.

ACKAcknowledgment that the packet has been successfully

received. NAK

Reports that the device temporary cannot send or received data. Also used during interrupt transactions to inform the host there is no data to send.

STALLThe device finds itself in a state that requires intervention

from the host. NYET

The device is not ready to answer.

Page 52: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Split Transaction Special Token Packets

PID

8

SPLIT 1000HUB

ADDRCRC

5

7 5

SC PORT SE

ET

71 1 1 2

52

The split transaction token is used to support split transactions between the host controller communicating with a hub operating at high speed with full-/low-speed devices to some of its downstream facing ports.

Page 53: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Maximum data packet size

53

Transfer Type Attributes High Speed

Full Speed

Low Speed

Examples

Control Quality + time 64 8,16,32 or 64 8 System control

Bulk Quality <512 8,16,32 or 64 NA Printer, scanner

Interrupt Quality + time <1024 <64 8 Mouse, keyboard

Isochronous Time <3072 <1023 NA Audio, video

Enpoints have several attributes in addition to their type. One of them being the maximum quantity of data that the endpoint can provide or consume in a single transaction.

A single transfer can involve less than the maximum quantity of data an endpoint can handle.

Page 54: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Hierarchy of data

Packet Token: OUT, IN, SOF, SETUP Data: DATA0, DATA1 Handshake: ACK, NAK, STALL, NYET Special: PRE, ERR, SPLIT, PING

54

Transfer (Control, Interrupt, Isochronous, Bulk)

Transaction 1Transaction

2Transaction 3 Transaction n…..

Packet 1 Packet 2 Packet 3 Packet 1 Packet 2 Packet 1 Packet 2… … …

Page 55: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Transactions

Each USB transaction consists of a Token Packet (Header defining what it expects to follow), an Optional Data Packet, (Containing the payload) and a Status Packet (Used to acknowledge transactions and to provide a

means of error correction)

A successful transaction is a sequence of three packets which performs a simple but secure transfer of data.

For IN and OUT transactions used for isochronous transfers, there are only 2 packets; the handshake packet on the end is omitted. This is because error-checking is not required.

There are three types of transaction: SETUP, IN and OUT.

55

Page 56: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Frames

All USB communication links are broken into frames The first packet of each frame is the Start-Of-Frame packet (SOF) A frame is transmitted every 1 ms in low and full speed At high speed the 1 ms frame is divided into 8 microframes of 125 us.

A SOF is sent at the start of each of these 8 microframes, each having the same frame number, which then increments every 1 ms. A high-speed microframe is 125µs to minimize the buffer requirement

On a low speed link, to preserve bandwidth, a Keep Alive signal is sent every millisecond, instead of a Start of Frame packet. In fact Keep Alives may be sent by a hub on a low speed link whenever the hub sees a full speed token packet.

56

Page 57: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Bandwidth Management

The host is responsible in managing the bandwidth of the bus. No more than 90% of any frame to be allocated for periodic transfers

(Interrupt and Isochronous) on a full speed bus. (80% in high speed)

In a highly saturated bus with periodic transfers, the remaining 10% is left for control transfers and once those have been allocated, bulk transfers will get its slice of what is left.

57

Page 58: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Bandwidth Management

PID PAYLOAD DATA CRC16

PIDSYNCEOP

PIDADDR

CRC5

ENDP

SYNCEOP

HANDSHAKE PACKET

DATA PACKETSYNCEOP

TOEKN PACKET

TOEKN PACKET … DATA PACKET(S) ...HANDSHAKE

PACKET

TRANSACTION 1 TRANSACTION 2 ………………….. TRANSACTION N

1 ms 1 ms 1 ms

58

All USB transactions are performed in 1mSec frames initiated by the Host. Time Division Multiplexing is used to separate packets or transactions from different sources within each frame.

Page 59: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm59

Protocol AnalyzerStrongly recommended

Page 60: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Endpoints

All packets are sent to and received by the device via endpoints.

Endpoints are buffers where a device either puts or gets data

Each endpoint has a direction, IN or OUT and an address

Up to 16 endpoints can reside within a device A device can have up to 16 OUT and 16 IN endpoints with each its

buffer The endpoint direction is implicit in the PID.

– OUT and SETUP PIDs refer to the OUT endpoint– IN PID refers to the IN endpoint.

Endpoint 0 is always the control endpoint

60

Page 61: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Pipes

A Pipe is a logical connection between a source or destination on the host and endpoint(s) on a device.

USB defines two types of pipes

Stream Pipes No defined USB format: an application can send any type of data down a stream pipe

and can retrieve the data out the other end. Data flows sequentially. Pre-defined direction for data: IN or OUT. Support bulk, isochronous and interrupt transfer types. Controlled by the host or the device.

Message Pipes Well-defined USB format. Controlled by the host : host initiates a request for the device. Data is then transferred

in the desired direction, dictated by the request. Data can flow in both directions. Only support control transfers.

61

Page 62: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Endpoints and Pipes

62

I/O Device

Configuration 1

PC Host

Application Program

I/O Manager

Device Driver 1 Device Driver 2

Real World

User

Kernel

Interface 2Interface 1

INEndPoint

OUTEndPoint

INEndPoint

OUTEndPoint

ControlEndPoint

Configuration 2

Interface 2Interface 1

INEndPoint

OUTEndPoint

INEndPoint

OUTEndPoint

Data P

ipe

Data P

ipe

Control P

ipe

Page 63: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Transfers types

63

A transfer is made of one of more transactions

Transfers type Description

Control Is non-periodic. It is used mostly for commands and status operations. Mandatory using Endpoint 0 OUT and Endpoint 0 IN.

Isochronous Has a fixed number of bytes per frame. The bandwidth is guaranteed. No error-checking

Interrupt Is periodic and the latency between transactions is guaranteed. Error-free and low throughput

Bulk Is not periodic and it is used mostly to transfer large amounts of data. Error-free high volume throughput when bandwidth available

Page 64: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB's actual throughput

Function of: target device's ability to source or sink data, the bandwidth consumption of other devices on the bus, and the efficiency of the host's USB software stack.

Assuming Host and Device CPU can follow line speed, it is a function of: Transfer type and Signaling rate

(In practice, most hosts can reach the maximum isochronous and interrupt bandwidths with a single target endpoint. With bulk transfers, typical transfer rates are around 900kb/s to a single endpoint, increasing to near ideal transfer rates with multiple endpoints.)

64

Page 65: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Transfer impacts on communication flow

Each transfer type determines various characteristics of the communication flow including the following:

Data format imposed by the USB Direction of communication flow Packet size constraints Bus access constraints Latency constraints Required data sequences Error handling

The designers of a USB device choose the capabilities for the device’s endpoints.

65

Page 66: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Table Calculation for the transfer impacts

Each table shows: The protocol overhead required for the specific transfer type (and speed) For some sample data payload sizes:

The maximum sustained bandwidth possible for this case The percentage of a (micro)frame that each transaction requires The maximum number of transactions in a (micro)frame for the specific case The remaining bytes in a (micro)frame that would not be required for the specific case The total number of data bytes transported in a single (micro)frame for the specific case

A transaction of a particular transfer type typically requires multiple packets. The protocol overhead for each packet includes: a 8-bits (FS/LS) or 32-bits (HS) SYNC field a PID byte A 3-bits (FS/LS) or 8-bits (HS) EOP In a token packet: endpoint number + device address + CRC5 = 16 bits In a data packet: 16-bits CRC16 + any data field (8 bits per byte) For transaction with multiple packets, the inter packet gap or bus turnaround time

required.

For these calculations, there is assumed to be no bit-stuffing required.

66

Page 67: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Low-speed Control Transfer Limits

67

Page 68: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Full-speed Control Transfer Limits

68

Page 69: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

High-speed Control Transfer Limits

69

Page 70: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Full-speed Isochronous Transaction Limits

70

Page 71: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

High-speed Isochronous Transaction Limits

71

Page 72: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Low-speed Interrupt Transaction Limits

72

Page 73: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Full-speed Interrupt Transaction Limits

73

Page 74: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

High-speed Interrupt Transaction Limits

74

Page 75: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Full-speed Bulk Transaction Limits

75

Page 76: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

High-speed Bulk Transaction Limits

76

Page 77: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Enumeration

Once the device is attached, enumeration starts Host requests a number of data structures called

descriptors Enumeration occurs on the default endpoint Host assigns a unique 7-bit address to the device

77

Device attachment

Reset device

Get device descriptor

Assign address

Get configuration descriptor

Get other descriptors

Select device driver

Page 78: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Descriptors

Describes attributes about the peripheral Peripherals typically have more than one descriptor It is typically stored in an EEPROM in the device’s

circuit There are few types of descriptors:

Standard Class Vendor

Among the standard descriptors: Device descriptor - general information about

device Configuration descriptor - device configuration Interface descriptor – number of endpoints Endpoint descriptor - properties of an endpoint

78

Device Descriptor:bcdUSB: 0x0110bDeviceClass: 0x00bDeviceSubClass: 0x00bDeviceProtocol: 0x00

bMaxPacketSize0: 0x08 (8)idVendor: 0x058FidProduct: 0x9380bcdDevice: 0x0100iManufacturer: 0x01iProduct: 0x02iSerialNumber: 0x00bNumConfigurations: 0x01

ConnectionStatus: DeviceConnectedCurrent Config Value: 0x01Device Bus Speed: FullDevice Address: 0x04Open Pipes: 2

Endpoint Descriptor:bEndpointAddress: 0x01Transfer Type: Bulk

wMaxPacketSize: 0x0040 (64)bInterval: 0x00

Endpoint Descriptor:bEndpointAddress: 0x00

Transfer Type: ControlwMaxPacketSize: 0x0507 (1287)

wInterval: 0x0282bSyncAddress: 0x40

Page 79: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Enumeration

79

Device Descriptor

Configuration Descriptor 1

Configuration Descriptor 2

Configuration Descriptor n…

Interface 0 Descriptor

Interface 1 Descriptor

Endpoint Descriptor 1

Endpoint Descriptor 2

Endpoint Descriptor 1

Endpoint Descriptor 2

Interface 0 Descriptor

HID Descriptor

Endpoint Descriptor 1

Configuration Descriptor 1

wTotalLength

Configuration Descriptor 2

wTotalLength

General

HID

Page 80: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

HID Enumeration

80

USB Host(PC) MCU

CONTROL pipe

INTERRUPT-IN pipe

Request for Device Descriptor

Reply with Device Descriptor

Request for Configuration DescriptorRequest for Report Descriptor

Reply with Configuration Descriptor(s)Reply with Interface Descriptor(s)Reply with Endpoint DescriptorReply with Report Descriptor

Set Configuration

IN Packet

IN Report

Reply with HID Descriptor

HID Driver

Endpoint 0 (EP0)CONTROL endpoint

Endpoint 3 (EP3)INTERRUPT-IN endpoint

Connect USB cable

Page 81: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Device Driver

The loading of the appropriate driver is done using a PID/VID (Product ID/Vendor ID) combination.

Abstract from a .inf file:

[DeviceList]%USB\VID_8765&PID_1234.DeviceDesc%=USBBulkInstall, USB\VID_8765&PID_1234

81

Page 82: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Functions i.e. Classes

The USB standard makes references to USB functions which can be seen as USB devices which provide a capability or function such as a Printer, Mass Storage Drive, Scanner, Modem or other peripheral.

In Software, Classes implements the Functions.

82

Page 83: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Classes

Class Name Examples

Audio Speakers, microphones

Mass Storage Hard drives, flash drives, CD-ROMs

Human Interface Devices (HID) Keyboard, mouse, digital I/O

Communication Modems

Video Video cameras

Printer

83

Currently 18 device classes specified by the USB specification Software interfaces for common devices A single device can belong to multiple classes

Page 84: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Mass Strorage Class

USB Cable

Device

USB DeviceController

USB DeviceController

Driver

USB DeviceStack

USB MassStorage Class

Deviceapplication

Host

USB HostController

USB HostController

Driver

USB HostStack

USB MassStorage Class

File System

Host application

StorageDevice

Storage Accessfunctions

File System

84

Software Hardware

Page 85: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Control Device Class (CDC)

USB Cable

Device

USB DeviceController

USB DeviceController

Driver

USB DeviceStack

USB CDC ACMClass

Serial Interface

Deviceapplication

Host

USB HostController

USB HostController

Driver

USB HostStack

USB CDC ACMClass

Serial Interface

Host application

85

Software Hardware

Many variants of the CDC Class exist:

• ACM (Abstract Control Model )

• ECM (Ethernet Networking Control Model )

• EEM (Ethernet Emulation Model)

• and others

Page 86: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Control Device Class (CDC)

USB Cable

Device

USB DeviceController

USB DeviceController

Driver

USB DeviceStack

USB CDC ACMRNDIS Class

TCP/IP

Web Server

Host

USB HostController

USB HostController

Driver

USB HostStack

RNDIS overUSB

TCP/IP

Web Browser

86

Software Hardware

Page 87: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB Audio Class

USB Cable

Device

USB DeviceController

USB DeviceController

Driver

USB DeviceStack

USB AudioClass

Sound Manager

Host

USB HostController

USB HostController

Driver

USB HostStack

USB AudioClass

Sound Layer

Hostapplication

MicrophoneSpeaker

Codec Driver

MIDIAudio Interface

87

Software Hardware

Page 88: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Host Stack

88

Application

USB Class API

Class Drivers

USB Host core stack

Host Controller Driver

Host Controller Hardware

Mass storage

HID CDC HubCustom drivers

Kernel A

bstraction

Kernel

Page 89: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Host controller interfaces

USB 1.1 OHCI – Compaq, Microsoft, and National; hardware burden UHCI – Intel, software burden

USB 2.0 EHCI – USB with Intel, simplified software and reduced cost

USB 3.0 SuperSpeed - Hewlett-Packard, Intel, Microsoft, NEC, NXP

Semiconductors and Texas Instruments November 17, 2008 The first certified USB 3.0 consumer products were announced January

5, 2010

Custom Memory map, SPI, etc

89

Page 90: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Host and Root Hub

Root Hub (RH) = embedded hub part of the Host Provides 1 or more attachment points (i.e. ports) Equivalent to external Hub

– Presents standard hub functions

– Presents standard states as other USB devices

Responsible for:– Device connection/disconnection

– Device reset

– Port power

90

Compound Device

HostRoot Hub

Device Device

DeviceDevice

Device

DeviceDevice

Hub Hub

Page 91: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Host and Root Hub

Host Controller Driver (HCD) manages the Root Hub according to the

hub-class protocol Some hub features handled in HW Other features in SW

(e.g. standard USB descriptors for the Hub class)

91

PHY

Port 1 Port 2 Port 3 Port 4

Root Hub

Host stack

OHCIHost

Controller

EHCIHost

Controller

Page 92: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Host and Root Hub

When the Host stack starts, the 1st device to be enumerated is always the Root Hub (RH).

During enumeration, the RH returns the Hub descriptor which contains features supported by the RH. bNbrPorts: Number of downstream facing ports that this hub supports

Hub driver (part of Host core layer) will handle hub events: Device attachment/detachment event Port power/enable/reset/suspend events

92

Host stack

Host controller

Hub

Function 1

Function 2

Function 3

Root HubHub descriptor

Enumerating RH

Enumerating Function 1

Enumerating Hub

Hub descriptor

Enumerating Function 2 & 3

bNbrPorts = 2

bNbrPorts = 2

Page 93: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Device Stack

93

Application

USB Class API

Class Drivers

USB Device core stack

Device Controller Driver

Device Controller Hardware

Kernel A

bstraction

Mass storage

HID CDCCustom drivers

Kernel

Page 94: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB On-The-Go

Supplement to USB 2.0 Allows for devices to be host and peripheral New features:

Smaller connectors with an added pin (ID) Tighter power constraints for devices Protocol enhancement for dynamic switching Definition session request protocols (SRP)

94

Page 95: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB On-The-Go

Allows two USB devices to talk without a PC as host.

DRD (Dual Role Devices).

Unique mini-AB receptacle.

OTG High Speed and Full Speed.

Low power requirements on battery powered devices.

95

Page 96: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

USB On-The-Go

96

Application

Device stack

OTG Controller Driver

Host Controller Hardware

Device stack

OTG stack

Device Controller Hardware

Page 97: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Wireless USB

Certified Wireless USB is the new wireless extension to USB that combines the speed and security of wired technology with the ease-of-use of wireless technology

Certified Wireless USB is the first high-speed wireless personal interconnect technology to meet the needs of multimedia consumer electronics, PC peripherals, and mobile devices.

Certified Wireless USB will preserve the functionality of wired USB while also unwiring the cable connection and providing enhanced support for streaming media CE devices and peripherals.

Certified Wireless USB performance is targeted at 480Mbps at 3 meters and 110Mbps at 10 meters.

97

Page 98: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Compliance

The USB organization has created a compliance program

Two main criteria are: checklists and compliance testing

Checklists contain questions relating to a product and its behavior

USB-IF provide a Compliance Program for a small membership fee

Usage of the USB logo requires a product to be compliant

There are a set of registered USB logos which are not interchangeable

98

Page 99: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm99

Renesas offering

SH7722 SH7763 SH7764 SH7760

USB-Device √ √ √

USB-Host √ √ √

SH7705 SH7720 SH7721 SH7727

USB-Device √ √ √ √

USB-Host √ √ √

SH7670

USB-Device √

USB-Host √

SH7203 SH7205

USB-Device √ √

USB-Host √ √

SH7263 SH7265

USB-Device √ √

USB-Host √ √

SH7285 SH7286

USB-Device

USB-Host √ √

H8SX/1653 H8SX/1658R H8SX/1668R H8SX/1663

USB-Device √ √ √ √

USB-Host

H8S/2172

USB-Device √

USB-Host

H8S/2215 H8S/2218

USB-Device √ √

USB-Host

H8S/2472

USB-Device √

USB-Host

M16C/24

USB-Device √

USB-Host

Type a H8S2215

Type b H8S2218

H8S2212

Type c H8S2472

Type d H8SX1653

H8SX1663

H8SX1658R

H8SX1668R

Controller types

78K0/R

USB-Device √

USB-Host

V850Mx V850Jx

USB-Device √ √

USB-Host √ √

RX200 RX600

USB-Device √ √

USB-Host √ √

SH2A SH4A

USB-Device √ √

USB-Host √ √

R8C

USB-Device √

USB-Host

Page 100: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Have Reasonable Expectations

Typical MCU can not keep up with High speed USB controllers.

USB device controllers are sometimes troublesome to port. This is partly because a USB device controller port deals more closely with more complicated hardware than, say,a TCP/IP NIC port.  Partly, this is because USB device controllers are much more various than NICs.

The Device can never initiate a communication.

If using MSD & a file system, either the device or the host (but not both) can access the disk at any time.

100

Page 101: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Summary

Appealing features: Ease of use Bus power Auto-detection and self configuration Expandability Speed Availability of peripherals Flexibility and reliability

The tradeoff is complex implementation and cost

101

Page 102: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

References

Documentation

Universal Serial Bus Specification, Revision 2.0

www.usb.org/developers/docs/usb_20_071607.zip

www.usb.org/developers/onthego/.

USB Design by Example: A Practical Guide to Building I/O Devices by John Hyde

USB Complete by Jan Axelson

Web Sites

www.beyondlogic.org/index.html#USB

www.usb.org

www.everythingusb.com

www.usbman.com

102

Page 103: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm

Questions?

103

Page 104: Micriµm ID 221C:USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

Micriµm