Remove All Ads from XDA
Honor 9 Lite

[WIP] USB Host support (working)

1,305 posts
Thanks Meter: 2,651
Post Reply Email Thread
1st March 2012, 08:49 PM |#121  
brendan10211's Avatar
Senior Member
Flag Cary
Thanks Meter: 12
Awesome! Can't wait to try it out, now I need a USB keyboard.
3rd March 2012, 05:37 AM |#122  
Senior Member
Thanks Meter: 33
Originally Posted by Renate NST

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 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!
3rd March 2012, 02:47 PM |#123  
Renate NST's Avatar
Inactive Recognized Developer / Recognized Contributor
Thanks Meter: 1,034
@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: [ View ] Gift Renate NST Ad-Free
3rd March 2012, 10:23 PM |#124  
Junior Member
Thanks Meter: 4
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?
3rd March 2012, 11:09 PM |#125  
Renate NST's Avatar
Inactive Recognized Developer / Recognized Contributor
Thanks Meter: 1,034
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.
4th March 2012, 12:22 AM |#126  
Junior Member
Thanks Meter: 4
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!
7th March 2012, 11:07 AM |#127  
Junior Member
Thanks Meter: 1
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: [ View ] Gift durn_it Ad-Free
7th March 2012, 12:32 PM |#128  
Renate NST's Avatar
Inactive Recognized Developer / Recognized Contributor
Thanks Meter: 1,034
Originally Posted by durn_it

...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.
7th March 2012, 03:02 PM |#129  
Renate NST's Avatar
Inactive Recognized Developer / Recognized Contributor
Thanks Meter: 1,034
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: [ View ] Gift Renate NST Ad-Free
7th March 2012, 03:37 PM |#130  
Renate NST's Avatar
Inactive Recognized Developer / Recognized Contributor
Thanks Meter: 1,034
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:

adb pull /data/data/ settings.db

sqlite3 settings.db
update secure set value='' where name='enabled_input_methods';

adb push settings.db /data/data/
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: [ View ] Gift Renate NST Ad-Free
10th March 2012, 08:12 PM |#131  
ros87's Avatar
Senior Member
Flag Bodø
Thanks Meter: 164
Donate to Me
There might be a possible danger to this (host mode)

I left my NST in sleep mode with the host mode kernel a couple of weeks ago.

When I picked it up today it was completely dead, and it won't charge, the charge led just goes green instantly when connected to the charger..

It's been sitting on the charger for a couple of hours now, led is green but there's nothing I can to do wake it up.

My suspicion (I might be wrong tho) is that that playing with host mode might allow for the battery to be completely drained if left unused for a long time.
Normally there are logic that will prevent the battery from draining entirely as that is usually very bad for this type of battery..

Post Reply Subscribe to Thread

usb host, usbhost

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes