TP-Link TL-MR3020 as AirPlay receiver

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: 1×2.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 OpenWRThttp://openwrt.org/
* Read about router at OpenWRT sitehttp://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.

38 Replies to “TP-Link TL-MR3020 as AirPlay receiver”

  1. Hi Edu!

    Sorry, I don't have ipk since it's a quite heavy mechanism for such tiny machine as MR3020.
    However, it is very easy to upload any binary directly into running system, for example using wget.
    I can send you a binary executable file for shairport if you wish.

  2. Hi, I see there are some package preselect in addition to what is listed above. Am I suppose to unselect all the packages except the one listed above to make it fit in the 4Mb flash? I am afraid some of them is required and my blink my router.

    also i cannot locate wpad-mini and hotplug2 packages in the latest trunk r37793.

    Thanks.

  3. the trunk now have shairport package but it doesn't work. I replaced with the binary you posted above and it work very perfectly. thanks so much.

    the structure might have changed, I cannot get your feed to show up in menuconfig. i can see all the downloaded files under the /feeds directory. the package show up under multimedia is from the trunk and that one wont work.

  4. Hey, would anybody out there feel enough pity for me to post a link to the final binary? Save me a day or two building it for myself.

    Pretty please? With a cherry on top? (Note, I am obviously not above begging.)

  5. Ok, I must be blind, dense or both. I see a link to the shairport binary and a couple to articles about related articles but not to the complete openwrt image with shairport. What am I missing?

  6. Hmmm… I uploaded the new firmware image and it said it had updated the firmware ok and then rebooted. Now when I cycle the power, the blue light flashes once and that's it. I do see link lights on the ethernet hub it's plugged into but no sign of it in the wifi menu on my laptop or iPhone.

    One thing, I don't have my USB audio adapter yet. Will it fail to boot correctly without it?

    (Oh, and thanks so much for posting the binary for me!)

  7. You should connect via telnet and configure your wireless network using vi.
    (or if your home network is 192.168.1.0 then you can try it without wifi)

    The box itself should work normally without peripherals.

  8. Ok, first off.. Thanks so much for all your help. I really appreciate it. That said…

    I've been able to talk to it via telnet if I hold down the reset button for about 10s while it is boots up. With it connected to my system via ethernet cable, I can then telnet to it at 192.168.1.1.

    In that state, I don't see it in any of my iOS devices as an AirPlay device nor do I see any wifi SSIDs from it.

    If I boot it w/o holding in the reset button, the blue light flashes once, then about 5s later the green led on the usb audio device lights up and then a few seconds later the blue light comes on solid.

    I did get a copy of the boot log and can post it here for you if that's of any help.

  9. Michael:
    Thanks for all your work on this and publishing you firmware. I downloaded you complete firmware and flashed it to my wr703n without issue. Now however, I can't communicate with it. What is the IP address you have in your firmware? I tried the usual 192.168.1.1 and 192.168.1.100 with no luck. I also tried to arp -a it but no response from it.
    Also, do I need to telnet to it through the wired out serial port?
    Thanks again.

  10. I'm sorry about this situation.
    If everything was ok, your device should be available via 192.168.1.1 on Lan port and WiFi interface will grab network configuration from your DHCP service. You can try to boot in failsafe mode to look what is going on.
    BTW, I've placed a disclaimer about such model at the top of this post.

  11. Thanks Michael. Can you point me to your latest firmware version so I can download and try again. I have had good luck with other 3020 software on the 703.
    I've got connection to the serial port thru my rs232 adaptor now and I can see all to console output. Just need to figure out why I can't ping it at 192.168.1.1.
    Appreciate your responding on this. I don't expect you to trouble shoot it. This is my leearning experience with this little guy.

    Cheers.
    Glenn.

  12. Michael did you manage to help Dan? I think i had the same problem. I
    upgraded your final firmware to my 3020 v1 and now i dont see it on my
    network. Dont see any new wifi and throught lan i cannot ping
    192.168.1.1 its like the router is not doing nothing. On fail safe
    mode i can connect with Telnet on 192.168.1.1. What can i do? Is there
    anything i need to configure after flashing your firmware? The litle
    switch had to be on what position? 3G Whisp or AP? Thanks Michael for
    You help.

  13. Hi Dan and Michael, I am having the same issue. My MR3020 is not showing up at all on my computer. I do not see it boot up correctly, all I see right now is the reset led and power LED on after flashing the firmware in the suggested post above.

Leave a Reply

Your email address will not be published. Required fields are marked *