Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,785,193 Members 36,781 Now Online
XDA Developers Android and Mobile Development Forum

[WIP] USB Host support (working)

Tip us?
 
brendan10211
Old
#121  
brendan10211's Avatar
Senior Member
Thanks Meter 12
Posts: 200
Join Date: Feb 2012
Location: Cary
Awesome! Can't wait to try it out, now I need a USB keyboard.
Nexus 7 32GB
Nook Simple Touch - Rooted
 
case-sensitive
Old
#122  
Senior Member
Thanks Meter 21
Posts: 259
Join Date: Nov 2010
Quote:
Originally Posted by Renate NST View Post
Ok, here's the new version.

If you are using unpowered devices or an unmodified hub:
  1. Hit the "Off" button.
  2. Plug in.
  3. Hit the "Host" button.

If you are using a modified hub:
  1. Plug in.
  2. Play with the charging settings if you feel like it.

When you are done:
  1. Unplug.
  2. Hit the "Peripheral" button.
  3. Hit the "Off" button.
  4. Hit the "Auto" button.
Thanks for making this!

I just tried it on my rooted NST; sadly it didn't work. Specifically, I I connected my usb keyboard to the NST using a microusb-to-usb convert http://www.amazon.com/Micro-USB-Male...0748930&sr=8-1 and then follow your instruction for "unpowered device", but the NST did not respond to the keyboard. The converter is almost certainly not an OTG one; could that be the problem?

I also tried to connect a micro sdcard to the NST (via a cardreader), again using your instruction for unpowered devices; ES file manager did not see the micro sdcard card, and the LED on the usb carder did not turn on (probably because there's not enough power to run the micro sdcard?).

I would *love* to be able to use a keyboard and to hook up a usb stick to my NST, so thanks for making this app. Any suggestions on fixing mine are most welcome!
 
Renate NST
Old
#123  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 796
Posts: 1,973
Join Date: Feb 2012
Location: Boston
@case-sensitive: Nope, you need an OTG. Take a razor blade to your little adaptor and try to see if you can ground the ID pin.

The mechanism where the Nook figures out exactly what is plugged into its USB connector is a bit complicated. It could be a a computer, a peripheral or a charger. Any of these could be charging at different rates and either end could be host. Throw in a few bugs in the driver and it's no wonder that the Nook occasionally gets confused what is going on.

One of the first problems was getting the Vbus (the charge pump) going. verygreen found a way to kickstart it with their driver.

The next problem was the question of an OTG cable or not. I was misled my the source code because it said "presume that it's an OTG cable". That presumption came after it had received an interrupt already from an OTG cable. In short, you need an OTG cable (with this driver).

There were cases of people getting this to work and people not getting it to work. When the Nook tries to start host mode it switches on vbus (the charge pump) and then waits to see if the voltage actually goes up. The driver appears to be incomplete in that it sets no timeout for waiting for this to happen. Without a timeout if the voltage doesn't rise you get the dreaded "a_wait_vrise". There is no reason that the driver should be in this state for more than a fraction of a second.

So why doesn't the voltage rise? Well, it tries. The problem is that the Texas Instruments TPS65921B IC inside the Nook that monitors the Vbus signal has a voltage threshold of 4.4-4.6 Volts. On my Nook we were seeing the Vbus rise to 4.46 Volts. For some people that was enough to say "Vbus valid", for others it didn't quite get there. (Note: Just to confuse things, if the voltage did rise high enough but there is no device connected the status will misleadingly say "a_wait_vrise" when the state is probably "a_idle".)

The actual problem was that the charger circuit in the Nook was trying to charge itself off the ~4.5 Volts that it was generating itself. That's really picking yourself up by your bootstraps. It doesn't work. The solution is to make sure that the charging circuit is off. The "Off" button in my application does that. You should be now getting 5.0 Volts.

Using a back-powering hub obviates all that. It gives (through an OTG adaptor) an OTG ID ground, it gives you your Vbus voltage. What more could you need?

I just checked using a thumb drive directly (without a hub). I couldn't seem to get it to mount by itself. The power was fine (4.92 Volts), the USB was happy (in host mode), but the LED on the thumb didn't go on. This needs further investigation. It works fine plugged into a hub.

If you have an OTG adaptor plugged in all by itself, you should be able to get the Nook LED to turn solidly on and off with the "Peripheral"/"Host" buttons on my application. Plugging in any device into the adaptor (without disturbing the OTG adaptor to Nook connection) should allow it to switch from "a_idle" to "a_host". Disconnecting the device from the OTG adaptor will cause it to flash "a_wait_bcon" for a second before settling into "a_idle" again.

So, in summary, to get it to work:
  • You must use an OTG adaptor or cable.
  • You may do either or both of these:
    • Use verygreen's uImage and uRamdisk to get the driver to work correctly. Use my application to make sure that the charging circuit is off and to see what's going on.
    • Use a back-powering hub (as posted above) to force things to go. My application is helpful in allowing you to actually charge the Nook.
The Following 3 Users Say Thank You to Renate NST For This Useful Post: [ Click to Expand ]
 
staylo
Old
#124  
Junior Member
Thanks Meter 3
Posts: 26
Join Date: May 2011
Great work! Using mali100's kernel I was able to get a battery powered GPS (iBlue 747) connected and accessible via /dev/ttyUSB0 very quickly, after modifying the USB cable into an OTG cable (shorting the ID pin to ground)

My main concern at the moment is that this GPS is usually charged over USB. When connected I see the battery voltage readout drop by ~0.1V and hear a high-pitched noise from the GPS (presumably a switching DC-DC converter) so I suspect the GPS is trying to draw some current from the Nook. Any suggestions on how best to tackle this problem?
 
Renate NST
Old
#125  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 796
Posts: 1,973
Join Date: Feb 2012
Location: Boston
Good work!

You might try connecting the GPS to the Nook with the red wire connection broken. That way each end is responsible for its own power. It should work.

I got my old Microsoft USB GPS puck to work. It spits out data and I can read it, but I haven't got the LocationProvider bit to work. It's on my big list of things to do.
 
staylo
Old
#126  
Junior Member
Thanks Meter 3
Posts: 26
Join Date: May 2011
Thanks, that was a good idea. Unfortunately the BT747 (probably) appears to drop the USB connection when Vbus is not connected, presumably as a power saving measure. I experimented with various resistances between the Vbus lines of the two devices, but I had to use 140 ohm before the BT747 would consistently connect.. (showing 3.1V on Vbus on the BT747 side) - that's a lot of wasted power So it seems like it's time to look for a low power USB GPS mouse!
 
durn_it
Old
#127  
Junior Member
Thanks Meter 1
Posts: 9
Join Date: Mar 2009
OTG cable works!

However when I restart the NST it no longer works - I have to reboot using the TouchNooter image with verygreen's binaries. Any ideas on how to make it persistent?
The Following User Says Thank You to durn_it For This Useful Post: [ Click to Expand ]
 
Renate NST
Old
#128  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 796
Posts: 1,973
Join Date: Feb 2012
Location: Boston
Quote:
Originally Posted by durn_it View Post
...when I restart the NST it no longer works...
Are you using my application to turn off the charging system?
When a Nook is fresh booted the charging system is off.
Once you plug a charger in it could be enabled, even after disconnecting.
 
Renate NST
Old
(Last edited by Renate NST; 9th April 2012 at 05:07 PM.)
#129  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 796
Posts: 1,973
Join Date: Feb 2012
Location: Boston
Here's a new version of my application.
It's no major change, just a few little things.
It will indicate how many "keyboards" are attached.
A multimedia keyboard is actually two USB devices, a qwerty and a multimedia controller.

As always, this reports what the system sees, not what is actually there.
The Following 2 Users Say Thank You to Renate NST For This Useful Post: [ Click to Expand ]
 
Renate NST
Old
(Last edited by Renate NST; 15th July 2012 at 11:58 AM.)
#130  
Renate NST's Avatar
Recognized Contributor / Recognized Developer
Thanks Meter 796
Posts: 1,973
Join Date: Feb 2012
Location: Boston
Oh, yeah... Here is my totally amazing IME (Input Method Editor).
It's called "Null keyboard". It does... nothing.
Select it as your input method and then when you go to edit a text field nothing happens.
Of course at that point you can just type on your USB keyboard without having 1/2 your screen blocked.
Note: Using the keymap files posted earlier, the Ctrl keys pop up an IME selection dialog.

Oh, if you don't have settings to enable this you can do:

Code:
adb pull /data/data/com.android.providers.settings/databases/settings.db settings.db

sqlite3 settings.db
update secure set value='com.android.inputmethod.latin/.LatinIME:com.temblast.nullkbd/.NullKeyboard' where name='enabled_input_methods';
.q

adb push settings.db /data/data/com.android.providers.settings/databases/settings.db
Oh, ok, a new doo-dad thrown in:
If you have the Null keyboard set as your IME and you go to edit a field somewhere and your keyboard is disconnected
it will popup the "Select Input Method" dialog.
This will rescue you when you left it on Null keyboard and went out without a keyboard.

The Following 3 Users Say Thank You to Renate NST For This Useful Post: [ Click to Expand ]
Tags
usb host, usbhost
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes