USB Packet Format

Source: Internet
Author: User
Tags keep alive

1. Starter (SOP) encapsulation

The root hub sends a SOF packet every 1 Ms. This is a time between 2 SOF packets, called frames. The SOF packet is a token-wrapping, but it has its own PID form name SOF. Usually the target set uses the SOF packet to identify the starting point of the frame. This packet is often used for wait-time transmissions. That is, when the 1 ms frame (high speed is 125μs micro-frame, 1 MS is cut into 8 parts), isochronous transmission will use SOF to activate the transmission and achieve the role of synchronous transmission. At the beginning of each frame, the SOF is passed to all connected full-speed sets (including hubs). Therefore, SOF packets do not apply to low-speed devices. The package contains a frame code that can be continuously incremented and reversed to 0 at up to the maximum value, re-

A few times. This frame code is used to represent the count value of a frame, so 8 micro-frames use the same frame code value. If necessary, the number of repetitions of the SOF can be calculated by the high-speed setting, and the quantity of the micro-frames is calculated. By shortening the cycle time of the micro-frames, it is possible to reduce the need for buffer memory at high speed.

As shown in 1, the high-speed root hub will use an extra SOF to transmit 8 micro-frames. Some books will call this high-speed SOF, and the other name Usof. This increased micro-frame also brings more sophisticated control to high-speed connections.

Figure 1 USB frames and Micro Frames

In addition, the diagram shown in 2 is used to illustrate the format of a SOF packet sent by the host. Where the SOF packet identifier, the PID data field value is 0xa5. Pid[3:o]=0101 and pid[3:o]=1010, except that the order of transmission must be LSB→MSB. Therefore, the 0xa5 can be deduced. Below, all PID data fields can be derived from this.

Figure 2 The various constituent fields of the SOF envelope

Figure 2 shows the various fields associated with the SOF packet definition.

In addition, the endpoint can be synchronized by the SOF packet, or frame value as a reference to the time. When there is no USB transmission on the entire USB bus, the SOF packet also avoids having the device cut down to a low-power abort (suspend) state. Furthermore, although the SOF packets are not visible at low speeds, instead, the hubs are configured with the BOP (End of-packet) signal mentioned earlier and set once at each frame. Therefore, it is sometimes called this signal to set the low-speed survival (keep alive) signal. So, the SOF/USOF packet is used for full speed/high speeds, while the low-speed survival signal avoids getting the low-speed device into the abort state.

2. Token pack

Because the USB data transaction is activated by the PC host side, in each data transaction, the following 5 data fields must be combined with the token packet as the starting point and the leading work of the communication protocol is performed. A token seal contains 5 data domain sync, PID, ADDR, ENDP, and CRC5. This is the 1th number of 54233:5. The data fields that are composed of each of its token packets, as listed below.

The PID data field (pid[1:0]=[0,1]) of the token packet contains the 3 PID type names of out, in, and setup. That is, it contains the out token packet, the in token packet, and the setup token envelope. For example, when executing a control transfer host to obtain a device descriptor (Get ̄descriptor) from a preset address, the following Setup token packets must be executed as the start of each control transfer, where the PID bar becomes the PID type name (0XB4) of the setup. In token packets, it is the work that the host uses to notify the device that data entry will be performed. The Out token packet is just the opposite.

Figure 3 shows the Setup token packet that originated from the PC host.

Figure 3 The various constituent fields of the token envelope

3. Data packets

In the USB interface, the host performs the management of the bus, data transmission, and the action that the host requests the command to respond. What are the data and demand commands that are being transmitted? Therefore, this work must be done through a data packet.

The data transfer from the setup, in and out token packets will be implemented with Datao, DATA1, DATA2 and Mdata packets. A data envelope contains 4 data fields: SYNC, PID, data, and CRC16. The meaning of each field has been described before. This is the 2nd number of 54233:4. Here, it is important to note that the bit values placed in the data field must be based on the USB device (low speed, high speed and full speed) as well as the type of transmission (interrupt transmission, bulk transfer and transmission), and must be in the set Maxpacksize bytes as the basic unit. That is, if the transmitted data is less than maxpacksize bytes, or the last remaining is less than the maxpacksize byte, it is still necessary to transfer the Maxpacksize bytes of data field.

Lists data packets that are composed of 4 data fields.

The data packet's PID data field (Pid[1:0]=[1:1]) contains 4 types: DATA0, DATA1, DATA2, and Mdata. According to the USB specification, the initial data packets are started with DATA0, followed by DATA1, and then alternately switched in this way. This action is called data toggle. This action is a bit like connecting data tightly. This ensures that the host can be synchronized with the set-up during the entire transmission and is used for framing errors. For example, if two consecutive DATA0 are received, it means that the DATA1 packet is omitted and the error condition is generated. DATA2 and Mdata, however, are only suitable for high-speed, equal-time transmissions.

If the host wants to set each endpoint for the special addressing, send out the command to set each descriptor, as shown in 4, the data packet containing the command will be outgoing. In particular, it is important to note that there are only 8 bytes in the data domain because of the control transfer. The meaning of the equipment requirements for "8006 0001 000040".

Figure 4 Various constituent fields of the data packet

4. Handshake packets

Handshake packets are the simplest type of packet. In this handshake packet, only a single PID data field is included. Its format is listed below, containing only sync and PID two data fields, which is the 3rd number of 54233:2.

The PID data field (pid[1:0]=[1:0]) of the handshake Packet contains the 4 PID type names of Ack, NAK, Stall, and Nyet. That is, it contains ACK, NAK, stall and nyet handshake packets.

Extends the previous legend, and the device responds with a handshake packet if the device has received a command that the host is going to execute to obtain the device descriptor. It is therefore important to note that if the device is ready to be received, the packet responds with an ACK handshake, if it is not yet ready to use the Nak handshake Packet Response, and if an error occurs, the stall handshake packet response is used. Figure 5 shows the format of a handshake packet, where the ACK PID data field value is ox4b, just as opposed to the PID data field value of Setup.

Figure 5 The various constituent fields of the handshake envelope

With the above 3 packets, a data transaction can be formed. This is, of course, the 4th digit of 54233:3.

For high-speed devices, in order to improve the NAK mechanism, nyet handshake encapsulation is particularly supported. This is because when the data has been transferred to the bus, it is not enough to trade the out data via Nak. Moreover, if there is a high frequency nak transfer process on the bus, it will cause the whole bus to be dragged down gradually and the bandwidth is shared. At this point, the high-speed set can use a special ping packet (mentioned later) to ask whether the receiver also has buffer space to receive out data transactions. If each response is set with an ACK, the transmitter will arrange

Out transfer. Conversely, if the response is nyet, then the transmitter is queried by a ping packet. This way, the bus will have the best usage rate.

5. Special packaging

A total of 4 special packets (PRE, ERR, split and Ping) are included. Among them, one is used only on low-speed devices, one is used only at high speeds, the remaining two are for USB 2 when low-speed or full-speed devices are connected. 0 hubs are used when communicating with the host in a high-speed manner.

(1) Pre-packet

This special predecessor (special Preamble,pre) packet has its own PID type name pre, which is only available when the host wants to transfer from high-speed to slow transmission. That is, the host must first send out the pre-packet before sending the low-speed packet to the lower port to communicate with the low-speed device. In the pre-package, the preamble is included to tell the hub that the next packet is low speed. This way, the hub will begin to perform the communication with the slow device that is about to be connected. At this point, the pre packet is placed before all tokens, data, and handshake packets that are guided to the low-speed setting. The high-speed setting is encoded by the pre with the split packet, so it will not be sent repeatedly. The pre-packet is not required for devices that are already low-speed. This format is listed below and contains only two 8-bit data fields: Sync and Pre.

(2) Ping packet

The special packets that are used only in high-speed devices are ping packets. The primary opportunity is to send a ping packet to find out whether the endpoint is busy before sending the next packet in bulk or in a controlled transmission with multiple data packets. This is due to the traditional USB data trading, if the usual Nak to respond to batch or control out of the transfer, often lead to waste too much bandwidth. Therefore, in order to reduce the loss of high speed or control out endpoint, USB 2. 0 added a ping packet. Once the batch or control transfer of out data transactions is responded to by Nak, the host controller will use a PING packet to query whether the high-speed, non-cyclical endpoint has enough memory to receive the wmaxpacketsize size capacity of the data. If the endpoint has enough buffers to use, it responds with an ACK, and vice versa, until the Nak responds.

In addition, high-speed, non-cyclical out endpoints can also respond with nyet to inform the host that the data to be loaded is acceptable, but the endpoint does not have enough memory. At this point, the host uses a ping token until the endpoint indicates that there is enough buffer memory for the next out data transaction.

(3) Split envelope

The Spilit packet defines the token packet as part of the split data transaction (split TransactIon). In order to optimally use the bus time, USB 2. 0 hosts and hubs deliver low-speed and full-velocity communication data at high speeds. Why do we need to split data trading? This is due to the fact that when the host starts transmitting a predetermined data transaction for a low-speed or full-speed set, the closest device is 2. 0 hubs are responsible for implementing data transactions with this set. In addition, it is also responsible for storing any postback data or status information and returning it with one or two later data transactions. In this way, the entire bus does not have to wait for a low-speed transaction to be implemented continuously. The special data transaction between the hub and the host is called split data trading.

(4) Error very inch bag

This packet is only used when splitting data trading. 2. 0 The hub uses the packet and returns an error to the host with a slow or full-speed data transaction. Here, whether the reader found that the PID code value and the pre-PID code value is the same. However, the biggest difference is that the former is applied to the hub and the other is applied to the host. That is, the hub will not send the pre packet to the host or ERR packet to set each.

The following, the packet format and the fields, such as the table is listed, and lists the fields and their purpose.

Relationship between a table envelope and a field

Continuation table

USB Packet Format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.