Thursday, January 15, 2009

USB-OTG - A brief

Dealing with the USB OTG on Beagle has been quite a learning experience, especially, since my knowledge of USB was very minimal. This is Me's attempt at providing a brief about USB OTG.

USB was first introduced to address desktop's connectivity with various peripherals - printer, mouse, keyboard, serial, parallel, PS2 etc. It was quite successful - so much so that almost all peripherals and devices that need PC connectivity these days use USB.

USB has further been extended to other devices, mobile phones in particular and the functionality has been extended from mere PC connectivity to include charging, transferring video etc.

The USB master/ slave architecture that USB generally used - where a host acts as a protocol master and a USB device (peripherals) act as the slave - were sufficient to address most usage scenarios. The host always initiated the configuration/ data transfer from the peripherals in these cases.

Specifically, a usage model started emerging - the one where a device needed to either act as a host or a peripheral based on the situation. A typical example would be when two mobile phones could be connected for data transfer - where one would act as a device and the other as a peripheral. The same mobile also needed to act as a peripheral when connected to a PC. A need to have one connector on the mobile for all purposes - charging, to connect audio headsets, for data transfer - also played an important role in the introduction of USB OTG during late 2005 - early 2006 timeframe. The miniature nature of these devices also resulted in mini USB connectors to suit their form factors.

USB On The Go - USB OTG in short - introduced  two new protocols: SRP - Session Request Protocol and HNP - Host Negotiation Protocol.

SRP allows both communicating devices to control when the link's power session is active. This was not available in the standard USB spec - only the host was capable of doing so. This fine control over the power consumption resulted in significant power savings in battery operated devices like cameras and mobile phones.

HNP allows the two devices to exchange their Host/Device roles, provided both are OTG dual-role devices.

USB OTG protocols cannot pass through a standard USB hub - since they are based on physical electrical signalling.

USB OTG defines two roles of devices: OTG A-device and OTG B-device. The terminology defines which side supplies power to the link, and which is initially the host.

OTG A-device is a power supplier, and an OTG B-device is a power consumer. The default link configuration is that A-device acts as a USB host and B-device is a USB device. The modes may be exchanged later by using HNP.

USB OTG standard introduces a new plug receptacle called mini-AB. It can accept either a mini-A connector or a mini-B connector. USB OTG also adds a fifth pin to the standard USB connector called the ID-pin.

The mini-A connector has the ID pin grounded (connected to GND), while the ID in the mini-B connector is floating (non-grounded).

A device that has a mini-A plugged in becomes an OTG A-device and the one that has mini-B plugged in becomes a OTG B-device. The type of the plug inserted is detected by the state of the ID pin.

Beagle Context:

Beagle has a mini-AB connector and has both modes of operation. When connected to a PC it is a peripheral and when it is connected to other devices like a USB hub, keyboard, mouse, USB Ethernet etc, it playes the role of a host. When Beagle is required to play the role of a host, the cable that is required would need to be in the OTG-A mode.

In the market, almost all USB cables with a mini-AB connector are of OTG-B configuration. Me had scourged the local markets in Bangalore and Hyderabad, and couldn't find a cable that was made in a mini-A configuration. What makes matters worse that none of these cables had any indication about whether the cable has OTG-A or OTG-B configurations. The shopkeepers would hardly understand OTG, complicating things a little further.

2009-01-10-32267

So, to get USB on my Beagle working, Me had to choose between meddling with the board and modifying a cable. For obvious reasons, Me choose to modify the cable. Lucky for me the connector opened up pretty easily. But unfortunately, unlike the other pins, the ID pin was trimmed off making it very challenging to connect it to the GND pin.

After a whole lot of struggle, ended up with a connection as shown in the picture here. Had to take a small strand from a USB cable that Me had opened up earlier, use the solder to firm it up, and then put up a struggle to connect it between the ID and GND pins, making sure that it didn't touch any of the other pins.

Me's opinion - USB standard or atleast the cable manufacturers should come up with a standard way of indicating the OTG configuration that the USB A to mini-AB cables are made of. If not anything, that'd save some time and effort for folks who scourge the markets for specific cables.

-Me.

Further reading:

USB OTG on Wikipedia: http://en.wikipedia.org/wiki/USB_On-The-Go

USB OTG on the USB.org website: http://www.usb.org/developers/onthego

Maxim's app note on USB On-The-Go Basics: http://www.maxim-ic.com/appnotes.cfm/an_pk/1822

No comments:

Post a Comment