Home >Industrial IoT>Industrial IoT
How USB2.0 device establishes connection with the host

To establish a connection between a USB device and a host, the USB device must first be connected to the host. After the connection is made, the host will send a request to the USB device for device information. The USB device will then respond with its device identifier and other information about the device. The host will then send an acknowledgement to the USB device, and the device will respond by sending back a configuration descriptor. The host will then configure the USB device, and the connection is established.


Get to this page quickly



1. The birth background of USB

Before the birth of USB, all kinds of devices needed to be connected to computers through different types of interfaces. Such as keyboard, mouse use PS / 2 interface; printer, copier use DB-25 parallel port; serial port use DE-9 serial port. Moreover, most of the above interfaces are not hot-swappable, and you need to restart the computer every time you add a device. A new bus that is easy to use, low cost, high transfer rate, flexible protocol, and supports expansion was born. It is USB-Universal Serial Bus (Universal Serial Bus).

Related protocol recommendation:

TCP/IP protocol
2. History of the development and evolution of the USB standard

The organization that formulates the USB transmission protocol is USB-IF, and its members include Intel, Microsoft, HP, Apple, etc. From the first generation of USB 1.0 in 1996 to the latest USB4, there have been many iterations and name changes in the middle. Its standards mainly include the following versions, and the content of this article is also written based on the USB2.0 standard.

A) USB1.0

B) USB2.0

C)USB3.0

D)USB3.1

E)USB3.2

F) USB4

3. USB 2.0 vs. USB 3.0

USB 2.0 and USB 3.0 are two standards for connecting devices to computers. USB 2.0 is the older standard, while USB 3.0 is the newer one. Both standards are used to connect a variety of devices to computers, including external hard drives, printers, mice, keyboards, and more.

One of the most notable differences between USB 2.0 and USB 3.0 is their data transfer speeds. USB 2.0 has a maximum data transfer rate of 480 megabits per second (Mbps), while USB 3.0 has a maximum data transfer rate of 5 gigabits per second (Gbps). This means that USB 3.0 is significantly faster than USB 2.0.

Another difference between the two standards is their physical connectors. USB 2.0 connectors are rectangular and have four pins, while USB 3.0 connectors are usually colored blue and have nine pins. This makes it easier to tell the difference between the two standards.

USB 3.0 also supports a feature called SuperSpeed, which allows devices to transfer data faster than with USB 2.0. SuperSpeed is only available on USB 3.0 devices and can help reduce transfer times significantly.

In terms of compatibility, USB 3.0 is backward compatible with USB 2.0, meaning that USB 2.0 devices can be used with USB 3.0 ports, though at the slower USB 2.0 speed. USB 3.0 devices can also be used with USB 2.0 ports, though they won’t be able to take advantage of the faster USB 3.0 speeds.

USB3.0 VS USB2.0

Overall, USB 3.0 is the superior standard of the two, offering faster data transfer speeds and support for SuperSpeed, as well as backward compatibility with USB 2.0 devices. That said, USB 2.0 is still widely used and is a great option for many users.

4. USB system structure

The USB system is divided into two parts - the USB host, the USB device, and of course the connection between them. The structure is as follows:

 

USB system structure

The schematic diagram of the USB bus topology is as follows:

 USB bus topology-CDEBYTE

USB2.0 standard devices are divided into two categories: USB2.0 full-speed devices (FULL SPEED) and USB2.0 high-speed devices (HIGH SPEED), the differences between the two are as follows:

a. Speed: full speed up to 12Mbps, high speed up to 480Mbps;

b. Pull-up resistor: The USB2.0 standard distinguishes between full-speed and high-speed devices, and the agreement stipulates that a 1.5K pull-up resistor should be connected to D+ and D- respectively. Among them, the pull-up resistor of the full-speed device is located at D+, and the high-speed device is located at D-.

5. The process (enumeration) of establishing a connection between the USB host and the slave is as follows:

■ Device insertion (determine device access through pull-up resistors, and distinguish whether it is a full-speed device or a high-speed device)

■ host power supply

■ Initialize the device

■ Get device descriptor

■ Reset again

■ Assign address (the following operations use the new device address)

■ Get the device descriptor again

■ Get Configuration Descriptor

■ Get string descriptor

■ According to the configuration obtained above, configure the device

■ After the configuration is completed, the communication can start

Converts to the following more human-readable procedure:

When the device is connected:

Host: What kind of device are you?

Device: 0x12 0x01 0x00 0x02...Device descriptor

Host: What configurations (functions) do you have?

Device: 0x09 0x02...Configuration descriptor (including interface descriptor, endpoint descriptor, function descriptor, etc.)

(The host understands the interface and endpoint used by the device such as the function through the configuration descriptor read in the previous step)

Host: How many interfaces do you have?

Device: 0x09 0x04 0x00...Interface Descriptor

Host: Which endpoints are used for each interface?

Device: 0x07 0x05 0x82... Endpoint Descriptor

Host: I see, let's start transferring data.

Equipment: OK.

At this point, the entire connection process is established, and the communication between the host devices can start.

Note: During USB connection and communication, all communication initiators are USB hosts, and the device can only respond passively.

6. Various descriptors in the enumeration process

Diagram of the relationship between various descriptors:

 relationship between various descriptors


■ Device Descriptor:The USB Device Descriptor is a structure that contains information about a USB device. It is used by the USB host to determine the device's capabilities and to identify the proper driver to use for the device. The descriptor includes information such as the vendor and product ID, the device's class and subclass, the number of endpoints it has, and the maximum packet size for each endpoint. The descriptor is typically stored in the device's non-volatile memory.

 

■ Configuration descriptor:A Configuration Descriptor is a data structure used in Universal Serial Bus (USB) communications. It contains information about the device's power requirements, the number of possible configurations, and the number and type of interfaces and endpoints that each configuration supports. This descriptor is part of the USB Device Descriptor, which is a set of data that describes a USB device and its capabilities.

 

■ Interface Descriptor:Interface Descriptor is a descriptor used in Universal Serial Bus (USB) that describes the parameters for a specific interface within a configuration. It includes information such as the interface class, subclass, and protocol, the number of endpoints, and the interface string. The interface descriptor is part of the USB device descriptor and is used for the host to identify and configure a device.

 

■ Endpoint descriptor:Endpoint descriptor is a structure used by the Universal Serial Bus (USB) to describe the properties of a particular endpoint. It contains information such as the maximum packet size, polling interval, synchronization type, and usage type. The endpoint descriptor is part of the configuration descriptor, which is transferred from the device to the host during the enumeration process.

 

■ String descriptor:A descriptor is a brief summary or overview of a particular subject, typically a person, business, product, or service. It is usually written in plain English and is meant to give the reader a basic understanding of the subject without providing too much detail.