Some basic concepts of USB
1. pipe is a data transmission model between the host and the device endpoint. There are two types of pipelines: unformatted
Stream pipe and message pipe ). Any USB device exists once powered on
An information pipe, that is, the default control pipe. The USB Host obtains the description, configuration, and status of the device through the channel, and
Configure the device.
2. An endpoint is the smallest unit in a USB device that can send and receive data. It supports one-way or two-way data transmission.
. The number of endpoints supported by devices is limited. A low-speed device supports a maximum of two groups of endpoints (2 inputs, 2
Outputs), high-speed and full-speed devices support up to 15 groups of endpoints.
3. interface ). Application Software controls and transmits data between devices through data exchange. Usually
Multiple pipelines are required for data exchange, because the same pipeline only supports one type of data transmission. Used Together
Several pipelines under row control are called device interfaces.
4. Relationship between devices and endpoints: a USB device can contain multiple endpoints. Different endpoints are distinguished by the number and direction of the endpoints.
Different endpoints support different transmission types, access intervals, and maximum packet sizes. Except the endpoint 0, all endpoints only support
Data transmission in one direction. Endpoint 0 is a special endpoint that supports bidirectional control transmission. Pipeline and Endpoint Association, and
The associated endpoint has the same attributes, such as the supported transmission type, maximum package length, and transmission direction.
5. descriptor describes the attributes of a device (attributes ). it is a data structure. The first byte represents the
descriptor size (number of bytes), and the second byte represents the descriptor type ). descriptor types:
1) device descriptor, which describes the general information of a device.
2) device_qualifier describes how a high-speed device changes at other speeds.
3) configuration descriptor, which describes a specific device configuration, such as the number of interfaces. a USB device has
one or more configuration descriptors. each configuration has one or more interfaces and each interface has 0 or more endpoints.
4) other speed configuration Descriptors (other_speed_configuration ), description
One configuration for high-speed devices at other possible speeds.
5) interface descriptor, which describes a specific interface in a configuration.
6) Endpoint descriptor, which describes the information required by the host to determine the bandwidth required by the endpoint. this descriptor can only be appended.
it can be transmitted in the getdescriptor () or getdescriptor () request. It cannot be transmitted separately. endpoint 0 does not have this descriptor.
7) string Descriptor (string), 0th string descriptors specify the language supported by the device, other descriptors each contain
A Unicode string. device descriptor. Configuration Descriptor and interface descriptor may contain string descriptor.
6. the USB device request is sent from the host to the device through the control pipeline.
Standard Device Requests include:
1) Clear feature
2) Get Configuration
3) Get Descriptor
4) Get Interface
5) Get status
6) set address
7) Set Configuration
8) set Descriptor
9) set feature
10) set Interface
11) synch Frame
Usb3.0 system topology
The system can have a tree structure of up to seven layers.
Up to 127 devices and hubs are supported
Host + roothub will always be at the first layer
Compound devices generally occupy two layers
Function devices cannot be used as non-leaf nodes, and only the hub can
Usb3.0 hub actually contains a usb2 hub and a superspeed hub.
Important features of usb3.0:
1. added an important data transmission rate
2. Point-to-point transmission packets to minimize the number of active links
3. asynchronous notification functions remove the need for polling
4. Link-level power management, which is the basic design of the bus structure
5. backward compatible with USB2.0, achieving compatibility at both the driver and physical layers
Difference between usb3.0 and USB2.0
1. data transmission rate, 3.0 is superspeed 5.0 Gbps,
2.0 is 1.5 Mbps, 12 Mbps or 480 Mbps
2. Data Interface, 3.0 is a full-duplex, four-way differential signal independent of USB 2.0 signal, supporting two-way data transmission at the same time
2.0 is a half duplex, dual differential signal, one-way data transmission, need to negotiate the transmission direction of the general route in advance
3. Number of signal lines, 3.0 is a 4-way superspeed data line, 2-way highspeed data line and 2-way power supply and ground line
2.0 is a 2-way ls/fs/HS data line, 2 power supplies and Ground Wires
4. Bus transaction protocol, 3.0 is host-dominated asynchronous transmission traffic control, and packet transmission can be explicitly routed
2.0 is the transmission traffic control in the polling mode dominated by the host. packet transmission is broadcast to all devices.
5. Power Management. 3.0 is the multi-level link power management. It supports idle, sleep, and suspend status.
2.0 is port-level management. There are two levels of hanging statuses on entry/exit.
6. Bus Power Supply, 3.0 is similar to USB 2.0, but the unconfigured power supply increases by 50%, and the configured power supply increases by 80%.
7. Host Controller. 3.0 uses xhci and 2.0 uses EHCI. Xhci provides virtualization technical support.
Usb3.0 Power Supply Status
1. U0, link active
2. u1, link idle-fast exit. Exit the latency level us
3. U2, link idle-slow exit. Exit the delay level of US-MS
4. U3, link suspend. No clock signal, exit the delay level of US-MS
Usb3.0 data packet type
1. Link Management packets, a link management package, occurs only between two connected ports and is mainly used for Link Management.
2. Transaction packets, a transaction package, occurs between the device and the host, used to control the data packet traffic, configure the device and hubs. It does not have data
3. data packets, a data packet, occurs between the device and the host. it consists of two parts: Baotou and actual data. the data also includes a 32-bit CRC verification code to ensure data integrity.
4. isochronous timestamp packets: Synchronous timestamp package. It is the only multicast Method for sending. The sending direction is from the host to all devices in the U0 status.
USB transmission type
1. Control Transmission)
Control transmission is a reliable two-way transmission. One control transmission can be divided into three stages.
The first stage is the setup transaction transfer from the host to the device. This stage specifies the request type for the transfer control;
The second stage is the data stage, and some requests do not have the data stage;
The third stage is the State stage. An in/out Transmission indicates whether the request is successfully completed.
The control transmission is performed between the control endpoints of the application software and the device through the control pipeline, and the data transmitted during the control transmission is
If the format is defined, a USB device or host can parse the data meaning according to the format definition. No format is defined for the other three transmission types.
Control transmission requires a fixed maximum package length. For high-speed devices, this value is 64 bytes; for low-speed devices, this value is 8; for full-speed Devices
It can be 8, 16, 32, or 64.
2. bulk transfers)
Batch transmission is a reliable one-way transmission, but the delay is not guaranteed. It uses the available bandwidth to complete transmission, and is suitable for the transmission of large data volumes.
Low-speed USB devices do not support batch transmission. The maximum package length of the high-speed Batch endpoint is 512. The maximum package length of the full-speed Batch endpoint can be 8, 16, 32, or 64.
Batch transmission has the lowest priority over other transmission types when accessing the USB bus,
Batch transmission is arranged only when the bus bandwidth is surplus. The high-speed Batch endpoint must support the ping operation to report the endpoint status to the host, nyet
It indicates a negative response, but is not ready to receive the next data packet. Ack indicates that the response is positive and the next data packet is ready to be received.
3. interrupt transfers)
Interrupt transmission is a round-robin transmission method, which is a one-way transmission. The host queries the interrupt endpoint at a fixed interval.
If data is transmitted or received, data is returned or sent. Otherwise, Nak is returned, indicating that the data is not ready yet. Guaranteed transmission interruption Delay
But not real-time transmission. It is a reliable transmission with limited latency and supports error retransmission.
For high-speed/full-speed/low-speed endpoints, the maximum package length can reach 1024/64/8 bytes respectively. High-speed interrupted transmission cannot occupy more than 80%
The microframe time, full speed and low speed cannot exceed 90%. The polling interval of the interrupt endpoint is defined in the endpoint descriptor. The polling interval of the full-speed endpoint can be
It is 1 ~ 255 ms, with a low-speed endpoint of 10 ~ 255 ms, the high-speed endpoint is (2interval-1) * 125us, where the interval value is between 1 and 16.
In addition to high-speed and high-bandwidth interrupt endpoints, only one interrupted transaction transmission is allowed within a microframe. A high-speed and high-bandwidth endpoint can enter a maximum of one microframe.
The row interrupts transaction transmission three times and transfers up to 3072 bytes of data.
4. synchronous transmission (isochronous transfers)
Synchronous transmission is a real-time and unreliable transmission, and does not support error retransmission. Only high-speed and full-speed endpoints support synchronous transmission and high-speed synchronization.
The maximum package length of a vertex is 1024, and that of a low speed is 1023.
In addition to high-speed and high-bandwidth synchronization endpoints, only one synchronization transaction is allowed to be transmitted within a microframe. A high-speed and high-bandwidth endpoint can perform three
Synchronous transaction transmission, transfer up to 3072 bytes of data. Full-speed synchronous transmission shall not occupy more than 80% of the frame time, and high-speed synchronous transmission shall not occupy
The microframe time exceeds 90%.
The access of the synchronization endpoint is the same as that of the interrupt endpoint, and there is a fixed interval limit.
There is another transmission between the host controller and the USB hub-split transaction, which is executed only between the host controller and the hub, allows full-speed/low-speed devices to connect to high-speed hosts. Separated transmission is transparent and invisible to USB devices.