[webcam support] USB Host support that YOU can try (now in nightlies)

Search This thread

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
USB support and usb audio support were recently picked up by mainstream, so starting from nightly 135 you get all of the below (except for the webcam support). I am leaving the old information for history preservation purposes. The usb mode utility is replaced by Nook Tweaks

IMPORTANT! READ TO THE VERY END FIRST!

Ok, so I know some people want to try the usbhost mode and I am releasing this trial package to gather feedback and see how it works in the wild.
I am not responsible if you fry your nook (see below).

First, you need some hardware, namely microUSB to USB Female adapter. Something like this one. (There are cheaper ones on ebay, but delivery time is about 3 weeks, I got mine for $1.43).
Also an USB gender changer will work.

Then you need a kernel with usbhost enabled. I made a package that you can install onto emmc with CWM, or the same package could be installed on SD card if you use my installer. This package is only for CM7 users that already converted to .32 kernel. If you still run 2.6.29 kernel (ie CM7.0.3) - you need to upgrade to a fresh nightly like -87 or wait longer.

You can get the kernel here: http://nook.handhelds.ru/usbhost/update-CM7-green-usbhost-2-emmc.zip

As you probably know, the Nook Color comes a little bit crippled in a sense that id pin on the OTG controller is not connected and so we cannot rely on it to properly choose mode. Instead I wrote an app to achieve the switching.
The app is ugly as hell, sorry, it's my first attempt at writing an Android app, bear with me, it would become better (I accept free Android programming lessons too! ;) ).
You can get the app here: http://nook.handhelds.ru/usbhost/NookUsbHostSwitcher.apk
The app requires root, so make sure to allow it once asked and make it to remember the setting.

Install the kernel, install the app.
Reboot into the new kernel.
Run the app and you'll see a big "ToggleButton". When it's in Off mode, that means your nook is in usb client mode.
When you press it for the first time it will change to On, that means usb host.
(you can connect your external accessory before or after you enable the host mode).
When you press it again, it will change to Off and switch back to the client mode.
I recommend that before switching the host mode off you first disconnect your accessory, otherwise the internal hub cannot switch off.
(note that in some configurations the host mode enabling did not work for me on the first try and I needed to turn it off and on several times before the device registered. I believe there is no such problem with this kernel, but keep in mind such a possibility)
Addition in v2:
A second button is now added that lets you to force "external" vbus source. When you make it to ON, the battery charger pump is opened and connected to vbus terminals. In this state it is safe to connect nook to a power source, usb host will work and the battery should be charging at the same time.
Even without external power if your battery has high enough voltage (usually when it's full for me), it still somewhat works.
Additionally if you try to enable HostMode and an external power source is connected already, the "external" power mode is enabled (not shown in the app, though). This is to avert a potential disaster from below and to save battery.
Now the important part: When the Nook is in host mode, it drives 5V vbus off the connector at all times. If you connect the nook to a PC in this state, the PC will try to drive it's own vbus. Last time I tried to do this, my usb port in the nook fried! You've been warned! But that was before I had the host mode working and it might have been caused by a number of other things I was doing at the time too. Anyway I am not very keen on repeating this experiment again. If you are curious and decide to try it anyway regardless of the warning, make a comment and tell me what happened ;)

Supported devices (this is important, right?)
Note that only low power devices will work if you don't have an externally powered hub. Don't expect to be able to drive a cdrom or a hard drive out of just nook. 100mA is the current limit. (Current testing shows that if you use ISB hub, even unpowered, it hides this issue).
  • All keyboards should be supported. (the keymap in CM7 is a bit strange, though, you'll see it).
  • All mice should be supported too, though I have not tried.
  • I enabled Xbox and PS3 controllers support, but have not tried.
  • Usb camera support - I only enabled UVC-compliant cameras (Microsoft Live cameras are compliant for example, probably many others). You also need specially built nigthtly with videocam support (try Camera app).
  • USB storage - generic support enabled, so should work for you.
  • Serial port support - only generic support enabled (I guess GPS devices mostly work as serial ports)
  • USB audio support enabled - not sure if the Android has any idea how to support it.

The kernel is basically normal dalingrin's kernel with USB host support enabled and ipv6 disabled (to keep kernel size below 3M threshold).

Kernel source (for the curious and if you want to build your own kernel with some mode devices support): git://github.com/dalingrin/nook_kernel.git branch usbhost

Enjoy and share your experience.
 
Last edited:

Arbelzapf

Senior Member
Oct 29, 2010
754
149
So if anything goes wrong, we can revert by just flashing Dalingrin's kernel again, right?

Going to order an adapter now :)

Quick (and possibly stupid) question: Would gender changer plugs work in combination with a regular micro USB->USB cable?
 
Last edited:

tkascak

Member
Feb 16, 2010
10
0
Awesome news

Thanks for all your work on this. It just amazes me how much talent is here on XDA.

It also amazes me that Android tablets/phones struggle with something a 10+ year old Windows 98SE laptop can do with ease.

Ordered my cable and can't wait to try transferring pictures from my camera to the Nook!
 

paleh0rse

Senior Member
Jan 4, 2011
1,942
627
Has anyone seen a netbook-style keyboard/case combo that would work with the nook? (Bluetooth and/or USB)

Great work man, can't wait to try this out!! :)
 

hazridi

Senior Member
Dec 31, 2010
89
20
Just built cm7 from source as of 6AM and flashed your kernel, turned usb host on and attached my usb gender changer to my phone's micro usb cord and plugged in a mass storage device. dmesg in Terminal Emulator showed the device properly but apparently android has no idea what to do with it, the light didn't even come on. Encouraged by this minor sign of life, I plugged in a keyboard and it works (though of course the android keymap is close to full retard).

Good job! I think nullghost's idea of adding this to the CM7 pulldown menu is a good idea. Maybe also the power control?
 
A

ace7196

Guest
Glad I though ahead and got an adapter :cool:

Working well so far. Will try more accessories at school!
 

Divine_Madcat

Retired Forum Moderator
Sep 9, 2005
2,938
2,613
USA
Any advice on what adapter to buy? I was looking at this one:
http://www.amazon.com/USB-Micro-Ada...YMU6/ref=sr_1_1?ie=UTF8&qid=1306940268&sr=8-1

but not sure if it is what we are looking for since one review said it does not work for USB OTG.

Actually, thinking about it, is the USB host mode that is enabled here, different from the USB OTG that i am thinking of?


And since i dont mind being the first to ask a dumb question..
You will need to mount the USB storage yourself.
Would this be something done in the terminal, or through the settings UI (aka, it will show up on the same place that the SD card shows up)?
 
Last edited:

Arbelzapf

Senior Member
Oct 29, 2010
754
149
Using my mouse with my Nook at the moment :)

I went out and bought a gender changer, which seems to work. Thank you a LOT!

No luck with my Xbox 360 controller. It lights up and then keeps on blinking. I tried to assign hardware keys in FPse but it didn't respond to any keypresses.
Also, my Nook froze when plugging my mouse back in.
 
Last edited:

racks11479

Senior Member
Jan 2, 2011
990
748
Fresh Meadows
Dangit! How am I suppose to get any work done when you release something like this. Gonna have to run out and get a gender changer during lunch so I can play around with this! :D

Thank you verygreen!

-Racks
 
A

ace7196

Guest
Sorry, haven't tried that yet. But in theory it should (with a powered hub).
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
Any advice on what adapter to buy? I was looking at this one:
http://www.amazon.com/USB-Micro-Ada...YMU6/ref=sr_1_1?ie=UTF8&qid=1306940268&sr=8-1

but not sure if it is what we are looking for since one review said it does not work for USB OTG.

Actually, thinking about it, is the USB host mode that is enabled here, different from the USB OTG that i am thinking of?
OTG cable is only needed when hardware is supporting OTG mode natively.
All it does is has an extra connected pin. Nook ignores this signal unfortunately.

Would this be something done in the terminal, or through the settings UI (aka, it will show up on the same place that the SD card shows up)?
Nook cannot have fully automatic otg mode where you just plug an accessory and it works, then unplug, lug a host and it works.
Instead you need to manually control the mode from the provided app.
 
  • Like
Reactions: Divine_Madcat

joenathane

Senior Member
Oct 19, 2010
1,332
537
Phoenix
This is so awesome, if the nook can support a usb Ethernet adapter i'd be in heaven, I wouldn't have to lug around my Sony UX. Who has the best development community in the world? Nook does!
 

Divine_Madcat

Retired Forum Moderator
Sep 9, 2005
2,938
2,613
USA
OTG cable is only needed when hardware is supporting OTG mode natively.
All it does is has an extra connected pin. Nook ignores this signal unfortunately.


Nook cannot have fully automatic otg mode where you just plug an accessory and it works, then unplug, lug a host and it works.
Instead you need to manually control the mode from the provided app.

Thanks for the cable info - adapter is ordered. ;)

As for the mass storage, i guess what i was asking in a round about way; what IS the proceedure to mount a USB flash stick (for instance) so that something like Root Explorer could see the files?

Personally, i am REALLY interested in this for my photography. I would love to be able to connect my nook in the field, and get a sneak peak at what my shots are looking like, without having to haul out a full on laptop. My camera connects as a mass storage device, so assuming that Android could read a mass storage volume, i would be in business.
 

Gin1212

Senior Member
Jan 26, 2011
344
34
I hate you guys! =( Always making me spend more money that I don't have! Now I need to go find a good solid case with a usb keyboard!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 26
    USB support and usb audio support were recently picked up by mainstream, so starting from nightly 135 you get all of the below (except for the webcam support). I am leaving the old information for history preservation purposes. The usb mode utility is replaced by Nook Tweaks

    IMPORTANT! READ TO THE VERY END FIRST!

    Ok, so I know some people want to try the usbhost mode and I am releasing this trial package to gather feedback and see how it works in the wild.
    I am not responsible if you fry your nook (see below).

    First, you need some hardware, namely microUSB to USB Female adapter. Something like this one. (There are cheaper ones on ebay, but delivery time is about 3 weeks, I got mine for $1.43).
    Also an USB gender changer will work.

    Then you need a kernel with usbhost enabled. I made a package that you can install onto emmc with CWM, or the same package could be installed on SD card if you use my installer. This package is only for CM7 users that already converted to .32 kernel. If you still run 2.6.29 kernel (ie CM7.0.3) - you need to upgrade to a fresh nightly like -87 or wait longer.

    You can get the kernel here: http://nook.handhelds.ru/usbhost/update-CM7-green-usbhost-2-emmc.zip

    As you probably know, the Nook Color comes a little bit crippled in a sense that id pin on the OTG controller is not connected and so we cannot rely on it to properly choose mode. Instead I wrote an app to achieve the switching.
    The app is ugly as hell, sorry, it's my first attempt at writing an Android app, bear with me, it would become better (I accept free Android programming lessons too! ;) ).
    You can get the app here: http://nook.handhelds.ru/usbhost/NookUsbHostSwitcher.apk
    The app requires root, so make sure to allow it once asked and make it to remember the setting.

    Install the kernel, install the app.
    Reboot into the new kernel.
    Run the app and you'll see a big "ToggleButton". When it's in Off mode, that means your nook is in usb client mode.
    When you press it for the first time it will change to On, that means usb host.
    (you can connect your external accessory before or after you enable the host mode).
    When you press it again, it will change to Off and switch back to the client mode.
    I recommend that before switching the host mode off you first disconnect your accessory, otherwise the internal hub cannot switch off.
    (note that in some configurations the host mode enabling did not work for me on the first try and I needed to turn it off and on several times before the device registered. I believe there is no such problem with this kernel, but keep in mind such a possibility)
    Addition in v2:
    A second button is now added that lets you to force "external" vbus source. When you make it to ON, the battery charger pump is opened and connected to vbus terminals. In this state it is safe to connect nook to a power source, usb host will work and the battery should be charging at the same time.
    Even without external power if your battery has high enough voltage (usually when it's full for me), it still somewhat works.
    Additionally if you try to enable HostMode and an external power source is connected already, the "external" power mode is enabled (not shown in the app, though). This is to avert a potential disaster from below and to save battery.
    Now the important part: When the Nook is in host mode, it drives 5V vbus off the connector at all times. If you connect the nook to a PC in this state, the PC will try to drive it's own vbus. Last time I tried to do this, my usb port in the nook fried! You've been warned! But that was before I had the host mode working and it might have been caused by a number of other things I was doing at the time too. Anyway I am not very keen on repeating this experiment again. If you are curious and decide to try it anyway regardless of the warning, make a comment and tell me what happened ;)

    Supported devices (this is important, right?)
    Note that only low power devices will work if you don't have an externally powered hub. Don't expect to be able to drive a cdrom or a hard drive out of just nook. 100mA is the current limit. (Current testing shows that if you use ISB hub, even unpowered, it hides this issue).
    • All keyboards should be supported. (the keymap in CM7 is a bit strange, though, you'll see it).
    • All mice should be supported too, though I have not tried.
    • I enabled Xbox and PS3 controllers support, but have not tried.
    • Usb camera support - I only enabled UVC-compliant cameras (Microsoft Live cameras are compliant for example, probably many others). You also need specially built nigthtly with videocam support (try Camera app).
    • USB storage - generic support enabled, so should work for you.
    • Serial port support - only generic support enabled (I guess GPS devices mostly work as serial ports)
    • USB audio support enabled - not sure if the Android has any idea how to support it.

    The kernel is basically normal dalingrin's kernel with USB host support enabled and ipv6 disabled (to keep kernel size below 3M threshold).

    Kernel source (for the curious and if you want to build your own kernel with some mode devices support): git://github.com/dalingrin/nook_kernel.git branch usbhost

    Enjoy and share your experience.
    9
    Ok, I guess I'll do some sort of a progress update on the usb audio since so many people are interested.

    To use the files referenced here you need to install nightly -100 or later! If you use anything earlier than that version there is a bug in generic framework code that would prevent any audio input from working!

    You will need this kernel image: http://nook.handhelds.ru/usbaudio/uImage
    that you will need to use as the kernel.
    The kernel change is only to allow skype not to enter dead loop when it tries to open a microphone and cannot (when you do not have a usb headset connected).
    Unfortunately as soon as the internal mic input is opened, the audio out is also muted so I only include this for convenience of testing. (naturally don't take any of this as an indication that there is internal microphone input or anything.
    On the other hand this kernel also includes some groundwork to enable FM radio support (assuming it was properly wired, in the past all attempts failed because these bits were missing)).

    The other important bit is the alsa.omap3.so: http://nook.handhelds.ru/usbaudio/alsa.omap3.so
    Drop it to /system/lib/hw/ (this on sdcard this is partition2, /lib/hw)

    once the files are in place, reboot, connect the audio device, enable usbhost (or the other way around).
    The skype will now work. The sound is a bit distorted/sped up due to lack of rate conversion I guess.
    My usb headset is limited to 44.1kHz rate where as voice in is usually requested at 8k.
    the library I supply hardcodes the rate at 44.1kHz anyway.

    I suspect that the microphone only devices (like what is commonly found on web cameras) should also work with sound going to internal speaker.

    While you are at it, also please try to see if your audio device supports any other rates than mine. If it will turn out there are many 8k-supporting devices, I can try to add support for it I guess:
    Code:
    # cat /proc/asound/card1/stream0 
    C-Media USB Headphone Set   at usb-musb_hdrc-1.4, full speed : USB Audio
    
    Playback:
      Status: Stop
      Interface 1
        Altset 1
        Format: S16_LE
        Channels: 2
        Endpoint: 1 OUT (ADAPTIVE)
        Rates: 48000, 44100
    
    Capture:
      Status: Stop
      Interface 2
        Altset 1
        Format: S16_LE
        Channels: 1
        Endpoint: 2 IN (ASYNC)
        Rates: 48000, 44100
    The important are the "capture" rates. If yours look different, please report here.

    Hm... Actually I just tried my usbcam and the rates I see are (and yes, the mic-only input works too, output goes to internal speaker):
    Rates: 8000, 16000, 22050, 24000, 32000, 44100, 48000

    So I guess I need to add lower rates support after all and it'd work much better as a result.
    Also need to figure out how to make ALSA to sample down the rates, I believe there is support for this.
    The hardcoded 8k samplerate alsa lib is coming soon, though, after I give it a try locally.

    Another useful bit - make sure to press volume-up button while in skype, esp if on internal speaker, as it starts calls at something like 70 or even 60% volume for some reason.
    6
    I just got USB camera working (to some degree. preview window shows stuff).
    Only for uvc cameras supported by the kernel.

    Most of the work was done by CoreDruids by adding support for v4l cameras to Froyo. I merely ported their work to current CM7 sources. (links to follow once I submit changes to the repo. I expect this to be interesting to a lot of people as lately there were released plenty of tablets without cameras).

    My camera is MS Lifecam HD and seems to be too power-hungry for Nook to drive, so I used the just released ability to have externally driven vbus and borrowed the power from my desktop. Keep this in mind if you try with your camera and it does not work at first. (without it if I use the camera + keyboard on just nook power, stuff dies on init. If I use just the camera (over unpowered usb hub in both cases to hide power-hungry profile from the nook) it inits fine, but dies due to lack of power once real video stream is attempted (protocol error visible in logcat from v4l module)).

    Edit: So here is a special nightly build with webcam support. Try Camera app, that one certainly works. http://nook.handhelds.ru/usbhost/update-cm-7.1.0-RC0-encore-KANG-signed.zip This nightly already includes usbhost enabled kernel, but you still need to install the usbhost switchign app separately if you don't have it.

    Source changes for those interested. Generic libcamera stuff: http://review.cyanogenmod.com/5928 and Nook specific parts: http://review.cyanogenmod.com/5929
    5
    Microphones still aren't working, are they? Has anyone tried a USB mic?

    They sort of do in the latest nightly with a fix (http://review.cyanogenmod.com/5985 ) and recompiled alsa hw lib, but now there is a rate mismatch (usb device I have does not want to work at 8kHz), so all you hear is some bubbling.
    I am digging in this today and so hopefully a "Working skype" video is forthcoming at the end of the day ;)
    5
    I have updated the Nook Color Tweaks app with USB host support but I have no way of testing it.

    I would like to get confirmation that it works.

    Note: CM after version 7.1 is released this week will have automatic USB storage mounting for external disks. This app has a handy dandy shortcut in the notifications to safely unmount the disk. In order to test this notification you will need to manually mount to /mnt/usbdisk until the changes are merged into CM7.1

    The app should be partially compatible with verygreen's modified kernel but will need the 06/18 OC kernel to use all the features.

    As a bonus the app has boot features added by FatTire