WARNING! The following post was written regarding MR3020 device. The author never used WR703N nor tested the following steps to use Shairport on WR703N. Even more, it's already known that the setup below may not work on this device.
MR3020 is a nice box, which includes the following internals:
CPU: Atheros AR7240@400MHz
RAM: 32MiB
Flash: 4MiB
Lan: 1x100Mbit
WiFi: 802.11 b/g/n 150Mbps
SoC: Atheros AR9330 rev 1
USB: 1x2.0 (* notes below)
Serial: yes
JTAG: no
SoC: Atheros AR9330 rev 1
Power: 5V via mini-USB
OS: OpenWRT support
Very similar to TL-WR703N
That's a quite powerful tiny box and it costs only 20-40$. That price makes MR3020 a very interesting one in terms of experimentation. I've decided to convert it into AirPlay receiver to push music stream wirelessly over the house.
My network config is something like this:
WIFI<-------- dhcp client>MR3020<static 192.168.1.1/24 -------->LAN (for administration reasons)
\-->USB sound card-->audio cable etc
Since zeroconf works on broadcast basis we don't need to know MR3020 address in WIFI network - it will be discovered and communicate automatically. So it'll act as a usual DHCP client.
Here is the algo of such process and notes about pitfalls.
* Learn a bit about OpenWRT:
http://openwrt.org/
* Read about router at OpenWRT site:
http://wiki.openwrt.org/toh/tp-link/tl-mr3020
* Install a stock OpenWRT build into your device
* Set up a build environment. I've used Ubuntu 12.10 x64 running in VirtualBox
Here's a good manual:
http://wiki.openwrt.org/doc/howto/buildroot.exigence
First of all you have to set up prerequisites depending on your build system.
* Download openwrt itself:
mkdir ~/openwrt
cd ~/openwrt
svn co svn://svn.openwrt.org/openwrt/trunk/
cd trunk
* Download and patch shairport package
copy
feeds.conf.default to
feeds.conf
add new source to the end:
src-git jlars git://github.com/jlars/packages.git;master
checkout feeds:
./scripts/feeds update
./scripts/feeds install -a
* Patch shairport package:
cd feeds/jlars
wget -O - ftp://ftp.custom-openwrt-builds.info/patches/shairport_deps_trunk.diff | patch -p1
cd ~/openwrt/trunk
* Configure our build
select our target:
make menuconfig
select Target System->Atheros AR7xxx/AR9xxx
select Target Profile->TP-Link TL-MR3020
quit and fill the defaults:
make defconfig
enter menuconfig again check the following list of packages. MR3020 has only 4Mb flash, so system should contain only required packages (packages should be built into system - 'y' key to choose):
base-files
busybox
dropbear
hotplug2
mtd
swconfig
uci
kmod-leds-gpio
kmod-ledtrig-default-on
kmod-ledtrig-netdev
kmod-ledtrig-timer
kmod-ledtrig-usbdev
kmod-gpio-button-hotplug
kmod-wdt-ath79
kmod-sound-core
- all sound drivers
kmod-usb-audio
kmod-usb-ohci
kmod-usb2
kmod-ath9k
wpad-mini
shairport
uboot-envtools
* Try to build it
make -j 3 V=99
* Check if build was successful: check binary image at
bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
(
if you have weird errors while building sstrip tool - try to fix it's makefile:
change this:
$(HOSTCC) $(HOST_CFLAGS) -I../include -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c
into this:
$(HOSTCC) $(HOST_CFLAGS) $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c
)
* Patch shairport on IPv6/iPv4 bug:
go into
build_dir/target-mips_r2_uClibc-0.9.33.2/shairport-0.05/ and edit
socketlib.c.
at line #162 comment out AF_INET6 option:
// tFamily = AF_INET6;
build and install fixed version:
make package/shairport/compile
make package/shairport/install
make
* Now we need to edit configuration files so our build can start serving AirPlay right after installation.
FS root is located at:
build_dir/target-mips_r2_uClibc-0.9.33.2/root-ar71xx
We need to edit 3 things:
- lan configuration
- wifi configuration
- shairport autostart
* Edit lib/functions/uci-defaults.sh
Locate things like this:
set network.lan='interface'
set network.lan.ifname='$ifname'
set network.lan.type='bridge'
set network.lan.proto='static'
set network.lan.ipaddr='192.168.1.1'
set network.lan.netmask='255.255.255.0'
and change them into this:
set network.lan='interface'
set network.lan.ifname='$ifname'
# set network.lan.type='bridge'
set network.lan.proto='static'
set network.lan.ipaddr='192.168.1.1'
set network.lan.netmask='255.255.255.0'
set network.wan='interface'
set network.wan.proto='dhcp'
Here we're disabling bridging between lan and wifi and enable wifi(wan) with dhcp config.
* Edit lib/wifi/mac80211.sh
Locate things like this:
option type mac80211
option channel ${channel}
option hwmode 11${mode_11n}${mode_band}
$dev_id
$ht_capab
# REMOVE THIS LINE TO ENABLE WIFI:
option disabled 1
config wifi-iface
option device radio$devidx
option network lan
option mode ap
option ssid OpenWrt
option encryption none
and change them into this:
option type mac80211
option channel ${channel}
option hwmode 11${mode_11n}${mode_band}
$dev_id
$ht_capab
# REMOVE THIS LINE TO ENABLE WIFI:
# option disabled 1
config wifi-iface
option device radio$devidx
option network wan
option mode sta
option ssid YOUR_SSID
option encryption YOUR_ENCRYPTION
option key YOUR_PASSWORD
write in the right configuration options of your WiFi network
* Edit etc/rc.local like this:
/usr/bin/shairport --apname=MR3020 --buffer=300 -d
exit 0
* Build the final image:
make target/install
* Find any lightweight http-server like Mangoose and share the system image located at
bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
(better rename it into something like image.bin)
* Telnet into running MR3020 via cable at 192.168.1.1(it will root login without password) and install fresh image:
cd /tmp
wget http://192.168.1.2:8080/image.bin
mtd write image.bin firmware
reboot
After rebooting WiFi LED should be blinking and new AirPlay receiver named MR3020 will be available in your wireless network.
Pitfall note! MR3020 has USB2.0 _only_ port. That means that it will not work well with USB1.0/1.1 devices. There's a pretty simple workaround - plug your sound card via USB2.0 hub. Here are details about this bug:
https://forum.openwrt.org/viewtopic.php?id=39956
Personally I'm using Creative USB Sound Blaster Play! (USB 1.1) and it works well with USB hub.
That's all for now.