[WIP] USB Host support (working)

Search This thread

Renate

Recognized Contributor / Inactive Recognized Dev
This is chinese for me again, sorry...

Ni hao ma?

Ok, no problem.

Here is the official (interim, hacked) way to get your Nook to be an MP3 player.

  1. Root
  2. Install mali100's uImage with USB host mode and audio drivers
  3. Install superuser.apk and su
  4. Install UsbMode-1.4.apk (see below)
  5. Install AudioCtl-1.0.apk (see below)
  6. Create the text file /system/etc/asound.conf as shown here
  7. Plug in USB audio adapter through a special OTG cable adapter
  8. Using UsbMode, set in host mode
  9. Run AudioCtl, it should make beeping noises
  10. Go to your file manager and select a suitable song to play
  11. Goto step #10

AudioCtl is very much a version 1.0
It is necessary to use now as a workaround due to problems with mediaserver.
You only need to run it once after each time of turning on the USB audio adapter.
In the future, AudioCtl will have useful features.

Note: Ignore all that stuff about ps, kill, mediaserver, etc. AudioCtl obviates all that.
 

Attachments

  • usbmode1.jpg
    usbmode1.jpg
    47.5 KB · Views: 585
  • usbmode2.jpg
    usbmode2.jpg
    44.3 KB · Views: 528
  • audioctl.jpg
    audioctl.jpg
    18.3 KB · Views: 430
Last edited:

Gogolo2

Senior Member
Nov 30, 2011
118
8
thank you very much, I just want to connect a keyboard. I realize that mediaserver is no concern here.
but I just can't get it working. I successfully installed uImage, but is uRamdisk also required? If so, How?

I've read the whole thread but can't find a step by step howto. sorry I may have missed something.
 

Renate

Recognized Contributor / Inactive Recognized Dev
You do have an adapter that specifically says "OTG"?
You are using the UsbMode application (as above)?

Plug in OTG adapter & keyboard
Go to UsbMode
Hit "Off"
Hit "Host"
Did the green LED on the Nook go on solid? No => hit "Peripheral", then "Host"
Now the green LED is on
Does it say "keyboard"? No => unplug keyboard from adapter, then reinsert.
It shows keyboard.

If you can never get the green LED to go on solid:
Are you sure that you have an OTG adapter there?
You did hit "Off" before "Host"?
You did try "Peripheral", then "Host".
Try with just the OTG adapter to get the green LED on.

It should not be that tricky to get the keyboard recognized.
It is a bit more tricky to get it using USB and charging when using a back-powered hub (for advanced users).
 

Gogolo2

Senior Member
Nov 30, 2011
118
8
Thanks very much for your kind help!

It is weird: The green lamp is on, it says: keyboard: none, kbd:2

Sometimes the upper row is functioning (multimedia keys like "play/pause" and "E-Mail" etc. but none of the others). May it be that there are actually two keyboards (as it is recognizing kbd:2) one of them a multimedia one and it only is able to connect to the second?

Thanks again.
 

Renate

Recognized Contributor / Inactive Recognized Dev
Yes, "multimedia" keyboards are actually two separate and unrelated devices.
What "None" is telling you is that there is no recognized qwerty or numeric keyboard attached.
What "Kbd:2" is telling you is that are two event style things on the system.

Can you try another keyboard? The host mode seems to be working fine.

What does View USB tell you?
 

nrseife

Senior Member
Jun 16, 2010
181
7
micro USB to Audio Jack Converter

Hi renate NST, will this work in your opinion?:
http://www.amazon.com/gp/product/B0...onics&tag=5336653508-20&qid=1327504575&sr=1-6
I have not tried yet your instructions to fix audio support via usb....do you believe that you a "simple" solution (I guess I am lazy) that requires running only one app (or copying a few files to the NST using Root Explorer) will be available soon?
Thanks for all your good work!
 

Renate

Recognized Contributor / Inactive Recognized Dev

No. Many cell phones have non-standard micro USB connectors with separate pins for audio.
What you indicated was a break-out cable for these extra contacts that the Nook does not have.

You need an OTG adapter, I have this: http://www.amazon.com/dp/B005FUNYSA

And a USB audio adapter, I have this: http://www.amazon.com/dp/B002R33VWW
(Only because it was the cheapest thing that I could buy locally.)
You can buy similar things for anywhere from $2 to $10.
 

zholy

Member
Sep 13, 2011
46
10
Hi Renate...

Do you know why, when I run your audio apk - it tells me BEEPING HAS FAILED ???

I did everything according to your instructions:
- your USB apk finds the adapter (it looks like in your picture under 4)
- asound.conf is in system/etc (I've created a txt file, later renamed the end to conf)

Any ideas/suggestions ??? Thank you in advance.

P.S. : I'm using ES File Explorer to play the mp3 (will check other programs as well)
 
Last edited:

Renate

Recognized Contributor / Inactive Recognized Dev
"Beeping has failed" is when an error is thrown when using ToneGenerator.
It's probably related to not finding any hardware.

Step 1: Does the View USB show the device and have little black dots on the end that indicate that drivers are loaded?

Setp 2: What does this say:
Code:
#alsa_aplay -L
default:CARD=Dummy
    Dummy, Dummy PCM
    Default Audio Device
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=default
    C-Media USB Audio Device   , USB Audio
    Default Audio Device

I tried again to play an audio file using alsa_aplay, it used to work.
I can't seen to get it to work now, despite normal file manager playing of MP3s working fine.
I'll have to look into that one too.


Oops, I was playing a blank file. :eek:

Step 3: The first time that you run AudioCtl after plugging in your USB audio adapter do you get this in logcat?

Code:
D/Temblast( 1321): Setting speakerphone on
I/DEBUG   (  980): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  980): Build fingerprint: 'generic/zoom2/zoom2/zoom2:2.1/ERD79/1.1.2:user/test-keys'
I/DEBUG   (  980): pid: 983, tid: 983  >>> /system/bin/mediaserver <<<
I/DEBUG   (  980): signal 11 (SIGSEGV), fault addr fffffff4
I/DEBUG   (  980):  r0 fffffff4  r1 bec319b8  r2 00000000  r3 000207c8
I/DEBUG   (  980):  r4 000207c0  r5 00000000  r6 00000000  r7 00020588
I/DEBUG   (  980):  r8 00000000  r9 00000000  10 00000000  fp 00000000
I/DEBUG   (  980):  ip 00000008  sp bec319c8  lr a9d1c56b  pc ab884c9e  cpsr 80000030

That is, does it kill mediaserver?
 
Last edited:

zholy

Member
Sep 13, 2011
46
10
OK...the first problem are the dots. I don't have them.

What does that mean / how can I fix that ?

Sent from my MB526 using xda premium
 

Renate

Recognized Contributor / Inactive Recognized Dev
OK...the first problem are the dots. I don't have them.

Well, that is your problem.

Can you see your USB audio adapter similar to the bottom of the middle image in:
http://xdaforums.com/showpost.php?p=24824407&postcount=183

There should be 3 or possibly 4 branches, control, streaming, streaming.
You won't have HID unless there are some volume or mute buttons on the thing.
Compare it to a keyboard or something that does have black dots.

No black dots means that no compatible driver was found.

Tell me the VID/PID or post a screenshot.

(If you see anything besides the first line of "MUSB HDRC Host Driver" then you have host mode with an OTG cable working.)
 

zholy

Member
Sep 13, 2011
46
10
Here is the picture of my nook once I plug everything in. With a memory stick I do have the black dot (although I don't know, where to look for it when it comes to the explorer :) ... I'll search through the forum for this)

Thanks for any suggestions.

Sent from my MB526 using xda premium
 

Attachments

  • uploadfromtaptalk1335182788772.jpg
    uploadfromtaptalk1335182788772.jpg
    131.1 KB · Views: 314

zholy

Member
Sep 13, 2011
46
10
Automount? No.

Code:
mount -o rw,remount rootfs /
mkdir /thumb
mount -t vfat /dev/block/uba1 /thumb

I can easily get a thumb drive to work on a hub, I've not gotten mine to work plugged directly into the Nook.

I've managed to find my THUMB/Memory Stick connected directly to the nook. I've used your code and it worked on the first hit (I've used Gscript)
 

zholy

Member
Sep 13, 2011
46
10
Gentlemen ... with all your projects and mind being focus on other bits and pieces - do you still work on this one? To make it close to 100% working? ( like volume, mic, ...)

Just asking ...
 

Renate

Recognized Contributor / Inactive Recognized Dev
and ladies...

We're still working on recording, Skype and getting it to work without kicking mediaserver.

Volume works fine, you just have to use a USB keyboard or an USB audio adapter with HID volume buttons.
Don't you get a popup graphic of a speaker with dots under it?
 
  • Like
Reactions: zholy

Top Liked Posts

  • There are no posts matching your filters.
  • 18
    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!)
    7
    This is chinese for me again, sorry...

    Ni hao ma?

    Ok, no problem.

    Here is the official (interim, hacked) way to get your Nook to be an MP3 player.

    1. Root
    2. Install mali100's uImage with USB host mode and audio drivers
    3. Install superuser.apk and su
    4. Install UsbMode-1.4.apk (see below)
    5. Install AudioCtl-1.0.apk (see below)
    6. Create the text file /system/etc/asound.conf as shown here
    7. Plug in USB audio adapter through a special OTG cable adapter
    8. Using UsbMode, set in host mode
    9. Run AudioCtl, it should make beeping noises
    10. Go to your file manager and select a suitable song to play
    11. Goto step #10

    AudioCtl is very much a version 1.0
    It is necessary to use now as a workaround due to problems with mediaserver.
    You only need to run it once after each time of turning on the USB audio adapter.
    In the future, AudioCtl will have useful features.

    Note: Ignore all that stuff about ps, kill, mediaserver, etc. AudioCtl obviates all that.
    5
    USB Host Mode Swicth for Nook Simple Touch

    Attached is a Nook Simple Touch version of verygreens USB Host Mode switching app.

    Requires properly installed "su" in /system/bin

    Let me know if there are problems.
    5
    Ok, here's a summary.
    Depending on what you want to do not all of this may be required.

    For basic playback
    For basic recording or Skype
    • Modify /system/lib/hw/libaudio.so
      Code:
      [00009188] B1 F5 FA 54 => 70 BD 00 BF
      [000091EC] 6C 33 => 00 05
    • Patch /system/framework/framework.jar with AudioRecord.smali using mergesmali, in signature, in Nook121patch
    For recording directly through ALSA
    • Recorder.apk, in signature
    • Modify /system/etc/permissions
      Code:
         <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
             <group gid="sdcard_rw" />
             [b]<group gid="audio" />[/b]
         </permission>
    Jeez, it seems like a lot.
    4
    Is it possible to change the keyboard layout?

    Of course.

    There are two levels of processing turning a key press into a character.
    The first is mapping of the scan code into a key code.
    The second is mapping the key code and meta keys (shift, alt, etc) into a character.

    The first mapping is done using files like /system/usr/keylayout/qwerty.kl
    The second mapping is done using files like /system/usr/keychars/qwerty.kcm.bin
    The first file is conveniently in plain text, the second is a simple binary file.

    If you are simply swapping keys around you only need to change the .kl file
    If you want to make it so that shift 4 is Euro instead of dollar you need to change the kcm.bin file.

    You can just edit the .kl file. Before:
    Code:
      key  21  Y
    After:
    Code:
      key  21  Z
    This would make the key layout more "German-like" by making the center key in the top alpha row be considered the 'Z' key.

    The .kcm.bin are compiled files from source.
    I haven't looked into where the compiler comes from, I just modify the stock kcm.bin by hand.

    The file is broken down into 16 byte chunks with a 16 byte header.
    Here is the chunk for C (on my modified version):
    Code:
    000100 1F 00 00 00 43 00 32 00 63 00 43 00 E7 00 C7 00
    This means:
    • This chunk is about KEYCODE_C (0x1f) (uses Android key codes)
    • The visual for this key is 'C' (0x0043)
    • On a numeric keypad this would dial a 2 (0x0032) as in ABC on a phone
    • The unshifted UTF-16 value is 'c' (0x0063)
    • The shifted UTF-16 value is 'C' (0x0043)
    • The alt modified UTF-16 value 'ç' (0x00e7)
    • The alt-shift modified UTF-16 value is 'Ç' (0x00c7)

    You can also use alt combos for combining diacritics:
    • 0x0300 grave accent
    • 0x0301 acute accent
    • 0x0302 circumflex accent
    • 0x0303 tilde accent
    • 0x0308 umlaut accent

    To replace these files on your Nook, you will need to remount your system as R/W:
    Code:
    mount -o rw,remount /dev/block/mmcblk0p5 /system

    You can get fancier if you want to have some USB keyboards US and some Belgian.

    I await my shipment of Belgian chocolates. :D