Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

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

2 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

3 Micriµm 3 USB Products

4 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

5 Micriµm Agenda Hardware architecture Mechanical specifications Electrical specifications Software specifications Compliance Final comments 5

6 Micriµm 6 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.

7 Micriµm 7 Brief history 1969Serial port (RS-232C) 1995The USB consortium is formed by Compaq, DEC, IBM, Intel, Microsoft, NEC and Northern Telecom. 1996USB 1.0 standard was released. Plug Fest 1999USB 1.1 was released. Corrected bugs 2000USB 2.0 was released specifying the implementation of a 480 Mbps bus 2001USB On-The-Go (OTG) supplement was added which allowed devices to talk to each other 2005Wireless USB standard was released which is a point to point wireless communications link 2007USB 3.0 goal is to deliver over 10 times the speed of today’s connection

8 Micriµm 8 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)

9 Micriµm 9 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 23 4 Type A USB Connector Type B USB Connector 12 34

10 Micriµm 10 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 12345 Mini-B USB Connector Mechanical specifications

11 Micriµm Contact Number Signal Name Typical Wiring Assignment 1VBUSRed 2D-White 3D+Green 4ID <10Ω = Micro-A >100kΩ = Micro-B 5GNDBlack ShellShieldDrain Wire Micro Plug Pin Assignments 11 OTG connectors Micro-A USB Connector Micro-B USB Connector 15 White insulator 15 Black insulator

12 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

13 Micriµm 13 Electrical specifications Device 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

14 Micriµm 14 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 powered Self powered Hybrid powered Device Powering

15 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

16 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

17 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

18 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

19 Micriµm 19 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

20 Micriµm 20 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.

21 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 StateLevels 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-speed Full-speed Differential '0' Differential '1' Data K State: Low-speed Full-speed Differential '1' Differential '0' Idle State: Low-speed Full-speed D- high, D+- low D+ high, D- low Resume StateData 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 DisconnectSE0 for >= 2us ConnectIdle for 2.5us ResetSE0 for >= 2.5 us

22 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

23 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

24 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+ and D- Idle state

25 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

26 Micriµm SE0 The Single Ended Zero (SE0) is when both lines are being pulled low. 26 SE0 D+ and D-

27 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+ and D- Idle state2 bits EOP 1 bit Last data bits of packet

28 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+ and D-

29 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+ and D- Idle state >= 10ms Reset

30 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+ and D- Idle stateSuspended >= 3ms

31 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+ and D- Idle state2 bits Keep Alive 1 bit Idle state

32 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+ and D- 2 low speed bit time >= 20 ms Idle J state Suspended K state Idle J state Resume 1 low speed bit time

33 Micriµm 33 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.

34 Micriµm 34 Software specifications USB Protocols Packets Transfer types Transactions Frames Endpoints Pipes

35 Micriµm Packets 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).

36 Micriµm USB Packet Fields SYNC 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

37 Micriµm USB Packet Fields PID PID PID stands for Packet ID. This field is used to identify the type of packet that is being sent. 37

38 Micriµm USB Packet Fields PID 38 GroupPID ValuePacket Identifier Token0001OUT 1001IN 0101SOF (Start of frame) 1101SETUP Data0011DATA0 1011DATA1 0111DATA2 1111MDATA Handshake0010ACK 1010NAK 1110STALL 0110NYET (No Response Yet) Special1100PRE (Host-issued preamble. Enables downstream bus traffic to low-speed devices) 1100ERR (Split Transaction Error Handshake (reuses PRE value)) 1000SPLIT (High-speed Split Transaction Token) 0100PING (High-speed flow control probe for a bulk/control Endpoint) 0000Reserved 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.

39 Micriµm USB Packet Fields PID 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 PID 0 PID 1 PID 2 PID 3 nPID 0 nPID 1 nPID 2 nPID 3 PID shown in transmission order, LSB first.

40 Micriµm USB Packet Fields ADDR 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

41 Micriµm USB Packet Fields ENDP 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

42 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

43 Micriµm USB Packet Fields EOP 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

44 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

45 Micriµm Start of Frame Packets 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.

46 Micriµm Token Packets 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.

47 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

48 Micriµm Data Packets 48 High Speed mode defines another two data PIDs, DATA2 and MDATA. DATA2 This 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. MDATA This 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.

49 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 DATA1 DATA2

50 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

51 Micriµm Handshake Packets 51 Handshake packets are used for acknowledging data or reporting errors. There are three type of handshake packets which consist simply of the PID. ACK Acknowledgment 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. STALL The device finds itself in a state that requires intervention from the host. NYET The device is not ready to answer.

52 Micriµm Split Transaction Special Token Packets 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.

53 Micriµm Maximum data packet size 53 Transfer TypeAttributesHigh Speed Full Speed Low Speed Examples Control Quality + time 648,16,32 or 648 System control Bulk Quality <5128,16,32 or 64NA Printer, scanner Interrupt Quality + time <1024<648 Mouse, keyboard Isochronous Time <3072<1023NA 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.

54 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 1 Transaction 2 Transaction 3 Transaction n ….. Packet 1 Packet 2 Packet 3 Packet 1 Packet 2 Packet 1 Packet 2 … ……

55 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

56 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

57 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

58 Micriµm Bandwidth Management 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.

59 Micriµm 59 Protocol Analyzer Strongly recommended

60 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

61 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

62 Micriµm Endpoints and Pipes 62

63 Micriµm Transfers types 63 A transfer is made of one of more transactions Transfers typeDescription ControlIs non-periodic. It is used mostly for commands and status operations. Mandatory using Endpoint 0 OUT and Endpoint 0 IN. IsochronousHas a fixed number of bytes per frame. The bandwidth is guaranteed. No error-checking InterruptIs periodic and the latency between transactions is guaranteed. Error-free and low throughput BulkIs not periodic and it is used mostly to transfer large amounts of data. Error-free high volume throughput when bandwidth available

64 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

65 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

66 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

67 Micriµm Low-speed Control Transfer Limits 67

68 Micriµm Full-speed Control Transfer Limits 68

69 Micriµm High-speed Control Transfer Limits 69

70 Micriµm Full-speed Isochronous Transaction Limits 70

71 Micriµm High-speed Isochronous Transaction Limits 71

72 Micriµm Low-speed Interrupt Transaction Limits 72

73 Micriµm Full-speed Interrupt Transaction Limits 73

74 Micriµm High-speed Interrupt Transaction Limits 74

75 Micriµm Full-speed Bulk Transaction Limits 75

76 Micriµm High-speed Bulk Transaction Limits 76

77 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

78 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: 0x0110 bDeviceClass: 0x00 bDeviceSubClass: 0x00 bDeviceProtocol: 0x00 bMaxPacketSize0: 0x08 (8) idVendor: 0x058F idProduct: 0x9380 bcdDevice: 0x0100 iManufacturer: 0x01 iProduct: 0x02 iSerialNumber: 0x00 bNumConfigurations: 0x01 ConnectionStatus: DeviceConnected Current Config Value: 0x01 Device Bus Speed: Full Device Address: 0x04 Open Pipes: 2 Endpoint Descriptor: bEndpointAddress: 0x01 Transfer Type: Bulk wMaxPacketSize: 0x0040 (64) bInterval: 0x00 Endpoint Descriptor: bEndpointAddress: 0x00 Transfer Type: Control wMaxPacketSize: 0x0507 (1287) wInterval: 0x0282 bSyncAddress: 0x40

79 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

80 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

81 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

82 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

83 Micriµm Classes Class NameExamples AudioSpeakers, microphones Mass StorageHard drives, flash drives, CD-ROMs Human Interface Devices (HID)Keyboard, mouse, digital I/O CommunicationModems VideoVideo 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

84 Micriµm USB Mass Strorage Class 84

85 Micriµm USB Control Device Class (CDC) 85 Many variants of the CDC Class exist: ACM (Abstract Control Model ) ECM (Ethernet Networking Control Model ) EEM (Ethernet Emulation Model) and others

86 Micriµm USB Control Device Class (CDC) 86

87 Micriµm USB Audio Class 87

88 Micriµm Host Stack 88 Application USB Class API Class Drivers USB Host core stack Host Controller Driver Host Controller Hardware Mass storage HIDCDCHub Custom drivers Kernel Abstraction Kernel

89 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

90 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 Host Root Hub Device Hub

91 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 1Port 2Port 3Port 4 Root Hub Host stack OHCI Host Controller EHCI Host Controller

92 Micriµm Host and Root Hub When the Host stack starts, the 1 st 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 Port 1 Port 2 Root Hub Hub descriptor Enumerating RH Enumerating Function 1 Enumerating Hub Hub descriptor Enumerating Function 2 & 3 bNbrPorts = 2

93 Micriµm Device Stack 93 Application USB Class API Class Drivers USB Device core stack Device Controller Driver Device Controller Hardware Kernel Abstraction Mass storage HIDCDC Custom drivers Kernel

94 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

95 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

96 Micriµm USB On-The-Go 96 Application Device stack OTG Controller Driver Host Controller Hardware Device stack OTG stack Device Controller Hardware

97 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

98 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

99 Micriµm 99 Renesas offering SH7722SH7763SH7764SH7760 USB-Device √√√ USB-Host √√√ SH7705SH7720SH7721SH7727 USB-Device √√√√ USB-Host √√√ SH7670 USB-Device √ USB-Host √ SH7203SH7205 USB-Device √√ USB-Host √√ SH7263SH7265 USB-Device √√ USB-Host √√ SH7285SH7286 USB-Device USB-Host √√ H8SX/1653H8SX/1658RH8SX/1668RH8SX/1663 USB-Device √√√√ USB-Host H8S/2172 USB-Device √ USB-Host H8S/2215H8S/2218 USB-Device √√ USB-Host H8S/2472 USB-Device √ USB-Host M16C/24 USB-Device √ USB-Host Type aH8S2215 Type bH8S2218 H8S2212 Type cH8S2472 Type dH8SX1653 H8SX1663 H8SX1658R H8SX1668R Controller types 78K0/R USB-Device √ USB-Host V850MxV850Jx USB-Device √√ USB-Host √√ RX200RX600 USB-Device √√ USB-Host √√ SH2ASH4A USB-Device √√ USB-Host √√ R8C USB-Device √ USB-Host

100 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

101 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

102 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/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

103 Micriµm Questions? 103

104 Micriµm


Download ppt "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."

Similar presentations


Ads by Google