[WIP] USB Host support (working)

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
0
TN
linuxhacker.ru
Hello!

I have been asked into looking for usb host support for nook touch. The hardware appears to be pretty similar to Nook Color, so there were no troubles in that area.


The kernel used by B&N for the Nook Touch is somewhat older than .32 kernel used for Nook Color, so the patch itself required some massage. Surprisingly B&N kernel already has usb host support compiled in, so you don't even need to change anything in kernel config, just apply the patch.

Just like in Nook Color, the id pin in the usb receptacle is not connected anywhere, so a special app is needed to switch the host mode on and off. The Nook Color usbhost switcher should work: https://github.com/verygreen/Nook-Color-usbhost-switcher though I cannot compile it for eclair, so I guess that needs some more massage and help here would be appreciated.

Meanwhile you can simply switch the mode from adb, type
Code:
echo host > /sys/devices/platform/musb_hdrc/mode
to enable usb host mode and type
Code:
echo peripheral > /sys/devices/platform/musb_hdrc/mode
to disable it.
The LED at the bottom that usually indicates charging status will light up in usb host mode even if the power is not connected.

The upside is you don't need a special OTG cable and can just use gender changer on your existing nook cable if you so desire.

Now, problems ;)
  • I have not tracked why yet, but self powered mode only works when you try to enable it first with external power plugged in first.
  • The user-friendly tool for usbhost mode switching needs to be compiled for eclair
  • The self-powered mode is very faint. Keeps up with my keyboard, but not even with a simple usb hub.
  • Battery drain is significant, though not sure what part of it is attributed to the usbhost mode and what to adb over wifi
  • Eclair init is buggy so input devices are unusable without a patch, see commit 6405c6953fa02d41d9f6377f4cdb947604f481c4 in google tree to sytem/core/init. I am attaching recompiled init binary that works.

Attachments: binary.zip contains:
  • uImage - prebuilt 1.1 kernel with the patch
  • uRamdisk - root ramdisk with fixed init, adb over wifi
  • init - just recompiled init binary for those who might need it
usbhost_patch.zip - just the patch itself in it's current form.

THANKS TO:
andrewed, who asked me to do this and also provided me with a device. He is on a quest to touchtype on e-paper with a USB physical keyboard, all described here: Project: E-Paper Tablet (typable!)
 

Attachments

Last edited:

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
0
TN
linuxhacker.ru
That is awesome! How about audio and serial ports?

Thanks!
Audio will most probably require external power source. Also to make audio work there would need to be some changes to the libaudio, likely similar in nature to stuff I did for Nook Color, only for this older release of Android.

Serial ports will likely work as is as I don't think they draw too much power. The kernel support for usbserial would need to be added of course.
 

apeine

Senior Member
Mar 9, 2011
268
31
48
Sao Paulo
Verygreen,

As of now, what is the use? Can I put an external keyboard as it is? Does it need a driver (or something of the sort) for that? Can I put a usb stick? Audio and BT, as I can see, need an extra effort...
Anyway, thank you for your effort. I thought I'd never see something like that for the STR.
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
0
TN
linuxhacker.ru
Verygreen,

As of now, what is the use? Can I put an external keyboard as it is? Does it need a driver (or something of the sort) for that? Can I put a usb stick? Audio and BT, as I can see, need an extra effort...
Anyway, thank you for your effort. I thought I'd never see something like that for the STR.
You can use keyboard and mouse as is with just the files posted, no extra drivers need. Everything else would need more work at the android side.
 

cceerrtt

Senior Member
Sep 14, 2010
147
24
0
for some phones it is possible to buy usb to audio jack converter, e.g.
http://www.amazon.com/Headphones-Ea...6?s=electronics&ie=UTF8&qid=1327504575&sr=1-6
I don't know how much effort and changes is needed on kernel side to make it work though.

---------- Post added at 04:26 PM ---------- Previous post was at 04:21 PM ----------

Do I need to copy all three binaries? Also, could you prepare uRamdisk with adb over usb (not wifi) enabled? Thank you in advance.
 

dhkr234

Senior Member
Jan 27, 2011
575
157
0

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
0
TN
linuxhacker.ru
Do I need to copy all three binaries? Also, could you prepare uRamdisk with adb over usb (not wifi) enabled? Thank you in advance.
You need the kernel uImage and uRamdisk files, init is already included.

As far as adb over usb is concerned, it's a bit pointless since there is only one usb receptacle, so you can either connect with adb over usb or connect some usb device, but not both at the same time.
That's why wifi makes more sense.
 

cceerrtt

Senior Member
Sep 14, 2010
147
24
0
You need the kernel uImage and uRamdisk files, init is already included.

As far as adb over usb is concerned, it's a bit pointless since there is only one usb receptacle, so you can either connect with adb over usb or connect some usb device, but not both at the same time.
That's why wifi makes more sense.
My point is that you don't need wireless access point with adb over usb. It is also more secure than adb over wifi with lower power consumption. Whenewer I need adb over wifi, I can enable it using one adb command. Moreover, using both adb and keyboard attached to nook would not be very frequent scenario (at least in my case).
 
Last edited:

Thiso

Senior Member
Mar 16, 2010
127
23
0
Let's hope so. But I have good hopes as BT intention is to be low power communication. In the post I was referring to earlier, the power communication of BT in use was similar to USB mouse in use...

Sent from my GT-I8150 using xda premium
 

Torimu.Joji

Senior Member
Jan 5, 2012
61
16
0
Brr...
www.nookroot.tk
TorimuNooter

I'll try to get this included in my TorimuNooter root! Maybe version 0.5 I'm working on 0.4 right now and I can't include your USB host support because it's not yet complete, but I will try to implement it as soon as I can.
Good work! :):)
 
  • Like
Reactions: andrewed

Renate NST

Inactive Recognized Developer / Recognized Contrib
Feb 3, 2012
2,758
1,249
193
Boston
@Googie2149: Any standard USB cable will work as well as any other.
The ID pin on the micro USB connector on the Nook is not going anywhere so a special OTG cable is not required.

I loaded in the new uImage and uRamdisk and things act more consistently, but I still can't get a keyboard to work.

Neither of the two utilities out there seem to work correctly for me. I do have su installed. I have had more success with simple commands

Code:
echo host > /sys/devices/platform/musb_hdrc/mode
echo peripheral > /sys/devices/platform/musb_hdrc/mode
cat /sys/devices/platform/musb_hdrc/mode
One thing is clear; the Nook adheres to the USB standard for supplying power, that is, it supplies it for 100 millisecs and if the peripheral signals back correctly it continues to supply it. Issuing a host command cause the red LED to flash for about a 1/10 of a second. Supplying power on the red wire is not necessary for host communication.

My setup has a powered hub and a cable with the red lead not carried through. I can issue a host command but it never seems to communicate. The status reads back "a_wait_vrise".

Does anybody have any insight into the FSM to say what is going on?