Enable an usbkey­board for OpenWRT

Insert those modules:

1
2
3
ins­mod /lib/modules/2.4.30/input.o
ins­mod /lib/modules/2.4.30/evdev.o
ins­mod /lib/modules/2.4.30/hid.o

Down­load HERE

To com­pile those mod­ules your­self, you need to enable the fol­low­ing ker­nel option:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Input core sup­port  —>
 Input core sup­port
   < >   Key­board sup­port
   < >   Mouse sup­port
   < >   Joy­stick sup­port
      Event inter­face sup­port
   < >   User level dri­ver sup­port


USB sup­port  —>
USB Human Inter­face Devices (HID)
          USB Human Inter­face Device (full HID) sup­port
       [*]     HID input layer sup­port
       [*]     /dev/hiddev raw HID device sup­port      
</code
Info: I couldn’t use the key­board mod­ule (keybdev.o), when i inserted this mod­ule he com­plained about unde­fined ref­er­ences:
<code>
unre­solved sym­bol handle_scancode
unre­solved sym­bol keyboard_tasklet
unre­solved sym­bol kbd_ledfunc

I *guess* this is because the keyboard.o mod­ule doesn’t exist.
Now cre­ate a new modules.d con­fig file, /etc/modules.d/61-usb-hid with this content:

1
2
3
input
evdev
hid

Insert the mod­ules man­u­ally or reboot your Open­Wrt box.

Sys­log when you con­nect the usb keyboard:

1
2
3
4
5
Jan  1 00:01:45 Open­Foensi kern.info ker­nel: hid-core.c: v1.8.1 Andreas Gal, Vojtech Pavlik <vojtech@suse.cz>
Jan  1 00:01:45 Open­Foensi kern.info ker­nel: hid-core.c: USB HID sup­port dri­vers
Jan  1 00:01:51 Open­Foensi kern.info ker­nel: hub.c: new USB device 01:03.0–2.3, assigned address 8
Jan  1 00:01:51 Open­Foensi kern.info ker­nel: input: USB HID v1.11 Key­board [04d9:1203] on usb2:8.0
Jan  1 00:01:51 Open­Foensi kern.info ker­nel: input: USB HID v1.11 Device [04d9:1203] on usb2:8.1

Now there should be 2 input devices:

1
/dev/input/event0   /dev/input/event1

Now we need to han­dle these key­board events, its time for cmd­pad (http://cmdpad.sourceforge.net/). this app will lis­ten to a /dev/input/eventX device (i our case a USB key­board) and exe­cute a pro­gram for each key pressed/released/keep press­ing.
there seems to be a sim­i­lar tool called mpc key­board dae­mon, http://simon.arlott.org/sw/mpckbd/, but i didn’t test it.

I com­piled cmd­pad for Open­WRT, but I didn’t man­age to cre­ate an ipkg pack­age. You can get my poor ipkg attempt here or down­load just the bina­ries here.

1
2
3
install cmd­pad to /usr/bin/
install cmdpad.conf to /etc/
install S70USBKbd to /etc/init.d/

the startscript looks like this:

1
2
3
/etc/init.d/S70USBKbd
#!/bin/sh
/usr/bin/cmdpad –quiet

SOUND
Install mod­ules, source: http://sokrates.mimuw.edu.pl/%7Esebek/openwrt/ (http://sokrates.mimuw.edu.pl/%7Esebek/openwrt/packages/), extract them to /lib/modules/2.4.30/

Cre­ate /etc/modules.d/72-snd-usb-audio:

1
2
3
4
5
6
7
8
9
10
11
sound­core
snd-page-alloc
snd
snd-rawmidi
snd-hwdep
snd-timer
snd-pcm
snd-mixer-oss
snd-pcm-oss
snd-usb-lib
snd-usb-audio
1
2
3
install alsa-lib ipkg
install alsa-utils ipkg
install mpd / mpc ipkg

Con­fig­ure mpd:
I mount a usb stick to /mnt/stick1, where the _mp3 sub­di­rec­tory con­tains all my mp3’s.

My mpd con­fig­u­ra­tion, /etc/mpd.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##################### REQUIRED ###########################
music_directory         “/mnt/stick1/_mp3/“
playlist_directory      ”/mnt/stick1/_mp3/playlist“
db_file                 “/mnt/stick1/_mp3/.mpd/mpd.db“
log_file                ”/mnt/stick1/_mp3/.mpd/mpd.log“
error_file              ”/mnt/stick1/_mp3/.mpd/mpd.error“
pid_file                ”/mnt/stick1/_mp3/.mpd/mpd.pid“
##########################################################

#audio device
audio_output {
       type            “oss“
       name            “my OSS sound card“
       device          ”/dev/dsp” # optional
       for­mat          “44100:16:2″ #optional
}

# OSS Mixer
mixer_type              “oss“
mixer_device            ”/dev/mixer“
mixer_control           “PCM

state_file              ”/mnt/stick1/_mp3/.mpd/mpdstate“

buffer_before_play      “0%”

Don’t for­get to cre­ate those direc­to­ries:
mkdir /mnt/stick1/_mp3/.mpd
mkdir /mnt/stick1/_mp3/playlist

Start mpd, this will cre­ate the db and searches for all mp3 files.

Now add all mp3 files to mpc:

1
# mpc listall | mpc add -

WARNING for asus wl500 users, DO NOT INSTALL the pack­age “kmod-usb-ohci” or your usb sub­sys­tem will get messy, for exam­ple my usb 2.0 stick didn’t work any­more, error: usb.c: USB device not respond­ing, giv­ing up (error=-145)

DISPLAY
First I wanted to use a “reg­u­lar” LCD dis­play, but com­pared to a palm device on ebay, they are way too expen­sive. I bought some palm devices on ebay and the best device I think is the palm 3c. Nice color dis­play and a recharge­able bat­tery. I mod­ded a palm 3x device, so I don’t need bat­ter­ies any­more but take the power from the usb port. This has a big draw­back, when the device loose power, all installed appli­ca­tions are gone. You could copy some apps to the inter­nal ROM but there is just 50k free space.

Pal­mORB (http://palmorb.sourceforge.net/) is your friend, this appli­ca­tion emu­lates an Matrix Orbital LK204-25 LCD. My palm use a ser­ial con­nec­tor, so I need an usb/serial con­ver­tor. I had trou­ble with an FTDI adapter, now I use an PL2303 adapter. It looks like you only can go up to 9600bps, else the con­nec­tion gets fluffy, but this should be enough for our display.

On the Open­wrt you need to install LCD4Linux, I’ve patched the mpc plu­gin, check this arti­cle for a how-to.

CONCLUSION
There is still much to do here’s a small list…

Cur­rent Issues:
– My cheap USB sound card seems to buffer the sound, when i want to pause a song, the device keeps play­ing for about 4 sec­onds.
– I need to write some scripts for mount / dis­mount the USB stick, res­can the music source.
– Cur­rently I’m work­ing on a gps plu­gin for LCD4Linux.
– …

Feel free to sup­port me, con­tact me at michu at neo­phob dot com.

.