[WIP] USB Host support (working)

Search This thread

Renate

Recognized Contributor / Inactive Recognized Dev
The first thing to check is on the 2nd page of UsbMode, the View USB.
The audio adapter should be listed under the tree with a 3 or 4 interfaces.
They should all have little black dots to the right.
This indicates that the drivers for that interface are loaded.

The next thing to do is to see that ALSA recognizes the adapter.
Get yourself the ALSA utilities and try alsa_aplay (or however it's named).
alsa_aplay -l will list all devices.
You should have a dummy and your adapter.
 

digixmax

Senior Member
Jan 17, 2011
2,129
682
The first thing to check is on the 2nd page of UsbMode, the View USB.
The audio adapter should be listed under the tree with a 3 or 4 interfaces.
They should all have little black dots to the right.
This indicates that the drivers for that interface are loaded.
The audio adapter (0d8c:000c C-Media USB Headphone Set) tree has 4 lines: "1.0 - ..." to "1.3 - 03:00 HID" and only the last line has black dot at the end.

Does this mean I have to find and install the drivers for the adapter?
The next thing to do is to see that ALSA recognizes the adapter.
Get yourself the ALSA utilities and try alsa_aplay (or however it's named).
alsa_aplay -l will list all devices.
You should have a dummy and your adapter.
Do I install these utilities in /data/app?

Thanks.
 

digixmax

Senior Member
Jan 17, 2011
2,129
682
I've got the equally cheesy 0d8c:0008 C-Media.
I forget if the kernel had support for both the 0008 and the 000c.
These adapters look identical, I am wondering how one tells which version is being sold by a seller?
You do have a kernel with audio support?
...
I installed the kernel (plus all the stuffs) in usb-host-mt-pack_0.1.zip.

Should I try usb-host-mt-sound-pack_0.2.zip? What does "nopowercheck" in "uImage_mt_usbhost_nopowercheck_115" (which is the version in this pack), mean?
 

Renate

Recognized Contributor / Inactive Recognized Dev
The power/no power stuff was when mali100 was running into issues.
No power check was supposed to resolve it.
I'm not sure what the limit was.
With a powered hub it makes no difference.

As always, if you are having some problem, at least check using a powered hub.

OSes are supposed to find a driver by either VID/PID or else interface class.
That's why both my cheapy USB adapter and my Lexicon Alpha interface work.
I'm not sure why the 000c has such problems, but I think others report it too.

Did you at least look at dmesg when plugging in to see if something comes up?
 

digixmax

Senior Member
Jan 17, 2011
2,129
682
...
OSes are supposed to find a driver by either VID/PID or else interface class.
That's why both my cheapy USB adapter and my Lexicon Alpha interface work.
I'm not sure why the 000c has such problems, but I think others report it too.

Did you at least look at dmesg when plugging in to see if something comes up?
Attached is the captured dmesg log, it says (near the end) the adapter I have (v0d8c p000c) is not supported.

I will have to go hunting for its other cheesy cousin :). Does you adapter have sticker with UPC-like barcode ID on the back and if so what's is the ID#?

Thanks.
 

Attachments

  • dmesg.zip
    4.6 KB · Views: 10
Last edited:

Renate

Recognized Contributor / Inactive Recognized Dev
Sorry, the sticker that was on it fell off long ago.

The update to 1.2 has caused some problems with USB host mode.
I'd like to know if anyone else has had the same experience with this.
I'm surprised that I have not heard a lot about this.
Is it simply that most people haven't done an upgrade?

First I am having a problem with Superuser.apk
I haven't looked into this at all yet.

Also, the changes that they made to the EpdController broke my last version of UsbMode.apk
I have a new version that runs correctly on any version of Nook.
It will also at least not crash if you try to run it on non-Nook devices (although it won't be useful).
Without Superuser.apk working its utility is limited.
(The new version is not uploaded yet.)

I can get a keyboard to appear in the UsbMode.apk tree with its driver loaded,
but somehow the Android system does not acknowledge it as a keyboard.
The Caps Lock and Num Lock work, so the underlying parts are working.
Note that without Superuser.apk working the only way to get into host mode
is with the automatic switch using a powered hub and not through buttons on UsbMode.apk

I've temporarily switched back to 1.1.2 to check/scavenge some settings.
 

digixmax

Senior Member
Jan 17, 2011
2,129
682
In my case I have been holding off upgrading to v1.2 until the kinks in rooting process/tools get ironed out (I think Nook Manager just crossed that door) and until I hear how mods like usbhost fare with the new fw.
 

Renate

Recognized Contributor / Inactive Recognized Dev
Next problem is why I can't get a USB keyboard to work even though Linux sees it.

Logcat gives me this:
Code:
E/EventHub( 1051): could not open /dev/input/event3, Permission denied
E/EventHub( 1051): could not open /dev/input/event4, Permission denied

This seems to be an old, documented problem of a race condition between init and EventHub.

Has anybody experienced this?
 

Renate

Recognized Contributor / Inactive Recognized Dev
The problem with getting the keyboard recognized by Android seems to clearly be this ancient race condition.
To get a keyboard working with 1.2:
Use UsbMode (or a powered hub) to get Linux to recognize the keyboard.
UsbMode will show "Keyboard: None, Kbd:2"
In ADB shell, "stop", wait a bunch, "start"
Android will now have recognized the keyboard.
UsbMode will show "Keyboard: Qwerty, Kbd:2"
No, this is not the solution, merely a proof of concept.
 
  • Like
Reactions: mrWax

userbe

Member
Jun 17, 2007
35
1
print via usb with printshare

Need advice!

With usb-host-mt-sound-pack_0.2.zip on NST , all printers (HP's) connected and recognized perfectly in Renate's USB-MODE app . Like in attached image. But the printshare not see this usb print driver (see photo).

But look here http://www.youtube.com/watch?v=m-8bnejng3Y on 3.48 in timeline, in SGS3 all work perfect. Seemingly some files or settings are missing from nook?

Thanks
 
Last edited:

Renate

Recognized Contributor / Inactive Recognized Dev
That's interesting.
As I have no printer, I've not tried it.

As shown, your printer supports 4 interfaces, 3 proprietary and one generic.
The generic one has its driver loaded.

Does that application indicate the printer and can it read the model?
Edit: Oh, I can see that the USB mode is grayed out in the app.

Look in the /dev directory on the Nook and see which device is new.
Then try something like:
Code:
cat init.rc > /dev/[i][color=red]printerthingy[/color][/i]
 
Last edited:
  • Like
Reactions: mrWax

Renate

Recognized Contributor / Inactive Recognized Dev
There's a new UsbMode-1.7.apk available.
There is an important change that makes it work with the 1.2 or 1.2.1 update.
B&N's changes to the EpdController made former usage crash.
This version UsbMode works with old and new Nook Touch software.

The other change is mainly cosmetic:
Devices are displayed as 058f:6254:01, where it's vendor, product, configuration.
Interfaces are displayed as #0 - 09:00:00, where it's interface, class, subclass, protocol.
 
Last edited:

digixmax

Senior Member
Jan 17, 2011
2,129
682
So, is the process for getting USBHost on a NST 1.2.1 is to root, install usb-host-mt-sound-pack_0.2.zip, then UsbMode-1.7.apk?
 

Renate

Recognized Contributor / Inactive Recognized Dev
Yes, that's the gist of it.
We haven't had a lot of reports from the far side of 1.2/1.2.1

On my setup I'm running into what appears to be a well documented race condition.
I'm not sure why it appears now, I have to look into it.
The problem appears as Linux recognizing a keyboard but Android not recognizing it.
By restarting Android (not rebooting) I can make Android see a keyboard.

You'll need an OTG adaptor.
Using a small hub to at least get things started is a good idea.
 

DeanGibson

Senior Member
Apr 30, 2011
530
364
Seattle, WA
Nook Touch as serial monitor

I would like to use the Nook Touch, in conjunction with A Prolific USB-to-serial (RS-232) converter cable, to send and receive to a serial port device at 4800 or 9600 BAUD. I think I need:

  1. Rooted Nook Touch: done (v1.2.1)
  2. UsbMode.apk from RenateNST: not yet installed.
  3. OTG cable from Nook to USB-A/female: ordered four from Amazon.
  4. USB-to-serial (RS-232) cable w/ Prolific chip: done (I have 12).
  5. Serial program: For testing, I'll use Busybox's microcom, but GUI/touch application suggestions are welcome.
On my Acer A500, which has a USB host port, #4-#5 work fine; the A500 kernel recognizes the Prolific chip and creates /dev/ttyUSB. However, the A500 is running Android 4.0, so who knows about the kernel on the Nook Touch.

So, do I need anything else? Has anyone else done this?
 
Last edited:

userbe

Member
Jun 17, 2007
35
1
That's interesting.
As I have no printer, I've not tried it.

As shown, your printer supports 4 interfaces, 3 proprietary and one generic.
The generic one has its driver loaded.

Does that application indicate the printer and can it read the model?
Edit: Oh, I can see that the USB mode is grayed out in the app.

Look in the /dev directory on the Nook and see which device is new.
Then try something like:
Code:
cat init.rc > /dev/[i][color=red]printerthingy[/color][/i]

Hello Renate
Now I back to deal with Nook printing. I checked your suggestion to look at some additional device in DEV.
Indeed although USB MODE shows the correct name of the printer and has a black dot next to the name, in DEV, do not add any files.
I see only CONTROLC0 and two PCMC0D0.

How can we move forward?
Thanks for the help
 

userbe

Member
Jun 17, 2007
35
1
Those are the dummy audio interfaces.

If it loaded a driver, it should have created some device in /dev.

I'll have to look further.

I tried to connect the USB AUDIO which works well, and checked in DEV and I did not find any additional files? (Incidentally, the AUDIO works well, even audible and recording, but the buttons of volume_up, although which moves the blocks in volume bar, does not affect the sound level. I had a few times that the buttons volume up worked but in 90% of the time I connect the device it did not work?)
 

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