Wednesday 29 August 2007

Installing Music Player and usb sound card on the ASUS WL-500g wireless client

Following the wiki, I installed the appropriate kernel modules for an nfs client -
ipkg install kmod-fs-nfs
and then attempted to mount the filesystem export from the fileserver -
mkdir /tmp/music
mount -t nfs 192.168.1.77:/home/share/music /tmp/music -o nolock
then
ls /tmp/music
indeed shows the music directory from the fileserver -
root@OpenWrt:~# ls /tmp/music
2 Many DJ's
Acid House Kings
Al Green
Babyshambles
Barenaked Ladies
Buena Vista Social Club
Bugz in the Attic
Following the Usb Storage and Usb Audio wiki entries, I installed the appropriate kernel modules to enable my usb soundcard -
ipkg install kmod-usb-ohci kmod-soundcore kmod-usb-audio
Then, on plugging the soundcard in, dmesg gives -
hub.c: new USB device 00:04.0-1, assigned address 2
usbaudio: device 2 audiocontrol interface 0 has 0 input and 1 output AudioStreaming interfaces
usbaudio: device 2 interface 1 altsetting 0 does not have an endpoint
usbaudio: device 2 interface 1 altsetting 1 channels 2 framesize 2 configured
usbaudio: valid output sample rate 44100
usbaudio: valid output sample rate 48000
usbaudio: device 2 interface 1 altsetting 1: format 0x01000010 sratelo 44100 sratehi 48000 attributes 0x01
usbaudio: registered dsp 14,3
usbaudio: constructing mixer for Terminal 3 type 0x0301
usbaudio: registered mixer 14,0
usb_audio_parsecontrol: usb_audio_state at 807f8860
I then installed the Music Player application -
ipkg install mpd
and some other dependences that weren't properly flagged when mpd was installed -
ipkg install alsa-lib libpthread
editted the config file -

# MPD CONFIG FILE
# For a full description of all config parameters,
# Check the mpd man page, "man mpd".

##################### REQUIRED ###########################
music_directory "/tmp/music"
playlist_directory "/tmp/music"
db_file "/tmp/music/mpd.db"
log_file "/tmp/mpd.log"
error_file "/tmp/mpd.error"
pid_file "/tmp/mpd.pid"
##########################################################

##########################################################
# EVERYTHING ELSE IS OPTIONAL
##########################################################

################## AUDIO OUTPUT ##########################
#
# use this if you want to use OSS audio output
audio_output {
type "oss"
name "my OSS sound card"
device "/dev/sound/dsp" # optional
format "44100:16:2" #optional
}
#
# OSS Mixer
mixer_type "oss"
mixer_device "/dev/sound/mixer"
mixer_control "PCM"
#

################# SECURITY SETTINGS ######################
#
# It is encouraged to run MPD as
# non-superuser. If you start mpd as root
# (for example, in an init script), set
# this value, then mpd will drop root priveleges
# and runs as the user specified.
#
user "share"
#

################ MISCELLANEOUS OPTIONS ###################
#
port "6600"

added 'share' user and group (by editting /etc/passwd and /etc/group) so that we can properly read and write to the nfs share on the fileserver which is owned by user 'share'. Since we will be running mpd as user 'share', we need to open the permissions of /dev/sound/dsp and /dev/sound/mixer which were created by root
chmod 777 /dev/sound -R
Then try it ! First start the music player -
mpd
There may be a long wait while it builds the database before daemon starts up. Then can use the command-line controller to add all the files in the database to a playlist, shuffle it, then play -
mpc listall mpc add
mpc shuffle
mpc play
and lovely music!

In order for it all to start up properly on power-up of the router, create /etc/init.d/mpd -
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=70

start() {
mkdir /tmp/music
mount -t nfs 192.168.1.77:/home/share/music /tmp/music -o nolock
chmod 777 /dev/sound -R
mpd
mpc listall mpc add
mpc shuffle
mpc volume 10
mpc update
}

stop() {
killall mpd
umount /tmp/music
}
and then to set it up to run on router restart -
/etc/init.d/mpd enable

ASUS WL-500g as a wireless client/repeater

The Asus WL-500g router already had an old version of Openwrt White Russian firmware. I followed this advice from the Openwrt forums re installing Openwrt Kamikaze. Downloaded the appropriate firmware for the Asus WL-500g and loaded onto the router via the firmware upgrade function of webif (alternatively I could have used the the Asus upgrade utility).

After the usual logging on via telnet, changing root password etc described in the forum posting linked above, I followed the direction in this wiki article to configure the router as a wireless repeater.

Edited /etc/config/wireless -
config wifi-device wl0
option type broadcom
option channel 11

# REMOVE THIS LINE TO ENABLE WIFI:
option disabled 0

config wifi-iface
option device wl0
option network lan
option mode sta
option ssid NETGEAR
option encryption psk
option key LetterOfTheWeek

config wifi-iface
option device wl0
option network lan
option mode ap
option ssid Kitchen
option hidden 0
option encryption psk
option key LetterOfTheWeek
and /etc/config/network -
#### VLAN configuration
config switch eth0
option vlan0 "1 2 3 4 5*"
option vlan1 "0 5"

#### Loopback configuration
config interface loopback
option ifname "lo"
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0

#### LAN configuration
config interface lan
option type bridge
option ifname "eth0"
option proto static
option ipaddr 192.168.1.101
option netmask 255.255.255.0
option gateway 192.168.1.1
option dns 192.168.1.1

#### WAN configuration
config interface wan
option proto none

- to set up the router as a client with WPA encryption on the existing AP with an SSID of 'NETGEAR' and also as an AP itself with SSID 'Kitchen' which repeats the traffic with WPA encryption.

When the router is configured like this and rebooted, it becomes a client to an existing AP with an SSID of 'NETGEAR'. This client interface, the wired router ports and the new AP with SSID 'Kitchen' are bridged together with an IP address of 192.168.1.101. Wired or wireless clients attached to this bridge get their IP configuration in the 192.168.1.xxx subnet via DHCP from the NETGEAR access point. The routing table on the router is -

root@kitchen:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 br-lan
default 192.168.1.1 0.0.0.0 UG 0 0 0 br-lan
and the interfaces are -

root@kitchen:~# ifconfig
br-lan Link encap:Ethernet HWaddr 00:11:2F:90:E9:C4
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:65205 errors:0 dropped:0 overruns:0 frame:0
TX packets:41138 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:33390624 (31.8 MiB) TX bytes:7736272 (7.3 MiB)

eth0 Link encap:Ethernet HWaddr 00:11:2F:90:E9:C4
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:5281 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:512332 (500.3 KiB)
Interrupt:3

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:232185 errors:0 dropped:0 overruns:0 frame:0
TX packets:232185 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:28677026 (27.3 MiB) TX bytes:28677026 (27.3 MiB)

wl0 Link encap:Ethernet HWaddr 00:11:2F:90:E9:C4
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:88661 errors:0 dropped:0 overruns:0 frame:92666
TX packets:74755 errors:17 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46906044 (44.7 MiB) TX bytes:22477020 (21.4 MiB)
Interrupt:6 Base address:0x2000

wl0.1 Link encap:Ethernet HWaddr 00:11:2F:90:E9:C4
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Setting up NFS on the NSLU2 fileserver

Will want to export NFS shares from the fileserver as well as Samba. Followed advice from DebianHelp.
apt-get install nfs-kernel-server
edited /etc/exports to add -
/home/share/music *
then update the running server by doing
exportfs -a