USB device enumeration process

Source: Internet
Author: User

After detecting that the USB device is inserted, the USB host needs to enumerate the devices. Enumeration is to read some information from the device, know what the device is, and how to communicate, so that the host can load the appropriate driver based on the information.Program. Debugging a USB device is an important part of the USB enumeration process. As long as the enumeration is successful, it has already been more than half done.

Control transmission is very important in USB. To ensure data correctness, control transmission is used during device enumeration. Control transmission is divided into three processes: ① creation process. ② Optional data process. ③ Status process. The setup process is initiated by the USB host. It starts with a setup token package followed by a data0 package. For control of input transmission, the data process is the input data; for control of output transmission, the data process is the output data. If the data length is set to 0 during the setting process, there is no data process. The data process is followed by the state process. The State process is the opposite of the Data Transmission Direction of the Data Process: If it controls input transmission, the state process is an output data packet; if it controls output transmission, the state process is an input data packet. The status phase is used to confirm that all data has been correctly transmitted.

Let's take a look at the detailed enumeration process:

First, after the USB Host detects that the USB device is inserted, it will first reset the device. After the device is reset, the USB Host sends a standard request to the device whose IP address is 0 to obtain the device descriptor. The IP address of all USB devices is 0 after the bus is reset, so that the host can communicate with those devices that have just been inserted through address 0. The host sends an input request to obtain the device descriptor at the establishment stage. After the device receives the request, it returns the device descriptor to the host during the data process. After the host successfully obtains the device descriptor of a data packet and confirms that there is no error (NOTE: Some USB devices have endpoints 0 less than 18 bytes (but at least 8 bytes ), the standard device description is 18 bytes. In this case, the USB device can only temporarily return some device descriptors according to the maximum package. After the host successfully obtains the first part of the descriptor, instead of requesting the remaining device descriptor, but entering the address setting stage), a zero-length status packet is returned to the device.

Then the host resets the device, and then enters the address setting stage. At this time, the USB Host sends a request to set the address (during the setup process, the address is set to no data), the address is included in the build package, and the specific address is managed by the USB host, it allocates a unique address to the new device. After the USB device receives the address, it returns a status packet with a length of 0. After the host receives the status packet with a length of 0, it returns an ACK to the device. After the device receives the ACK, it can enable the new address. In this way, the device is assigned a unique device address, and then the host accesses the device through it.

The host then obtains the device descriptor again. This time, it may be a little different from the first time. This time, it needs to obtain the complete 18-byte device descriptor. Of course, if your endpoint's 0 buffer is greater than 18 bytes, it will be the same as the first time.

Next, the host will obtain the configuration descriptor. The configuration descriptor is a total of 9 bytes. After obtaining the configuration descriptor, the host obtains the configuration descriptor based on the total length of the configuration set. The configuration set includes the configuration descriptor, interface descriptor, and Endpoint descriptor.

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.