5,598,171 Members 43,915 Now Online
XDA Developers Android and Mobile Development Forum

[14 Apr 2012][USER/DEV] USB Host Support & Development [CM7/CM9]

Tip us?
 
Dj-Gutz
Old
(Last edited by Dj-Gutz; 16th April 2012 at 11:22 PM.)
#1  
Senior Member - OP
Thanks Meter 83
Posts: 197
Join Date: Sep 2010
Location: Tel Aviv
Default [14 Apr 2012][USER/DEV] USB Host Support & Development [CM7/CM9]

Nook Color USB Host Support & Development Thread

What is USB Host mode?
The ability to connect your day-to-day USB devices to your Nook Color

Is it the same as OTG ( On-The-Go )?
Principally YES , Technically NO
USB OTG has an id-pin that allows the host to detect automatically the state it should be and enable charging & hosting
On the nook , the id-pin is not connected so we have to control the states ourselves ( Nook Color Tweaks )
This is why an OTG cable is not needed ( but should work as well )

Purpose of this thread
As you might know , dalingrin and verygreen brought us USB Host support some time ago
This thread will rely on that original thread , but will bring some order so we can continue explore & develop.
CM9 ( ICS ) introduced us the USB HOST API , and much more support based on Honeycomb
I personally moved completely to CM9 since it's far superior IMO ( even at the current state of development )
so CM7 info is based on my own past experience & user experiences posted.
Current Status
please share your experience here
Nook Color USB HOST Device Compatibility List
Standard Support
  • External Storage ( Disk-On-Key / Card-Reader / HDD )
  • Keyboards & Mice
  • Game Controllers
  • Custom HID Input Controllers
  • DSLR & VDSLR Cameras
  • Audio Output

For detailed info & other devices go to post 2 - Possibilities include : Webcams , GPS , BT , 3G , DVB-T and more...
MUST READ!
Before posting an issue please SEARCH both this & the original thread
Tools Needed
External VBus
External VBus mode will enable you to use an external power source to charge the nook while using USB Host mode
This mode is quite buggy but still usable - READ before using a powered hub
Quote:
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.
Using the OEM cable to enable 2A charge
As far as I know , the OEM cable doesn't seem to work with USB Host mode
And as a result of this ( & most if not all usb hubs specs ) - you can't charge the nook with 2A using External VBus

Why do some devices REQUIRE an external hub?
The maximum current the nook can supply is 100mA
If your usb device require more than 100mA , External hub is REQUIRED
Read post 3 to find out how to diagnose power requirements

Important : Using a non-powered hub can mask the power requirements for some devices!

Tested Hubs
Testimonials : Belkin 4 Port Hub | Belkin FSU237 7 Port Powered Hub

^ That is what I use ( Link for ex. )
Needs Attention
  • Charger code bugs involving External VBus
  • "Charging" status while using External VBus
  • Home-Screen Widget
  • Audio Input
This is a Work-In-Progress
since I don't have much time , I'll be glad to see this as a community effort , so if you have any info to share feel free to do so
The Following 8 Users Say Thank You to Dj-Gutz For This Useful Post: [ Click to Expand ]
 
Dj-Gutz
Old
(Last edited by Dj-Gutz; 9th May 2012 at 06:56 AM.) Reason: Camera HAL
#2  
Senior Member - OP
Thanks Meter 83
Posts: 197
Join Date: Sep 2010
Location: Tel Aviv
Default USB Devices Support Extended Info

USB Devices Support Extended Info
There are Countless possible uses , Currently only 6 known to work
please share your experience here
Nook Color USB HOST Device Compatibility List
Standard Support
  • External Storage - Disk-On-Key / Card-Reader / HDD

    CM7 - FAT32 ( should Auto-Mount , CM7 users please confirm )
    CM9 - FAT32 / NTFS ( Mount using StickMount / Drive Mount )

    *NTFS support is not native , so keep reading this post if you plan to use it

  • Keyboards & Mice
    Most should be supported - Re-Mapping how-to on post 3

  • Game Controllers
    CM7 - Try Gamepad IME , no reports on successful attempts
    Testimonials : Link 1 | Link 2 | Link 3 | Link 4 | Link 5 | Link 6

    CM9

    USB/BT Joystick Center
    Quote:
    USB Joystick Center has Driver-Settings included for these Devices (ready to use, others you can create at your own):
    Wireless:
    - PS3 Controller without root (* CSR Bluetooth 2.x/EDR+ USB Stick is needed)
    - X360 Controller ("Microsoft Wireless Gaming Receiver for PC" USB is needed)
    - Bluetooth Keyboards
    - iCade
    - iControlPad (SPP Mode)
    - PhoneJoy
    - Wii Remotes 1-4 + Nunchuck + Classic
    - Zeemote
    * Please read the Sixaxis pairing instructions on the help site of the app!

    USB:
    - X360 Controller - Wired
    - PS3 Sixaxis - Wired
    - Hyperkin N64 Moonlight Controller
    - Logitech (Rumble, F310, F710)
    - Microsoft Sidewinder 2 Precision
    - Trust GXT 24
    - X360 Rockband: USB Guitars + Drums
    - N64 "Controller Adapter for PC USB" (for 2 Controllers)
    - PSX 1/2 "USB Gamepad Converter Dualschock" with 2 Player support
    - PSX + N64 USB Dual Converter
    - SNES "Controller Adapter for PC USB"
    - C64/Atari/Amiga "Donalds USB-Joystickadapter" for 2 Players
    - C64/128/A600 "Keyrah" USB Keyboard + 2 Joysticks Adapter
    - Stelladapter 2600 to USB
    - "PC/Gamepad/Joystick Adapter" (15 Pin D-Sub)
    - PSX - USB 4 "Buzz Junior" Wired Controllers
    - PSX 1/2 (EAXUS) "Super Dual Box Advanced" Adapter for PC USB

    If you have an adapter that is not natively supported and you have trouble to use it, enter the support forum.
  • Custom HID Input Controllers
    You can try to make a custom "driver" in USB/BT Joystick Center ( see Game Controllers ^ )
    Or , Go to post 3 which describes the manual way using the key layout file if your input controller contain mainly buttons

  • DSLR & VDSLR Cameras
    Many apps on Google Play , Here is what I could find

    DSLR Controller (BETA) - Known to work

    Remote Your Cam USB Lite
    ML Controller
    DslrDashboard 0.25.3 beta

  • Audio Output
    If your device doesn't require special drivers , and recognized as a USB Audio on your PC - It should work
    Testimonials : Logitech DAC A-5572A | Beresford TC-7520SE Caiman | FiiO E7
Ready For User Testing
Research & Development
USB Host is a bit of a challenge , Since it lives in both the kernel & userspace
Some devices require kernel "attention" , but some can use USB Host API

My advice is to try the API route first since it's native to ICS in general and it's cross-device
USB Host API is pretty much the same as libusb , so linux devs should be comfortable with it
LinuxAndroid
External Storage
To use NTFS file-system on CM9 you need to do the following :
  • Download the attached zip @ the bottom of this post
  • Extract fuse.ko ( credits : fattire ) & Place it in your sdcard ( eg. /sdcard/fuse.ko )
  • Open terminal session
    Code:
    insmod /sdcard/fuse.ko
  • Mount
*I can picture a fuse kernel module "injector" as an option in Nook Tweaks - if you up for it you can find the source in post 3
Audio Output
Although audio output is hard-wired in the kernel , There is still room for improvement
Once it's connected it takes control over all audio output
Novo7 Advanced devs for example have made a software mod to allow basic control via userspace
Drivers and libraries for NOVO7A (with usb audio)

Also , You can support google making it mainstream by starring this issue
Enable USB audio on the Galaxy Nexus (or any Android 4.0 device)
Audio Input
Relevant Info : Link 1 | Link 2 | Link 3 | Link 4
Testimonials : usb audio 7.1 | generic USB audio dongle | Logitech USB Headset 360 , More Info | MS Lifecam cinema | USB2.0 7.1CH Sound Adapter | Plantronics USB headset

I've been experimenting with my MicMate + ECM8000 combo on CM9 not long ago
I was able to use RTA apps to some extent , But recording apps FC
This needs further research
Webcams & Video Input
Last Update: 09/05/12
CM7 Relevant Info : Link 1 | Link 2 | Link 3

Kernel support is present already :
CONFIG_V4L_USB_DRIVERS=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y

Here is a source for an app that would allow you to view the video feed through JNI - Usage of USB webcam with customized Galaxy Nexus & Iconia Tab A500
You can download it compiled SimpleWebCam.apk ( Credits : bigrushdog )

Camera App/Skype/Etc. shouldn't work , For that we need something that will emulate the output as internal camera
9/5 - Camera HAL on the works
GPS
CM7 Relevant Info : Link 1
Testimonials : GlobalSat BU-353 , More Info

CM9 Relevant Info : Link 1
DVB-T
Last Update: 06/05/12
  • Android DVB-T - I can't download this app from Google Play ( This item is not compatible with your device ) , So I can't test it.
  • DroidTV ( In Development ) - Follow the git for progress , APK ( Still needs compiled modules )
Related Modules : dvb-core.ko , dvb-usb.ko , dvb-pll.ko , mxl5005s.ko , tda18271.ko , qt1010.ko , mt2060.ko , af9013.ko , tda18218.ko , dvb-usb-af9015.ko
Microsoft Kinect
Last Update: 02/05/12
There is a lot of "hidden" potential using Kinect
Here is an interesting project , he has plans for Android as well.
Reverse Parking Assist Using Microsoft Kinect
3G
Iconia A500 | Archos Gen8
BT
Relevant Info : Link 1

Related Modules : bluetooth.ko , btusb.ko , rfcomm.ko , bnep.ko , sco.ko
Phone Tether
Tether Android Phone (Desire) to Android Tablet (Iconia A500) via USB Cable
Video Output
Last Update: 02/05/12
Serial Port
Last Update: 06/05/12
Midi Controller
Last Update: 06/05/12
Scanners
Build native GNU/Linux applications: the easy way
Pico Projectors
An Open Source driver for USB pico projectors
IR
Last Update: 02/05/12
Does USB IR Transciever work with Android?
Attached Files
File Type: zip fuse.zip - [Click for QR Code] (32.3 KB, 192 views)
The Following 6 Users Say Thank You to Dj-Gutz For This Useful Post: [ Click to Expand ]
 
Dj-Gutz
Old
(Last edited by Dj-Gutz; 14th April 2012 at 03:09 AM.)
#3  
Senior Member - OP
Thanks Meter 83
Posts: 197
Join Date: Sep 2010
Location: Tel Aviv
Default Diagnostics & Development

Diagnostics & Development

I take no responsibility.............. DO IT ON YOUR OWN RISK!
This part of the thread will be dedicated to reading and diagnosing logs , and more advanced stuff for developers
most of the usb-related stuff are using kernel messages to let us know their status
to read kernel messages we can use Android Debug Bridge ( or ADB )
the original protocol is used via USB , but we already use it to connect our usb devices so we need a different route

So , you should basically know 2 apps :

adbWireless enables a wireless ADB connection , just like USB so you can view logs on your PC

Android Terminal Emulator will let you use Android's built-in Linux command line shell right on the nook itself.

It doesn't matter what you choose , those are just 2 different ways to view the same thing - and you will know more by the end of this post
I'll try to make this post appeal to both the command-line and GUI guys

Command-Line
You can use the following on both CM7 & CM9
So , open your app of choice ( adbWireless / Terminal Emulator / Whatever ) and establish a connection ( shell ) if needed

First you should start with
Code:
su
Since we are dealing with kernel stuff , you need superuser permissions.
this command will give you root access till the end of the session.
If you see ‘#’ - you already got root access
If you see ‘$’ - type ’su’ to get root access.

Now that we got root permissions we have read&write access to the system
Here is a list of relevant commands and their actions

Code:
logcat - view the internal log of the Android system
dmesg - view the message buffer of the kernel 
cat /proc/kmsg - continuous dmesg ( to stop the log use ctrl+c )
echo host > /sys/devices/platform/musb_hdrc/mode - usb host ON
echo peripheral > /sys/devices/platform/musb_hdrc/mode - usb host OFF
echo external > /sys/devices/platform/i2c_omap.1/i2c-1/1-0048/twl4030_usb/vbussrc - external vbus ON
echo internal > /sys/devices/platform/i2c_omap.1/i2c-1/1-0048/twl4030_usb/vbussrc - external vbus OFF
lsusb - list usb devices
cat /proc/asound/cards - list audio devices
GUI
General :


Lumberjack - Log export and viewer



CommandCenter - CM7 Support

USB HOST :


USB Host Viewer



USB Device Info


USB Host Diagnostics - CM7 Support


Usb Host Controller - CM7 Support

How To Diagnose Power Requirements ( 100mA limit )

As I stated earlier some devices require more than 100mA to become functional
in that case this can be easily spotted by looking at the logs ,
Enter cat /proc/kmsg on adb/terminal or watch dmesg log on lumberjack
Connect your usb device and look for the RED line :
Code:
<6>usb 1-1: Product: U3 Cruzer Micro
<6>usb 1-1: Manufacturer: SanDisk
<6>usb 1-1: SerialNumber: 0572710F0A803B8A
<7>usb 1-1: uevent
<7>usb 1-1: usb_probe_device
<6>usb 1-1: rejected 1 configuration due to insufficient available bus power
<4>usb 1-1: no configuration chosen from 1 choice
If you see it that means you need to connect an external power source ( hub for example )

Re-Mapping Input Buttons/Keys

Let's say you are using a full keyboard with Multimedia/Function keys or some kind of an HID device with buttons
And you want to map/re-map specific keys to do other functions in the system such as controlling volume , play/pause , go to home etc..

This is how you do it
  • Install KeyEvent Display
  • Connect your usb input device
  • Press the key you want to re-map and look for its scancode ( key code )

    Here you can see I pressed FN+Print Screen keys on my logitech keyboard , and found out the their scancode is 127
  • Open your favorite file browser ( I use Root Explorer )
  • Navigate to /system/usr/keylayout
  • backup Generic.kl file!
  • Edit Generic.kl , look for the keycode you found and change it's command
    My original layout :

    As you can see it's mapped as a menu key
    Now let's say for example I wanted this combination to trigger default music app , all I need is to change the highlighted line to
    Code:
    key 127    MUSIC
    If you see '#' in the start of the line , delete it to make the key active
    If your keycode doesn't exist - you can add it in a new line ( make sure it doesn't exist before you create a new line )
  • Save and Reboot! ( you must reboot for changes to take effect )

Since we are changing Generic.kl , almost every input device that is connected or present on the nook will be effected by the change
If at any step you find the hardware keys / keyboard not working properly - restore to your backup and reboot.

If you have more than 1 device with the same keycode and you need them to perform different actions you will have to create a specific key layout
More info can be found @ Key Layout Files

NOTE : This was tested on CM9 , I'm not sure this works on CM7 as well ( although probably not as generic.kl was introduced in HC )

Controlling USB Host & External VBus via Tasker
  • Install "Locale Execute" plug-in from the Market
  • In Tasker open "Tasks" and make a new one (e.g. "USB Host ON")
  • Category: Plugin Action: Execute
  • Give it a name on the label and push the edit button
  • Insert the command
    Code:
    @! echo host > /sys/devices/platform/musb_hdrc/mode
  • Apply

You can now test it , or use it in a profile of your choice.
Superuser App will ask for permission for *every single new command* you use in Locale Execute. No workaround.



Use these commands to control usb host & external vbus state
Code:
@! echo host > /sys/devices/platform/musb_hdrc/mode - usb host ON
@! echo peripheral > /sys/devices/platform/musb_hdrc/mode - usb host OFF
@! echo external > /sys/devices/platform/i2c_omap.1/i2c-1/1-0048/twl4030_usb/vbussrc - external vbus ON
@! echo internal > /sys/devices/platform/i2c_omap.1/i2c-1/1-0048/twl4030_usb/vbussrc - external vbus OFF
Control App Development
Nook Tweaks : Source
Nook-Color-usbhost-switcher ( verygreen's old app ) : Source

My Focus
  • GPS
  • Audio Input
  • DVB-T
  • Home-Screen Widget
The Following 4 Users Say Thank You to Dj-Gutz For This Useful Post: [ Click to Expand ]
 
fattire
Old
#4  
fattire's Avatar
Recognized Developer
Thanks Meter 4371
Posts: 1,517
Join Date: Oct 2010
Guess I'll grab a spot just for fun.
The Following User Says Thank You to fattire For This Useful Post: [ Click to Expand ]
 
bassrebel
Old
#5  
Member
Thanks Meter 2
Posts: 90
Join Date: Jan 2009
Location: Orlando, FL
Has anyone managed to get the Xbox 360 wired controller working?? If so, what would I need to do to make it work? I'm using CM9
Phone: Samsung Focus
Tablets: Rooted Nook Color (CM7 @ 1300 Mhz )
32GB HP Touchpad 1500Mhz x 2
 
Dj-Gutz
Old
#6  
Senior Member - OP
Thanks Meter 83
Posts: 197
Join Date: Sep 2010
Location: Tel Aviv
Quote:
Originally Posted by Dj-Gutz View Post
[*]Game Controllers
CM9 users try USB/BT Joystick Center
Should work.. give it a try
 
bassrebel
Old
#7  
Member
Thanks Meter 2
Posts: 90
Join Date: Jan 2009
Location: Orlando, FL
I haven bought that app yet because once I plug in the controller, I see that the lights turn on but then go off and the controller Buttons won't work... am i missing anything??
Phone: Samsung Focus
Tablets: Rooted Nook Color (CM7 @ 1300 Mhz )
32GB HP Touchpad 1500Mhz x 2
 
Dj-Gutz
Old
#8  
Senior Member - OP
Thanks Meter 83
Posts: 197
Join Date: Sep 2010
Location: Tel Aviv
Yeah probably just the keylayout , the app will just make it easier I don't see why not give it a try , you can refund if it doesn't work
Or you can find a cracked version and if it works buy the app

If you want a "free" way use KeynrTracker.apk from this Thread
see if you can capture the key codes of the buttons
 
bassrebel
Old
#9  
Member
Thanks Meter 2
Posts: 90
Join Date: Jan 2009
Location: Orlando, FL
I just tried it and the same... it lights but after half a second it just turns off... will it need external power?? I checked behind the controller and it says 5v - 400mA
Phone: Samsung Focus
Tablets: Rooted Nook Color (CM7 @ 1300 Mhz )
32GB HP Touchpad 1500Mhz x 2
 
martian21
Old
#10  
martian21's Avatar
Senior Member
Thanks Meter 38
Posts: 276
Join Date: Sep 2010
Location: Fort Wayne, IN
Quote:
Originally Posted by bassrebel View Post
I just tried it and the same... it lights but after half a second it just turns off... will it need external power?? I checked behind the controller and it says 5v - 400mA
Almost certainly will require external power. 400mA > 100 mA. Standard USB ports can source up to 500 mA so there are going to be a LOT of USB devices that don't work without external power on the NOOK.
Current Phone:
Galaxy Nexus - Verizon
ROM: AOKP

Current Tablet:
Acer Iconia A500
ROM: Flexreaper

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes