The full name of USB OTG is USB On The Go, which means that through the connection function of the USB interface, it can realize the function of data exchange between various mobile devices without a computer.
1. The historical development of USB
To understand USB OTG, you must first understand the USB standard. This can be traced back to November 1994, when 7 companies led by Intel introduced the first draft of the USB protocol, unveiling a new round of bus **. By February 1996, the USB protocol specification version 1.0 was released, and it was agreed that anyone could use it for free. At this point, USB began to be gradually recognized by the majority of computer technicians and users, and gradually began to become a standard interface on computer motherboards. Then, USB-IF soon introduced USB1.1 and USB2.0 versions in 1998 and 2000, which greatly expanded the USB application field. With the gradual expansion of the USB application field, people’s expectations for USB are getting higher and higher. It is hoped that USB can be used in various computer fields, especially in the field of mobile communications, allowing mobile devices to communicate directly with USB peripherals. That is to allow USB to be used in areas where there is no PC. Non-PC application area? This is an Achilles heel of USB.
2. USB OTG was born due to mobile demand
A standard USB connection requires a host, which is usually a PC. If you want to transfer data stored in a peripheral device to another peripheral device, the only way is to intermediate the transmission through the master. For example, if you want to print a photo from a digital camera, you must upload the photo to the PC and then transfer the photo from the PC to the printer. Why not add the master function to the mobile device? USB is a communication protocol with a master-slave architecture. It was originally designed according to the application method of matching multiple peripheral devices to a master. Therefore, the control and management of the USB connection rely on the master. If all the master control modules of the entire USB specification are to be built in a mobile device, it will cause a great burden for mobile devices that emphasize simplicity. Therefore, "how to apply USB to the embedded field? How to achieve USB point-to-point communication?" and other issues have begun to enter the discussion agenda of USB developers. It is precisely under this new demand that on December 18, 2001, the USB-IF, in response to the insufficiency of the USB 2.0 master-slave architecture, added the supplementary specification "USB OTG1.0" for USB 2.0, and it has undergone 6 revisions. Launched USB OTG 1.0a in June 2003.
Function as a host, analysis of USB OTG characteristics
The original goal of the USB OTG specification is some consumer portable devices, that is, devices that end users want to share data with without a computer.
1. More energy-efficient power management
As a supplement to USB2.0, USB OTG 1.0a basically complies with USB2.0 specifications. Like standard USB, OTG is also a point-to-point, central host controller bus, rather than a brand new point-to-point network connection. When connected to a standard USB host, OTG products still act as peripherals. The OTG supplementary standard mainly introduces the problem of how a device must work when it is in host mode. Its most important extension to USB2.0 is its more energy-efficient power management and allows the device to be host and peripheral Form work.
2. Prohibit the "Silent Failure" function
Another important difference between the USB specification and the OTG specification is that OTG has the function of prohibiting "Silent Failure". This is because OTG devices do not have the function of adding drivers for "unrecognized" devices. This is because OTG devices currently allocate a fixed storage capacity for the operating system, but due to the lack of open memory, other drivers cannot be added to this storage space. Therefore, OTG devices must provide the so-called "target peripheral list (TPL)", which allows device manufacturers to accurately specify the peripheral devices they support. TPL is a list of vendor identification numbers (VID) and product identification numbers (PID), which can be identified by the OTG host and can automatically include drivers to support it. The USB specification uses so-called "USB header" information to identify each type of USB device. The "first" two bars of any device header are VID and PID.
If the end user inserts an unsupported device (not in the TPL), the user will definitely be prompted with an error message. The preferred method is to display graphics or text messages on the screen of the OTG device. If the OTG device does not have a text/graphic display, other methods of displaying messages must be provided. For example, lighting a specific LED, blinking the LED in a specific pattern, changing the color of the LED, etc. No matter what kind of message system is selected, the end user must be notified of the message.
3. Smaller form factor
In standard USB, the interface on the host is called the "A" connector, and the interface on the peripheral device is called the "B" connector. Since the target terminal devices are mainly small electronic products, the standard "A" interface is too large for these products, so OTG adopts "smaller" connectors in terms of hardware, including the mini-A interface (Mini-A) , Mini-A interface (Mini-A) and Mini-AB interface (Mini-AB), these connectors are much smaller than the usual USB standard connectors Standard-A and Standard-B, and are more suitable for portable devices.
4. Dual role function
Of course, the biggest feature of OTG is its dual-role function. There are currently two types of OTG devices: dual-use OTG devices (Dual-BoleDevice) and peripheral OTG devices (Peripheral-Only Device). Peripheral OTG devices are traditional USB peripherals, which can only use Mini-B interface, not Mini-AB interface. The dual-purpose OTG device can be used as a host or for peripherals. A dual-purpose OTG device as a host does not need to support all USB peripherals, but when it is connected to a PC, it can only be used as a peripheral. The dual-purpose OTG device has a Mini-AB interface, which can be connected to a point-to-point through the Mini-A or Mini-B connector according to the master-slave setting. In order to easily distinguish between dual-use devices, Mini-A is usually white, mostly as the master interface, the device plugged into Mini-A is A-device (A-Device); Mini-B is black, mostly slave interface, plug in Mini- B's device is B-Device; Mini-AB is gray, mostly dual-role interfaces.
At this time, the problem arises: if a Mini-A plug is inserted, the device will be a host; if a Mini-B plug is inserted, it is a peripheral device, but how does a Mini-AB-based product know what is inserted? What? The OTG specification adds another contact to the four contacts of the standard USB system, called ID. USBOTG transmits data through a five-pin interface and a five-wire cable. In addition to the traditional four pins of VBUS, D+, D-, and GND, the fifth pin is ID. The ID pin determines the master-slave role of initialization: In the Mini-A plug, ID is short-circuited to ground, and the connected device is initialized as Master: In the Mini-B plug, the ID is floating, and the connected device is initialized as a slave. The direction of the cable determines the device role played by the two OTG devices at the connection.
Under software control, the roles of master and slave can also be exchanged using the master device conversion protocol (HNP). HNP defines a method of dynamically switching between host and device roles. If you consider that every OTG device must include a TPL, you can understand this requirement. The device on the left has a printer on its TPL, but it is "not" on the printer's TPL, so communication between the two devices is impossible. If the end of the cable is turned upside down and then reconnected, communication can be achieved. The OTG specification is built into the protocol to automatically deal with this situation. HNP allows silent and automatic role inversion to enable communication, which improves the end user experience.