Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jeffrafter/386741 to your computer and use it in GitHub Desktop.
Save jeffrafter/386741 to your computer and use it in GitHub Desktop.
Magic Potion | How to setup an Asus WL-520gu with OpenWRT for Sound
killall mpd
mkdir /mpd
mkdir /mpd/playlists
mkdir /mpd/music
echo "192.168.24.101 haunt.local" >> /etc/hosts
cd mpd
wget http://haunt.local/mpd.conf
cd /
mkdir /mpd2
mkdir /mpd2/playlists
mkdir /mpd2/music
cd mpd2
wget http://haunt.local/mpd2.conf
mv mpd2.conf mpd.conf
cd /
cd /etc/init.d/
rm mpd
wget http://haunt.local/mpd
chmod 755 mpd
cd /
rm /etc/modules.d/60-usb-audio
vi /usr/share/alsa/alsa.conf
reboot
vi /mpd/mpd.conf
port 6601
music_directory "/mpd/music"
playlist_directory "/mpd/playlists"
db_file "/mpd/mpd.db"
log_file "/mpd/mpd.log"
error_file "/mpd/mpd.error"
#audio_output {
# type "alsa"
# name "My ALSA Device"
# device "hw:0,0" # optional
# format "44100:16:2" # optional
#}
mixer_type "alsa"
mixer_device "default"
mixer_control "PCM"
mpd --create-db /mpd/mpd.conf
mpd /mpd/mpd.conf
# use and abuse of pipes with audio data
http://www.debian-administration.org/articles/145
Note these instructions are all based on the mightyOhm articles. This is a little bit different because I wanted to get alsa sound working (instead of dsp) so that I could overlay effects
and background sound simultaneously.
What to do
==========
install mightyohm trx by blind flashing
setup network and wireless and dhcp
setup the banner for fun
Blind flashing
==============
You need to be on the .1 network
Configure local machine (i.e., your laptop) lan hardware to 192.168.1.185 manual address
Connect network cable (not crossover) from local machine (i.e., laptop) to LAN1 port (i.e., router)
Sometimes your wireless network (wireless) is on a .1 network and will interfere
If so you can (a) change it (b) turn off wireless while you do stuff
Power off router
Hold down red Restore button on the back of the router
Power on router
Power LED should start flashing once per second, release Restore button
ping 192.168.1.1
cd < whereever the trx file is, maybe kamikaze/bin >
tftp
> trace
> timeout 1
> mode binary
> connect 192.168.1.1
> put openwrt-brcm-2.4-squashfs.trx
You may see a lot of "Sending packet" kind of information then it will stop
*** Wait 10 minutes, don't touch anything ***
*** During this point the router is reconfiguring the firmware you just uploaded ***
After 10 minutes, reboot the router (unplug, wait a couple seconds, plug it back in)
ping 192.168.1.1 (wait until it starts responding, boot takes about 10 seconds)
telnet 192.168.1.1
Next you want to setup your network
root@OpenWrt:/# vi /etc/config/wireless
=======================================
vi /etc/config/wireless
config wifi-device wl0
option type broadcom
option channel 6 # the channel your wireless network is on
config wifi-iface
option device wl0
option network lan
option mode sta
option ssid MyNetwork # the SSID of your network
option encryption psk # the encryption mode of your network (or wep)
option key XXXXXXXXXX # add this line with your preshared key in place of X...X
root@OpenWrt:/# vi /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.0"
option proto static
#### You could optionally give a manual address still,
#### but make sure it is on your wireless subnet
#### If you don't, your wireless network will give it one
option ipaddr 192.168.1.211
option netmask 255.255.255.0
#### WAN configuration
config interface wan
option type bridge
option ifname "eth0.1"
option proto static
option ipaddr 192.168.2.1
option netmask 255.255.255.0
#### If you do not use the mightyohm trx you need to set dhcp
root@OpenWrt:/# vi /etc/config/dhcp
===================================
config dnsmasq
option domainneeded 1
option boguspriv 1
option filterwin2k '0' #enable for dial on demand
option localise_queries 1
option local '/lan/'
option domain 'lan'
option expandhosts 1
option nonegcache 0
option authoritative 1
option readethers 1
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
#list server '/mycompany.local/1.2.3.4'
#option nonwildcard 0
#list interface br-lan
config dhcp lan
option interface lan
option start 100
option limit 150
option leasetime 12h
config dhcp wan
option interface wan
option start 100
option limit 150
option leasetime 12h
#### If you use the mightyohm trx you have a firewall, you want to open the wan port
root@OpenWrt:/# vi /etc/config/firewall
=======================================
#### Update the wan zone so it looks like the lan zone
config zone
option name wan
option input ACCEPT
option output ACCEPT
option forward REJECT
#### Restart your network
root@OpenWrt:/# /etc/init.d/network restart
===========================================
#### This will disconnect you.
#### You can again telnet to 192.168.2.1. You can also telnet through your wireless network by
#### finding out which dhcp address it picked up (check your normal wireless router for clients)
#### or 192.168.1.211 (if you specified that as the static address)
#### Edit the opening banner for fun and tricks
root@OpenWrt:/# vi /etc/banner
==============================
#### To install packages you need to setup opkg
root@OpenWrt:/# vi /etc/opkg.conf
=================================
src/gz snapshots http://<place where you have your packages, see 'Package server'>/packages
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /jffs
#### Update and install
root@OpenWrt:/# opkg update
root@OpenWrt:/# opkg install kmod-usb-ohci kmod-alsa alsa-lib
Mpd
===
vi /etc/opkg.conf
src/gz snapshots http://mightyohm.com/files/kamikaze-2.4/packages/mipsel
opkg update
install mpd mpc
reboot
vi /usr/share/alsa/alsa.conf
change
defaults.pcm.ipc_gid audio
to
defaults.pcm.ipc_gid root
Setting up MPD
==============
root@OpenWrt:/# mkdir ~/.mpd
root@OpenWrt:/# mkdir ~/.mpd/playlists
root@OpenWrt:/# mkdir ~/music
root@OpenWrt:/# mpd
unable to open db file "/root/.mpd/mpd.db": No such file or directory
current locale is "C"
setting filesystem charset to ISO-8859-1
No "audio_output" defined in config file
Attempt to detect audio output device
Attempting to detect a oss audio device
Error opening OSS device "/dev/dsp": No such file or directory
Successfully detected a oss audio device
# An example configuration file for MPD
# See the mpd.conf man page for a more detailed description of each parameter.
######################## REQUIRED PATHS ########################
port 6602
music_directory "/mpd2/music"
playlist_directory "/mpd2/playlists"
db_file "/mpd2/mpd.db"
log_file "/mpd2/mpd.log"
error_file "/mpd2/mpd.error"
################################################################
debug:
make sure there is no /etc/module.d/60-usb-audio
# You need to enable netcat server in the busybox core
https://dev.openwrt.org/ticket/2905
# How to add a package (https://forum.openwrt.org/viewtopic.php?id=16040)
(1) find the package you are looking for and check it out/copy into $base/package/<package name>
(2) Fixup the makefile
(3) Compile just that package and rebuild the index!
make package/<name>/{clean,compile} package/index
(4) Select the package (M)
make menuconfig
(5) Rebuild the index again
make package/index
(6) Copy those packages to your webserver so opkg can see it
# Installing rawrec
opkg update
opkg install rawrec
opkg install libpthread
include $(TOPDIR)/rules.mk
PKG_NAME:=rawrec
PKG_VERSION:=0.9.98
PKG_RELEASE:=1
#PKG_MD5SUM:=800856d0211de5728cea1cbde923201d
PKG_SOURCE_URL:=http://sourceforge.net/projects/rawrec/files/$(PKG_NAME)/$(PKG_VERSION)/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
include $(INCLUDE_DIR)/package.mk
define Package/rawrec
SECTION:=sound
CATEGORY:=Sound
TITLE:=rawrec is a direct audio file player/recorder
endef
define Package/rawrec/description
The rawrec package provides a simple command-line
utility for playing and recording audio files in
raw sample.
endef
define Package/rawrec/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_BUILD_DIR)/src/{rawplay,rawrec} $(1)/usr/bin/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/src \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)"
endef
$(eval $(call BuildPackage,rawrec))
include $(TOPDIR)/rules.mk
PKG_NAME:=rawrec
PKG_VERSION:=0.9.98
PKG_RELEASE:=1
#PKG_MD5SUM:=800856d0211de5728cea1cbde923201d
PKG_SOURCE_URL:=http://sourceforge.net/projects/rawrec/files/$(PKG_NAME)/$(PKG_VERSION)/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
include $(INCLUDE_DIR)/package.mk
define Package/rawrec
SECTION:=sound
CATEGORY:=Sound
TITLE:=rawrec is a direct audio file player/recorder
endef
define Package/rawrec/description
The rawrec package provides a simple command-line
utility for playing and recording audio files in
raw sample.
endef
define Package/rawrec/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_BUILD_DIR)/src/{rawplay,rawrec} $(1)/usr/bin/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/src \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)"
endef
$(eval $(call BuildPackage,rawrec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment