Enable an usbkeyboard for OpenWRT
Insert those modules:
1 2 3 | insmod /lib/modules/2.4.30/input.o insmod /lib/modules/2.4.30/evdev.o insmod /lib/modules/2.4.30/hid.o |
Download HERE
To compile those modules yourself, you need to enable the following kernel option:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Input core support —> Input core support < > Keyboard support < > Mouse support < > Joystick support Event interface support < > User level driver support USB support —> — USB Human Interface Devices (HID) USB Human Interface Device (full HID) support [*] HID input layer support [*] /dev/hiddev raw HID device support </code Info: I couldn’t use the keyboard module (keybdev.o), when i inserted this module he complained about undefined references: <code> unresolved symbol handle_scancode unresolved symbol keyboard_tasklet unresolved symbol kbd_ledfunc |
I *guess* this is because the keyboard.o module doesn’t exist.
Now create a new modules.d config file, /etc/modules.d/61-usb-hid with this content:
1 2 3 | input evdev hid |
Insert the modules manually or reboot your OpenWrt box.
Syslog when you connect the usb keyboard:
1 2 3 4 5 | Jan 1 00:01:45 OpenFoensi kern.info kernel: hid-core.c: v1.8.1 Andreas Gal, Vojtech Pavlik <vojtech@suse.cz> Jan 1 00:01:45 OpenFoensi kern.info kernel: hid-core.c: USB HID support drivers Jan 1 00:01:51 OpenFoensi kern.info kernel: hub.c: new USB device 01:03.0–2.3, assigned address 8 Jan 1 00:01:51 OpenFoensi kern.info kernel: input: USB HID v1.11 Keyboard [04d9:1203] on usb2:8.0 Jan 1 00:01:51 OpenFoensi kern.info kernel: 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 handle these keyboard events, its time for cmdpad (http://cmdpad.sourceforge.net/). this app will listen to a /dev/input/eventX device (i our case a USB keyboard) and execute a program for each key pressed/released/keep pressing.
there seems to be a similar tool called mpc keyboard daemon, http://simon.arlott.org/sw/mpckbd/, but i didn’t test it.
I compiled cmdpad for OpenWRT, but I didn’t manage to create an ipkg package. You can get my poor ipkg attempt here or download just the binaries here.
1 2 3 | install cmdpad 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 modules, source: http://sokrates.mimuw.edu.pl/%7Esebek/openwrt/ (http://sokrates.mimuw.edu.pl/%7Esebek/openwrt/packages/), extract them to /lib/modules/2.4.30/
Create /etc/modules.d/72-snd-usb-audio:
1 2 3 4 5 6 7 8 9 10 11 | soundcore 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 |
Configure mpd:
I mount a usb stick to /mnt/stick1, where the _mp3 subdirectory contains all my mp3’s.
My mpd configuration, /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 format “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 forget to create those directories:
mkdir /mnt/stick1/_mp3/.mpd
mkdir /mnt/stick1/_mp3/playlist
Start mpd, this will create 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 package “kmod-usb-ohci” or your usb subsystem will get messy, for example my usb 2.0 stick didn’t work anymore, error: usb.c: USB device not responding, giving up (error=-145)
DISPLAY
First I wanted to use a “regular” LCD display, but compared to a palm device on ebay, they are way too expensive. I bought some palm devices on ebay and the best device I think is the palm 3c. Nice color display and a rechargeable battery. I modded a palm 3x device, so I don’t need batteries anymore but take the power from the usb port. This has a big drawback, when the device loose power, all installed applications are gone. You could copy some apps to the internal ROM but there is just 50k free space.
PalmORB (http://palmorb.sourceforge.net/) is your friend, this application emulates an Matrix Orbital LK204-25 LCD. My palm use a serial connector, so I need an usb/serial convertor. I had trouble with an FTDI adapter, now I use an PL2303 adapter. It looks like you only can go up to 9600bps, else the connection gets fluffy, but this should be enough for our display.
On the Openwrt you need to install LCD4Linux, I’ve patched the mpc plugin, check this article for a how-to.
CONCLUSION
There is still much to do here’s a small list…
Current Issues:
– My cheap USB sound card seems to buffer the sound, when i want to pause a song, the device keeps playing for about 4 seconds.
– I need to write some scripts for mount / dismount the USB stick, rescan the music source.
– Currently I’m working on a gps plugin for LCD4Linux.
– …
Feel free to support me, contact me at michu at neophob dot com.
.

5 Comments
1 Urs wrote:
I have a similar setting:
WL-HDD, OpenWRT, USB-Sound, mpd.
Unfortunately, the CPU is used more than 100% :-(
Have you done special settings to get smooth playing songs?
Greets
Urs
2 michu wrote:
nope.. did you check, what’s the reason for 100% cpu? is it mpd?
3 Urs wrote:
It is mpd. I have 2 mpd processes who need about 45% cpu and 2 mpd processes who need about 2%, together with other tasks the cpu is full.
/proc/cpuinfo say I have just 82.94 BogoMIPS.
On the other hand, madplay uses about 60% cpu time. So it is possible with this cpu.
I think that mpd is doing some re-sampling or mixing. I tried a lot of settings for mpd but couldn’t turn down the cpu usage.
Maybe I really have to start compiling mpd on my own.
4 michu wrote:
what kind of distro you use? i guess its a 3rd party lib which is not optimized for embedded usage… do you play mp3 files or other kind of format? what kind of output format you use? did you try the null output?
5 Urs wrote:
It works now!
I recompiled mpd just with libmad and alsa output.
The average CPU load is 70%, but the device has nothing more to do as playing mp3. Nevertheless, thank you for your ideas.
How I like free software! :-)