[WIP] USB Host support (working)

Search This thread

dnastase

Member
Feb 20, 2009
34
9
This instance of the keyboard works fine on every other computer I've tried it.
The type is also fine, I have five of them and use them at work and home, never had any issues.

Model number is: A1242.
This is what lsusb reports: ID 05ac:021d Apple, Inc. Aluminum Mini Keyboard (ANSI)

Maybe it's my kernel.

Linux nook 2.6.29-omap1 #176 PREEMPT Wed Dec 5 12:36:15 CET 2012 armv7l GNU/Linux

It's the install-kernel-usbhost-176.zip that was vehiculated. But I've tried the binaries.zip thing, same behaviour.
 
N

NOOK!E

Guest
It worked!

My Perixx keyboard and OTG cable just came in the mail. I installed the patched uImage and uRamdisk, installed UsbMode.apk, followed the instructions, and HOORAY! It works! My keyboard works on my NSTG!

Thanks so much, Renate and team! :D
 

ameth

Member
Aug 8, 2010
15
1
Hello!
Is it possible to port that uImage/Ramdisk or binaries to Nook GlowLight 2013?
3641221.jpg


I have both of them - Nook Simple Touch (no Glowlight) and Nook GlowLight 2013 (without SD-card and physical buttons, like on a picture).
So this stuff works perfectly on NST, but requires a propriate kernel for NGL.
 
N

NOOK!E

Guest
Hello!
Is it possible to port that uImage/Ramdisk or binaries to Nook GlowLight 2013?

[image]

I have both of them - Nook Simple Touch (no Glowlight) and Nook GlowLight 2013 (without SD-card and physical buttons, like on a picture).
So this stuff works perfectly on NST, but requires a propriate kernel for NGL.

As of right now, nobody has attempted it (at least, to XDA's knowledge), but if you have experience with Nooks, you may as well give it a shot if you like.
 

FreyaBlack

Member
Sep 10, 2013
23
1
Thanks for the updated Qwerty.kl file Renate! It's a really big improvement. :)

I tried to edit it for UK keyboards and while I managed to get the # (hash) key working okay I havn't found a way to swap the " and the @ with one another which is the other big infuriating difference on UK keyboards. The file only seems to let you change the function of the entire key and not just the shifted state. On UK keyboards if you press shift and 2 you get " whereas there is a special button for @ next to the semicolon.

It's a big problem as it's quite common to need to quote people and obviouly email and twitter both make use of the @ symbol too.

Is there an easy way to fix this?
I havn't found one yet.

Freya
 

Renate

Recognized Contributor / Inactive Recognized Dev
The mapping of keyboard to character occurs in two stages.
The first is the mapping of the the scancode to the button.
The second is the mapping of the button and the shift/alt keys to the character.
Use your hex editor (or whatever) on qwerty.kcm.bin

Code:
modfile qwerty.kcm.bin 4a 22 [i]// switch over the two to double quote[/i]
modfile qwerty.kcm.bin  34a 40 [i]// switch over the single quote to at sign[/i]
 
  • Like
Reactions: FreyaBlack

aiamuzz

Senior Member
Dec 24, 2011
509
46
My Perixx keyboard and OTG cable just came in the mail. I installed the patched uImage and uRamdisk, installed UsbMode.apk, followed the instructions, and HOORAY! It works! My keyboard works on my NSTG!

Thanks so much, Renate and team! :D
will a usb flash drive be readable through the OTG ?
What all USB devices does it support ?
3G dongle, etc ... not that it make sense at the cost of battery, but just trying to understand the scope.

Where can i find the instruction set to get USB host up and running(i have the latest 1337 ROM and UBHost apk installed) ?
I tried connecting the USB flash drive and opened the USB host apk tried clicking on the various option, but never got any response, the flash drive light never came up.

thanks,
 
Last edited:
N

NOOK!E

Guest
@aiamuzz

Your Nook will recognize pretty much all USB storage devices (USB sticks, cameras, voice recorders, even other phones/tablets) and keyboards. I don't know about much more than that.

For getting stuff all set up, take a look at my guide here.
 

Renate

Recognized Contributor / Inactive Recognized Dev
A quick way to tell if something is at least semi-supported:
Look at your USB tree with the device connected in UsbMode.apk.
If there is a check mark next to the interface then there is a driver at least loaded.
Storage devices will still need to be mounted somehow (with a daemon or in init.rc or manually or somewhere).
 

nhedgehog

Senior Member
Oct 21, 2009
91
22
TTS working?

I still haven't managed to figure out with the drivers how to make a good quality recording,
but I did get the text-to-speech working.

As all TTS, it is amusing.
You have to fill /system/tts/lang_pico with language packs that you download and copy over.

I know this thread is quite old but back to my Nook ST I stumbled over audio vio OTG and got a working adaptor. Now I'm struggling to get other TTS than pico working on it. I can't even select between different TTS machines.
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,990
526
Ok, here's a summary.
Depending on what you want to do not all of this may be required.

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

I do not have libaudio.so in /system/lib/hw. Rather it is in /system/lib. Is that right?

If so, how do I make the changes (which look like HEX?) Can I do that through ADB shell using the literal lines shown?

I *think* I have managed to do the smali work on framework.jar, but the other modification is puzzling to me.
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,990
526
The good news is that I didn't brick my NST :D

But I don't seem to have made any discernible difference either, except that in AudioCtrl there is now a long list of recording formats showing. I've tried the test call in Skype and the app doesn't seem to know I have a microphone. I downloaded a couple of simple voice recording apps from the PlayStore and while most of them run they don't seem to record anything except for possibly a low-volume level rumble that might be imagined as an extreme slo-mo voice playback. Maybe.

I've checked to make sure the hex edits are actually there (they are). I didn't have a copy of libaudio.so in /system/lib/hw (mine was in /system/lib) so after the initial failure I added a copy of the file to /system/lib/hw and rebooted. No difference.

There's no way for me to check the framework.jar, I suppose, to see if the mergesmali operation went correctly, but the file is clearly not so corrupted that the NST can't do it's normal stuff and the size of the amended file is 14 KB larger than the original, so something happened there. I did NOT sign the modified jar because I didn't know how to get the system signature on it and I figured it would either work or not.

So what do I look at next?
 

stadros83

Senior Member
Sep 19, 2008
153
1
Paris
Hi,

Sorry if it was already asked but didn't find ...

Is it possible to use the Host mode and to charge the Nook (and the device connected) at the same time with a USB POWERED HUB ?
 

Renate

Recognized Contributor / Inactive Recognized Dev
Yes, it is possible with the Nook to charge while in USB host mode.
Because this is a bit of an unusual thing to do, you might use the UsbMode.apk (below) to monitor/adjust the charging current.

You will need something that will feed current back to the Nook.
There are "Y" power cables that do that, but my favorite is just to use a "back-powering" USB hub.
Some cheap USB hubs don't isolate the wall power supply from the upstream USB.
Other USB hubs have a diode which you can just short across.

See: http://xdaforums.com/showthread.php?p=25639514#post25639514
 

albrow

Member
Apr 16, 2015
22
4
UsbMode-2.1 with SuperSU

Hi

As SuperUser hasn't been updated for a few years, I thought I would try swapping over to SuperSU (2.6.5, for compatibility with some older apps). After doing so, UsbMode has started to throw up a write error when selecting Peripheral, OTG or Host mode. At a guess, it looks to me like UsbMode-2.1 isn't requesting root in a way that SuperSU can recognise.

Is it just my NST (running 1.2.1 with latuk's kernel) which is doing this, or can anyone else replicate it? And can anyone work out why it might be doing it?

Alex
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,990
526
Hi

As SuperUser hasn't been updated for a few years, I thought I would try swapping over to SuperSU (2.6.5, for compatibility with some older apps). After doing so, UsbMode has started to throw up a write error when selecting Peripheral, OTG or Host mode. At a guess, it looks to me like UsbMode-2.1 isn't requesting root in a way that SuperSU can recognise.

Is it just my NST (running 1.2.1 with latuk's kernel) which is doing this, or can anyone else replicate it? And can anyone work out why it might be doing it?

Alex

Back in the day I was allowing my apps to update from the Market when a new version became available that was still compatible with the NST. One day, SuperUser updated and started behaving oddly, not to mention was not fully readable on the screen when it threw up a message. I went back to the original SU provided with NookManager and turned off automatic updating on all my NST apps.

I'm running latuk's kernel with the USB audio enhancements on 1.2.1. I've not had any issues with the older version of SU.

Realistically, the chance of a useful update for apps that will run on the NST seems remote. Most of us search diligently for older versions that run well and bring out the best in our devices.
 

UncaughtError

New member
Jun 7, 2016
3
0
sound clicking?

Hey guys! First of all I want to say a big Thanks to Renate and to all of you guys.

I have a lot of fun with my NST, and just for fun (c) I decided to play with audio usb (C-media).
Everything is OK, but (sadly) sound is "clicking" 90% of the time, sometimes (randomly) sound is clean and clicks (very silent) appear if I type something in terminal (I have sshd on Nook). I dunno about the reason, I've tried anything: killing mediaserver, killing some heavy aps, reconnecting usb card...

alsa:
HTML:
defaults.ctl.card 1
defaults.pcm.card 1
defaults.timer.card 1

ctl.AndroidOut
{
   type hw
   card 1
}

ctl.AndroidIn
{
   type hw
   card 1
}


alsa_amixer
HTML:
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 151
  Mono:
  Front Left: Playback 150 [99%] [-1.37dB] [on]
  Front Right: Playback 150 [99%] [-1.37dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: Playback 0 - 127 Capture 0 - 16
  Mono: Playback 0 [0%] [0.00dB] [off] Capture 0 [0%] [0.00dB] [on]
Simple mixer control 'Auto Gain Control',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [on]
 

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