Tp-link router

Davr recently coordinated a group buy of a bunch of cheesy tp-link TL-WR703N wireless routers.

Here is a picture of the board:

[[Image:tp-link_wr703n_top.jpg|thumb|640p|Top of the board]]
[[Image:IMG_20120104_213222.jpg|thumb|640p|Bottom of the board]]

(the blue part of the case comes off with a slim piece of metal and a small amount of focused violence).

== Wasting Time Reading About OpenWRT ==

here is [https://forum.openwrt.org/viewtopic.php?id=31729 a link to an associated thread on openwrt.org].
it looks like there is [http://wiki.openwrt.org/toh/tp-link/tl-wr703n a working port of openwrt for the wr703n].

here is [http://blog.nemik.net/2011/12/arduino-openwrt-art/ a link to a blog post about using openwrt to diddle arduinos attached to the wr703n usb port]. i know how you love those arduinos!

== Flashing OpenWRT ==

Want to run OpenWRT? Get the image: http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin

Upload it at http://192.168.1.1/userRpm/SoftwareUpgradeRpm.htm

Once flashed, telnet to 192.168.1.1

For a little more info on how to get the router running, here is an [[Tp-link Setup|In Depth Setup]]

If you manage to get OpenWRT on, but somehow lock yourself out (like breaking the firewall, as I did), press the reset button a few seconds after powering on, the blue LED will blink furiously and it will let you telnet in as root with no password.

Update from robbiet480 on 01/13/13

Latest OpenWRT required me to install wpad-mini to enable AP functionality and be able to connect to WPA(2) networks. You can get it from [http://www.madox.net/wr703n/ar71xx/packages/].

== Cross-compiling ==

Once you have OpenWRT running, you can use their pre-built SDK for cross-compiling to the MIPS processor.

Get the SDK at: ”’http://downloads.openwrt.org/backfire/10.03.1/ar71xx/”’

You’ll need to add the cross-built GCC binaries to your PATH. Something like
export PATH="$HOME/dev/toolchains/tplink/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/bin/:$PATH"

To build:
$ mips-openwrt-linux-gcc -static -s hello.c -o hello
$ file hello
hello: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, statically linked, with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, stripped

== Autotools cross-compiling ==
OPENWRT_SDK="$HOME/dev/toolchains/openwrt"
OPENWRT_TOOLCHAIN="$OPENWRT_SDK/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1"
export PATH="$OPENWRT_TOOLCHAIN/usr/bin/:$PATH"
export LDFLAGS="-L$OPENWRT_TOOLCHAIN/usr/lib -L$OPENWRT_TOOLCHAIN/lib -Wl,-rpath- link=$OPENWRT_TOOLCHAIN/lib/"
export ac_cv_func_malloc_0_nonnull=yes

./configure –build=x86_64-linux-gnu –host=mips-openwrt-linux

== Blinking the blue LED ==

# echo 0 > /sys/devices/platform/leds-gpio/leds/tp-link:blue:system/brightness
# echo 1 > /sys/devices/platform/leds-gpio/leds/tp-link:blue:system/brightness

Sample C program: https://gist.github.com/1576363/

== Wrecking your Router ==

According to the internets, console I/O can be had by wiring up to TP_OUT and TP_IN at the edge of the board, closest to the dram part.
The test points pull off of the board very easily so be extra careful if you decide to solder stuff to them or follow Myles’s advice and solder to the empty capacitor pads next to the test points.

I used [http://www.sparkfun.com/products/449 this level shifter] to read the output but it doesn’t pull down the TP_IN line properly for sending data to the target board.
comm parameters are 115200 baud, N81

== Recovering from a bricked router ==

Set up serial port, then

Set up the tftp server at 192.168.1.100 and connect to bricked box via ethernet.

Break the autoboot on the serial console by typing tpl. It will keep whipping by, just type tpl and it will eventually work.

hornet> tftpboot 0x81000000 openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin
hornet> erase 0x9f020000 +0x3c0000
hornet> cp.b 0x81000000 0x9f020000 0x3c0000
hornet> bootm 9f020000

I learned how to do this from mrzaphodb at https://forum.openwrt.org/viewtopic.php?pid=154450

== Interfacing with Arduino ==

Prereqs
opkg install the following

coreutils-stty – 8.8-1 (lets you talk to serial ports)
kmod-usb-serial – 2.6.39.4-1 (base driver for USB serial ports)

and your serial port driver, probably
kmod-usb-serial-cp210x (CP201x based USB/serial adapters)
kmod-usb-serial-pl2303 (PL2303 based USB/serial adapters
kmod-usb-serial-ftdi – (FTDI based USB/serial adapters, used in older Arduinos)
kmod-usb-acm (USB/serial adapters implementing the standardized USB CDC protocol, such as the Teensy or Arduino Uno)

Can’t hurt to install them all

Script to read from arduino

#!/bin/sh
#/usr/bin/readuino.sh
# simple script to tail newline terminated messages from the arduino
# adjust the head number depending on your arduino messages

if ! [ -f /tmp/isrunning ]; then
if [ -c /dev/ttyUSB0 ]; then

echo $$ > /tmp/isrunning
/usr/bin/stty -F /dev/ttyUSB0 raw speed 9600
while [ 1 ]; do
if [ -c /dev/ttyUSB0 ]; then
head -n 3 /dev/ttyUSB0 >/tmp/volts
sleep 1
else
# USB dissapeared.
echo "Arduino no longer attached" >/tmp/volts
rm /tmp/isrunning
exit
fi
done
else
echo "Arduino not yet attached" >/tmp/volts
fi
fi

CGI to view data from arduino


#!/bin/sh
#!/www/cgi-bin/volts
# simple CGI to tail most recent info from an arduino

if ! [ -f /tmp/isrunning ]; then
/usr/bin/readuino.sh & 2>&1 >/dev/null
fi

echo "Content-type: text/html"
echo ""
echo "

"

echo "

Voltmeter

"
#echo "lame txt and pre to get around android’s bouncing status bar"
echo "




"

echo "

A/D reading, volts, degrees

"
echo "

"

cat /tmp/volts

echo "

"
echo ""

== Build VM ==

I set up a [[Tp-linkBuildVM|Vmware image]] to make development easier. It didn’t actually end up being easier, but now the work is done for you.

[[Category: Projects]]

Leave a Reply

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