Thursday 1 March 2012

USB blues

As it turns out, power is not the only problem I have with the tablet.

First, a bit about the tablet. It's an Ainol Novo Paladin - currently the cheapest tablet running ICS, with a capacitive screen, and not using a VIA CPU.  It's nice enough, and after upgrading it to 4.0.3 with an unofficial build, and getting rid of all the pre-installed Chinese apps, you're left with a responsive tablet with many of the basic apps working. This includes youtube, but not for example a working BBC iplayer.

It's Achilles Heel is the processor - unlike nearly all android systems out there, it's not an ARM  based processor, but a MIPS processor. While pure java apps work OK (and something I wrote for a phone in 2.2 worked immediately on the tablet, save a few scaling issues), any app that uses native compiled code won't work. And that excludes a lot of the apps on the Android market. That wouldn't be a problem, I thought, as I was going to write my own code, in java.

First I had to get a working adaptor cable. The tablet has a mini-B type OTG socket. 'Normal' USB connectors always have one type of connector for the host ('A' type, e.g. the flat one in full-sized plugs) and one for the client ('B' type, the square plug) - to make sure that it's not possible to create host-host or client-client connection. For USB OTG, the same socket on the device can be used as host or client, so the shape of the socket needs to accept plugs intended for either clients or hosts. To tell the device to switch (think of connecting two phones, one will need to become host), there must be something different in one of the two plugs. The difference is the 'X' or 'ID' pin (pin 4) - for clients, it is left floating; on the host side this pin is connected to ground. And, as I already found out, to tell the device that it is host, but allowed to charge of VBUS, that pin is connected to ground through a 124k resistor (but don't take my word on this, read the spec, and make sure your device actually implements this).

So you can't just make your own OTG cable by cutting off a connector from an old USB cable and soldering it onto another one, as the ID pin will be left unconnected. Instead, I bought a solderable Mini-USB plug (the only one I could find in the UK). But what you can't see in the photo is that the ID pin is trimmed off - instead of a solder pad, it only has a stub less than 1mm square! The nice people at hobbytronics confirmed that yes, all the plugs are like that.

But it is possible to solder a wire to it, with a bit of care (and two attempts in my case). The tablet reacts as expected - with the other end of the wire unconnected, it remains in client mode; with the wire touching ground, the tablet goes into host mode and powers the device (e.g. a keyboard works). Connected devices also show in /proc/bus/USB/devices.

That's where it stops. Unfortunately, it appears that Ainol did not bother to support Android's USB host  API. When I call UsbManager.getDeviceList(), the result is always empty. I am not the only one with this problem, apparently some tablets do, some don't, implement USB host.

What alternatives are there? FTDI, the makers of the serial/USB chip on my jeenodes, actually provide a nice Android library. Looks ideal, but it uses a native library, and that's only available for ARM. Compiling an FTDI driver into the kernel won't work for a similar reason - there is no source release for ICS that works for MIPS.

It now looks as if I need to change my hardware. Either sell the tablet and find one that does support the host mode API (and runs ARM), or turn the jeenode into a USB host instead. The USB host mini shield  seems the cheapest way to do that; the Arduino Mega ADK is a lot more expensive and would need an RFM12b module added. With the tablet running as client, I should be able to use the Android Accessory Protocol mode - running as client would also solve the power problem. That's assuming the AAP API is implemented, but I can (and will) test that.


1 comment:

  1. i have same tablet ,
    i tried every thing to get usb host api work,
    finlly i find this :
    http://stackoverflow.com/questions/11183792/android-usb-host-and-hidden-devices
    tried this and it worked ,
    good luck

    ReplyDelete