[Nook Color Android Development] Dj-Gutz:
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

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

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

<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
[B][COLOR="Red"]<6>usb 1-1: rejected 1 configuration due to insufficient available bus power[/COLOR][/B]
<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

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

@! 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

[B]@! echo host > /sys/devices/platform/musb_hdrc/mode[/B] - usb host ON
[B]@! echo peripheral > /sys/devices/platform/musb_hdrc/mode[/B] - usb host OFF
[B]@! echo external > /sys/devices/platform/i2c_omap.1/i2c-1/1-0048/twl4030_usb/vbussrc[/B] - external vbus ON
[B]@! echo internal > /sys/devices/platform/i2c_omap.1/i2c-1/1-0048/twl4030_usb/vbussrc[/B] - 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