Friday 7 September 2007

Adding keypad and LCD display to the ASUS WL-500g wireless client

The UI for the wireless player is a Targus usb numeric keypad and a homemade usb 20x4 LCD display based on Phil Endecott's slugterm. Unfortunately, as explained in this OpenWrt forum post, USB HID (Human Interface Devices) support is not enabled by default in the OpenWrt kernels - you have to enable it in the kernel config file. After some googling, I found this howto which describes which kernel options are required - but first I needed to set up the build environment.

Following the OpenWrt wiki again, I download the OpenWrt BuildRoot onto my Linux laptop -

svn co https://svn.openwrt.org/openwrt/trunk

and then ran -

make menuconfig

- selected the 'Broadcom BCM947xx/953xx [2.4]' target system otherwise left everything else as default, then did -

make V=99

to build the toolchain (as well as all the packages and kernel itself which we don't really need to do yet - anyway of stopping this?). After a very long time (left overnight ..) it finished.

Now I was able to enable the required kernel configuration options which allow the usb-hid kernel modules to be built. Following the BuildRoot wiki again, I changed the kernel configuration settings by cd'ing to the linux build directory and running make menuconfig, e.g.:

cd build_dir/mipsel/linux
make ARCH=mips menuconfig

- selected the following kernel options -

Input core support --->
Input core support
[M] Keyboard support
< > Mouse support
< > Joystick support
[M] 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

- then had to edit both -

package/kernel/modules/other.mk
package/kernel/modules/usb.mk

to remove the dependencies on kernel-2.6 for the input-core, input-evdev and usb-hid modules.

I removed the stuff from the previous build to force modules to be rebuilt-

rm .image .modules

- then returned to the top level directory and ran -

make menuconfig

again, selected the newly enabled kernel module selections (input-core, input-evdev and usb-hid)

Input Kernel modules --->
Other modules --->
[M] kmod-input-core
[M] kmod-input-evdev
USB Support --->
[M] kmod-usb-hid

and then -

make V=9

This generated the three required packages in bin/packages -

kmod-input-core_2.4.34-brcm-1_mipsel.ipk
kmod-input-edev_2.4.34-brcm-1_mipsel.ipk
kmod-usb-hid_2.4.34-brcm-1_mipsel.ipk

I copied these to the router and installed them with ipkg -

ipkg install kmod-input-core_2.4.34-brcm-1_mipsel.ipk
ipkg install kmod-input-evdev_2.4.34-brcm-1_mipsel.ipk
ipkg install kmod-usb-hid_2.4.34-brcm-1_mipsel.ipk

Now when the usb keyboard is inserted, dmesg gives -

hub.c: new USB device 00:04.0-1, assigned address 3
hub.c: USB hub found
hub.c: 3 ports detected
hub.c: new USB device 00:04.0-1.3, assigned address 4
input: USB HID v1.10 Keyboard [ORTEK USB Keyboard Hub] on usb1:4.0
input: USB HID v1.10 Device [ORTEK USB Keyboard Hub] on usb1:4.1

and the keyboard is correctly recognised!