[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
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?
In case you cannot read the commands I typed in the video, you do this (in bash):
mount /dev/block/sda1 /mnt/SOMEWHERE
and then /mnt/SOMEWHERE is where it is mounted.
don't forget to create /mnt/SOMEWHERE beforehand (might need to remount root RW).

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.
Just make sure your cmera can self-power in this mode instead of relying on the host providing the power (and certainly hope that it does not try to charge over USB).
Does not your camera have a screen of its own? ;)
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
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!
Imagine what I went through first spending money on a new toy (nook), then finding out I need a special usb cable, then BT headset...
But it's fun too. I guess if you want to have some fun, be prepared to spend some money ;)
 
  • Like
Reactions: poofyhairguy

Arbelzapf

Senior Member
Oct 29, 2010
754
149
In case you cannot read the commands I typed in the video, you do this (in bash):
mount /dev/block/sda1 /mnt/SOMEWHERE
and then /mnt/SOMEWHERE is where it is mounted.
don't forget to create /mnt/SOMEWHERE beforehand (might need to remount root RW).

Hmm...I get an "invalid argument" when trying to mount my external hard drive. It does show up in /dev/block/ and I did create the mountpoint first. root is mounted in rw.
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
Hmm...I get an "invalid argument" when trying to mount my external hard drive. It does show up in /dev/block/ and I did create the mountpoint first. root is mounted in rw.

Check dmesg to see what is it complained about?
Specify the filesystem type (-t whateveryourfs) if it's not just fat. e.g. if you have ext4 there the default would try ext3 and fail due to incompat features and you need to use -t ext4 to overcome the problem.
 
  • Like
Reactions: Arbelzapf

FRSP

Member
Feb 13, 2010
44
1
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!

Obviously this is deeply in experimental territory as you say right now, but whenever someone gets around to making a user-oriented version, it might be a good idea to have a VBUS warning in the status bar while it's active.

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 ;)

Some experiments with a current limiting resistor and metering might be informative. But is there any proposed scheme by which it could detect and switch off?

Perhaps automatically powering down VBUS whenever the USB device is unplugged would work. The methodology would be plug in USB device, use status bar button to enable VBUS, disconnect USB device - automatic VBUS disable. Plug in new USB device, manually activate VBUS again. And of course it should refuse to activate if it detects an external supply. Perhaps a dev more familiar with android user mode work could help with this.

Hmm, automatic VBUS disable might make devices that re-enumerate fail? Especially clever embedded gizmos that only assume their real identity after a firmware download? Option to enable a short delay?
 
Last edited:

Mistar Muffin

Senior Member
Aug 11, 2009
291
413
Perhaps automatically powering down VBUS whenever the USB device is unplugged would work. The methodology would be plug in USB device, use status bar button to enable VBUS, disconnect USB device - automatic VBUS disable. Plug in new USB device, manually activate VBUS again. And of course it should refuse to activate if it detects an external supply. Perhaps a dev more familiar with android user mode work could help with this.

Hmm, automatic VBUS disable might make devices that re-enumerate fail? Especially clever embedded gizmos that only assume their real identity after a firmware download? Option to enable a short delay?

I had the same thought about automatically powering down the vbus upon device disconnect. Sounds like a good solution if it is possible.
 

Divine_Madcat

Retired Forum Moderator
Sep 9, 2005
2,936
2,608
USA
In case you cannot read the commands I typed in the video, you do this (in bash):
mount /dev/block/sda1 /mnt/SOMEWHERE
and then /mnt/SOMEWHERE is where it is mounted.
don't forget to create /mnt/SOMEWHERE beforehand (might need to remount root RW).

Ah... gotcha. Sorry about asking - here at work, i have to make the YT videos kinda small so no one notices. My apologies for a redundant question (and doubly so for asking one that i realize now i should have known anyway.. lol)

Just make sure your cmera can self-power in this mode instead of relying on the host providing the power (and certainly hope that it does not try to charge over USB).
Does not your camera have a screen of its own? ;)

Oh, its power source is all on board (a vertical grip packing two Li-ion batteries).. :)
As for the screen - sure, it has one, but i love my Nooks 7" IPS as opposed to a 3" built in. Ideally, i need something that can open RAW files (which would be amazing, but i don't think its out there for my Sony yet), but Jpeg viewing on the larger screen is still preferable. All too often, something looking in focus on the small screen, may be just off on a bigger screen, and at that point, i have lost the chance to retake the shot.
 

Arbelzapf

Senior Member
Oct 29, 2010
754
149
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.

This is what dmesg says when I plug it in:

Code:
<7>[ 6123.342498] usb usb1: usb resume
<7>[ 6123.359710] hub 1-0:1.0: hub_resume
<7>[ 6123.363739] hub 1-0:1.0: port 1: status 0101 change 0001
<7>[ 6123.475006] hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
<7>[ 6123.481048] hub 1-0:1.0: port 1, status 0101, change 0000, 12 Mb/s
<6>[ 6123.592132] usb 1-1: new full speed USB device using musb_hdrc and address 10
<7>[ 6123.719055] usb 1-1: ep0 maxpacket = 8
<7>[ 6123.728302] usb 1-1: skipped 1 descriptor after interface
<7>[ 6123.734558] usb 1-1: skipped 1 descriptor after interface
<7>[ 6123.740539] usb 1-1: skipped 1 descriptor after interface
<7>[ 6123.746368] usb 1-1: skipped 1 descriptor after interface
<7>[ 6123.752532] usb 1-1: default language 0x0409
<3>[ 6123.759704] usb 1-1: device v045e p028e is not supported
<7>[ 6123.765441] usb 1-1: udev 10, busnum 1, minor = 9
<6>[ 6123.770690] usb 1-1: New USB device found, idVendor=045e, idProduct=028e
<6>[ 6123.777923] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
<6>[ 6123.785705] usb 1-1: Product: Controller
<6>[ 6123.789978] usb 1-1: Manufacturer: Microsoft Inc.
<6>[ 6123.795196] usb 1-1: SerialNumber: 10E7F90
<7>[ 6123.802856] usb 1-1: uevent
<7>[ 6123.811004] usb 1-1: usb_probe_device
<6>[ 6123.818054] usb 1-1: rejected 1 configuration due to insufficient available bus power
<4>[ 6123.829528] usb 1-1: no configuration chosen from 1 choice
<7>[ 6123.835876] drivers/usb/core/inode.c: creating file '010'
<7>[ 6123.842102] hub 1-0:1.0: 92mA power budget left
<7>[ 6123.848297] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0002
<7>[ 6123.854339] hub 1-0:1.0: port 1 enable change, status 000001
 

ADude

Senior Member
Mar 5, 2011
528
59
So, what is the overall status of Audio Input for the Nook Color ?

For example, many of the aforementioned Microsoft USB cameras have microphones.

Thanks !
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
Obviously this is deeply in experimental territory as you say right now, but whenever someone gets around to making a user-oriented version, it might be a good idea to have a VBUS warning in the status bar while it's active.
Much better controlling app is in the plans, like I said. My android programming experience is 0 and the app you see is the first for me ;)

Some experiments with a current limiting resistor and metering might be informative. But is there any proposed scheme by which it could detect and switch off?
Sorry, I am a software-only guy, I don't do hardware.

Perhaps automatically powering down VBUS whenever the USB device is unplugged would work. The methodology would be plug in USB device, use status bar button to enable VBUS, disconnect USB device - automatic VBUS disable. Plug in new USB device, manually activate VBUS again. And of course it should refuse to activate if it detects an external supply. Perhaps a dev more familiar with android user mode work could help with this.
Yes, this is essentially my plan if the frying issue confirms. I'll implement it at kernel level just to be extra sure.

The good news is if ou can bring external 5v to drive vbus (a battery pack or whatever), a different mode could be enabled where vbus is driven by the external power and nook would be able to charge from it at the same time while working as usb host (basically what hololight demonstrated).

Hmm, automatic VBUS disable might make devices that re-enumerate fail? Especially clever embedded gizmos that only assume their real identity after a firmware download? Option to enable a short delay?
It' not yet clear if we need to do any of this or not. Once confirmed we can work out the implementation kinks.
 
  • Like
Reactions: poofyhairguy

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
As for the screen - sure, it has one, but i love my Nooks 7" IPS as opposed to a 3" built in. Ideally, i need something that can open RAW files (which would be amazing, but i don't think its out there for my Sony yet), but Jpeg viewing on the larger screen is still preferable. All too often, something looking in focus on the small screen, may be just off on a bigger screen, and at that point, i have lost the chance to retake the shot.
For raw files you can run real linux like Fedora (I am working on a port) or Ubuntu. ;)
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
This is what dmesg says when I plug it in:

Code:
<7>[ 6123.342498]
<6>[ 6123.818054] usb 1-1: rejected 1 configuration due to insufficient available bus power
<4>[ 6123.829528] usb 1-1: no configuration chosen from 1 choice
<7>[ 6123.842102] hub 1-0:1.0: 92mA power budget left

So the MS controller wants to draw more that 100mA... Try with a powered hub, I guess.
 

FRSP

Member
Feb 13, 2010
44
1
Yes, this is essentially my plan if the frying issue confirms. I'll implement it at kernel level just to be extra sure.

Yes, the "off" would be in the kernel. But it would be nice if the "on" signal to the kernel were eventually triggered by a button next to the wifi, etc toggles CM has in the status bar expansion, which is user mode stuff.

The good news is if ou can bring external 5v to drive vbus (a battery pack or whatever), a different mode could be enabled where vbus is driven by the external power and nook would be able to charge from it at the same time while working as usb host (basically what hololight demonstrated).

Can the nook be convinced form the software side that it has a high current charge source available? Or would the external supply need a momentary pushbutton to short its data lines?

It' not yet clear if we need to do any of this or not. Once confirmed we can work out the implementation kinks.

I'm thinking a little bit about how to do a safe hardware test, problem is every time I play with a different android version it takes numerous attempts to get my current install stable enough for general use again. Restoring from a backup image is a little better, but even simply rebooting seems to often break it to a mode where it crashes and runtime-start-loops or kernel reboots every minute or so.
 
Last edited:

poofyhairguy

Senior Member
Feb 19, 2011
501
101
Um guys, lets fill up verygreen's Thanks Meter. More than six months after release our Nook keeps getting new capabilities thanks to the hard work of the CM7 team!!!
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
Can the nook be convinced form the software side that it has a high current charge source available? Or would the external supply need a momentary pushbutton to short its data lines?
What would you need this for?
It is possible to make the charger to open the battery gates.
The battery voltage itself is not enough to drive the vbus without external 5v source, though. At least not enough to start, once the external source kickstarts the bus, then battery seems to be enough to drive it later on until disconnect.

I'm thinking a little bit about how to do a safe hardware test, problem is every time I play with a different android version it takes numerous attempts to get my current install stable enough for general use again. Restoring from a backup image is a little better, but even simply rebooting seems to often break it to a mode where it crashes and runtime-start-loops or kernel reboots every minute or so.

If you have a spare microSD card, use my installer referenced from the first post to install a fresh nightly, then install updated kernel on top of it, install the app and off you go, your normal image would not be affected.
 

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