OpenWrt (Backfire 10.03) and TL-WR1043ND

December 13th, 2011 | Tags: , , , , , , ,

I forget to publish this article almost a year ago :-( So now it’s a good time before I’ll write another one…

It’s OUTDATED and INCOMPLETE, but it can still bring some light…

Few days ago I bought WiFi router TP-Link TL-WR1043ND. The main reason was the USB, Gigabit Ethernet ports, 802.11n and support in latest OpenWrt.

OpenWrt is amazing project which can create really powerful device from the wifi routers.

I spent many days with collecting various information about OpenWrt, because I want to use web camera, USB hub, external USB storage and later few thermometers.

I decided to compile it from scratch (using Fedora 13), because squashfs can’t work with block-extroot without building an image (see
I prefer to use squashfs, because some people say it’s better than jffs2.

Here you can find my notes…

Download necessary packages to compile OpenWrt:

yum install subversion gcc-c++ libz-dev flex unzip ncurses-devel zlib-devel

Download OpenWrt Backfire from svn:

cd /var/tmp/
svn co svn://

or use the standard way:

cd /var/tmp/
tar xvjf backfire_10.03_source.tar.bz2
mv backfire_10.03 backfire

Start configuring it:

cd backfire/
./scripts/feeds update
./scripts/feeds install xxx
make menuconfig

Select following items in the menuconfig and the items from the command below:

Target System (Atheros AR71xx/AR7240/AR913x)
Target Profile (TP-LINK TL-WR1043ND v1)
Kernel modules ---> Filesystems ---> kmod-fs-ext2
Kernel modules ---> USB Support ---> kmod-usb-core
Kernel modules ---> USB Support ---> kmod-usb-storage
Kernel modules ---> USB Support ---> kmod-usb-video
Kernel modules ---> USB Support ---> kmod-usb-serial
Kernel modules ---> USB Support ---> kmod-usb-serial-pl2303
Kernel modules ---> Video Support ---> kmod-video-core
Kernel modules ---> Video Support ---> kmod-video-uvc
Utilities ---> disc ---> block-extroot
#Base system ---> block-extroot

and all the packages you installed before

Run “make V=99″ to compile it.

I’ll put all the root files to the USB disk and I formated my 500MB USB stick this way:

root@fedora:/# parted -s /dev/sda p
Model: Generic STORAGE DEVICE (scsi)
Disk /dev/sda: 492MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 16.4kB 450MB 450MB primary ext2
2 450MB 492MB 41.9MB primary linux-swap(v1)

Connect router to your desktop/laptop and flash it form the webgui using this file: /var/tmp/backfire/bin/ar71xx/openwrt-ar71xx-tl-wr1043nd-v1-squashfs-factory.bin or use these commands if you already have OpenWrt installed:

scp ./backfire/bin/ar71xx/openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin root@
sysupgrade openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin
#scp ./backfire/bin/ar71xx/openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin root@
#mtd -e firmware -r write /tmp/openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin firmware

Set your password using telnet command and setup up block-extroot (Rootfs on External Storage) – use my USB stick as root partition to have more space:

ifconfig eth0 netmask

uci set fstab.@mount[0].fstype=ext2
uci set fstab.@mount[0].device=/dev/sda1
uci set fstab.@mount[0].is_rootfs=1
uci set fstab.@mount[0].enabled_fsck=1
uci set fstab.@mount[0].target=/mnt
uci set fstab.@mount[0].enabled=1
uci commit fstab


Turn on the swap:

uci set fstab.@swap[0].device=/dev/sda2
uci set fstab.@swap[0].enabled=1

Add option force_space in /etc/opkg.conf to allow installation of packets bigger than your /rom partitions free space:

echo option force_space >> /etc/opkg.conf

Setup the ssh key to enable autologin:

scp $HOME/.ssh/ root@
ssh root@
cp /tmp/authorized_keys /etc/dropbear/authorized_keys
chmod 600 /etc/dropbear/authorized_keys

Configure getting DHCP requests from WAN (Internet) port, wifi and firewall:

uci set network.lan.ipaddr=
uci set network.lan.netmask=

uci set network.wan.ifname=eth0.2
uci set network.wan.proto=static
uci set network.wan.type=bridge
uci set network.wan.ipaddr=
uci set network.wan.netmask=
uci set network.wan.dns=""
uci set network.wan.gateway=

uci set network.wifi_open=interface
uci set network.wifi_open.ifname=eth0.3
uci set network.wifi_open.type=bridge
uci set network.wifi_open.proto=static
uci set network.wifi_open.ipaddr=
uci set network.wifi_open.netmask=

uci set network.wifi_priv=interface
uci set network.wifi_priv.ifname=eth0.1
uci set network.wifi_priv.type=bridge
uci set network.wifi_priv.proto=static
uci set network.wifi_priv.ipaddr=
uci set network.wifi_priv.netmask=

uci add network switch_vlan
uci set network.@switch_vlan[-1].device=rtl8366rb
uci set network.@switch_vlan[-1].vlan=3
uci set network.@switch_vlan[-1].ports=5

uci set wireless.@wifi-iface[0].ssid=test123
uci set wireless.@wifi-iface[0].network=wifi_open
uci set wireless.@wifi-iface[0].encryption=psk2
uci set wireless.@wifi-iface[0].key=yyyyyyyy
uci set wireless.@wifi-iface[0].isolate=1

uci add wireless wifi-iface
uci set wireless.@wifi-iface[-1].device=radio0
uci set wireless.@wifi-iface[-1].network=wifi_priv
uci set wireless.@wifi-iface[-1].mode=ap
uci set wireless.@wifi-iface[-1].ssid=test345
uci set wireless.@wifi-iface[-1].encryption=psk2
uci set wireless.@wifi-iface[-1].key=yyyyyyyy

uci set
uci set
uci set wireless.radio0.hwmode=11ng
uci del wireless.@wifi-device[0].disabled

uci set firewall.@zone[1].conntrack=1
uci set firewall.@zone[1].forward=ACCEPT
uci set firewall.@zone[1].input=ACCEPT

uci add firewall zone
uci set firewall.@zone[-1].name=wifi_open
uci set firewall.@zone[-1].input=REJECT
uci set firewall.@zone[-1].output=ACCEPT
uci set firewall.@zone[-1].forward=REJECT
uci set firewall.@zone[-1].conntrack=1

uci add firewall zone
uci set firewall.@zone[-1].name=wifi_priv
uci set firewall.@zone[-1].input=ACCEPT
uci set firewall.@zone[-1].output=ACCEPT
uci set firewall.@zone[-1].forward=REJECT

uci add firewall forwarding
uci set firewall.@forwarding[-1].src=wifi_open
uci set firewall.@forwarding[-1].dst=wan

uci add firewall forwarding
uci set firewall.@forwarding[-1].src=wifi_priv
uci set firewall.@forwarding[-1].dst=wan

uci add firewall rule
uci set firewall.@rule[-1].name=icmp-echo-request
uci set firewall.@rule[-1].src=wifi_open
uci set firewall.@rule[-1].target=ACCEPT
uci set firewall.@rule[-1].proto=icmp
uci set firewall.@rule[-1].icmp_type=echo-request

uci add firewall rule
uci set firewall.@rule[-1].name=dhcp
uci set firewall.@rule[-1].src=wifi_open
uci set firewall.@rule[-1].target=ACCEPT
uci set firewall.@rule[-1].proto=udp
uci set firewall.@rule[-1].src_port=68

uci set dhcp.@dnsmasq[0]
uci set dhcp.@dnsmasq[0].port=0
uci set dhcp.@dnsmasq[0].cachelocal=0
uci set dhcp.@dnsmasq[0].dhcpscript=/etc/dnsmasq.script

uci set dhcp.wifi_open=dhcp
uci set dhcp.wifi_open.interface=wifi_open
uci set dhcp.wifi_open.start=130
uci set dhcp.wifi_open.limit=60
uci set dhcp.wifi_open.dhcp_option=6,

uci set dhcp.wifi_priv=dhcp
uci set dhcp.wifi_priv.interface=wifi_priv
uci set dhcp.wifi_priv.start=70
uci set dhcp.wifi_priv.limit=60
uci set dhcp.wifi_priv.dhcp_option=6,

uci set dhcp.lan.start=194
uci set dhcp.lan.limit=60
uci set dhcp.lan.dhcp_option=6,

uci add dhcp host
uci set dhcp.@host[-1].name=peru-nb-work
uci set dhcp.@host[-1].ip=
uci set dhcp.@host[-1].mac=00:1C:65:38:7C:F6

uci add dhcp host
uci set dhcp.@host[-1].name=peru-nb
uci set dhcp.@host[-1].ip=
uci set dhcp.@host[-1].mac=00:15:00:11:48:5a

uci add dhcp host
uci set dhcp.@host[-1].name=phone
uci set dhcp.@host[-1].ip=
uci set dhcp.@host[-1].mac=00:23:76:d6:42:c7

uci add dhcp host
uci set dhcp.@host[-1].name=palm
uci set dhcp.@host[-1].ip=
uci set dhcp.@host[-1].mac=00:0b:6c:57:da:9a

wget -O /etc/init.d/dnsmasq

Set the hostname, timezone and configure syslogd:

uci set system.@system[0].timezone=CET-1CEST,M3.5.0,M10.5.0/3
uci set system.@system[0].timezone=CET-1CEST,M3.5.0,M10.5.0/3
uci set system.@system[0].log_size=64
uci set system.@system[0].log_ip=

Configure certificate details for https:

uci set uhttpd.px5g.days=3650
uci set
uci set uhttpd.px5g.state="Czech Republic"
uci set uhttpd.px5g.location=Brno
rm /etc/uhttpd.crt /etc/uhttpd.key

Configure darkstat, snmpd and vnstat.

uci set darkstat.@darkstat[0].interface=wan

uci set mini_snmpd.@mini_snmpd[0].interfaces=lo,br-wan,br-wifi_open,br-wifi_private
uci set mini_snmpd.@mini_snmpd[0].community=OpenWrt
uci set mini_snmpd.@mini_snmpd[0].location='V Ujezdech 1, Brno'
uci set mini_snmpd.@mini_snmpd[0].contact='PeRu'

Few more commands to configure “non-uci” files:

sed -i 's/\(^mailhub\).*/\;s/\(^rewriteDomain=\).*/\' /etc/ssmtp/ssmtp.conf

sed -i 's/\(^GatewayInterface\).*/\1 br-wifi_open/;s/^# \(GatewayName\).*/\1 Medlanky/;s/^\([[:space:]]*FirewallRule allow tcp port 80\)/#\1/;s/\(.*FirewallRule allow tcp port 22\)/#\1/;s/\(.*FirewallRule allow tcp port 443\)/#\1/;/^FirewallRuleSet authenticated-users/a\ FirewallRule allow' /etc/nodogsplash/nodogsplash.conf

sed -i 's@\(\)@\1\n
<h3>For Internet access - click the dog</h3>
<h3>Pro pristup na Internet klikni na psa.</h3>

cat > /etc/dnsmasq.script << \EOF #!/bin/sh /bin/echo `/bin/date +"%F %T"` $* >> /tmp/dnsmasq.script.log

case $1 in
#grep -q $2 /etc/config/dhcp || /usr/bin/nmap -T4 -A $3 | ssmtp
#echo "Subject: New connection to `hostname` ($2 $3)\n\n`/usr/bin/nmap -T4 -A $3`" | ssmtp

chmod a+x /etc/dnsmasq.script

cat >> /etc/digitemp.script << \EOF
#!/bin/sh /usr/bin/digitemp_DS9097 -c/etc/digitemp.conf -a -n0 -d10 -q -s/dev/ttyUSB0 -o"PUTVAL OpenWrt/temp/temperature-%s interval=10 %N:%.2C"
chmod a+x /etc/digitemp.script
mkdir /root/.ssh/
dropbearkey -t rsa -f /root/.ssh/id_rsa

# Save the public key to the ~/.ssh/authorized_keys on the server cat > /etc/fswebcam.script << \EOF
OUTPUT_FILE="/tmp/webcam/`date +%F_%H-%M`.png" OUTPUT_DIR=`dirname
$OUTPUT_FILE` date > /tmp/fswebcam.script.log

if [ `pgrep -f fswebcam | wc -l` -ge 4 ]; then
echo -e "*** fswebcam already running [`pgrep -f fswebcam | wc -l`] !!!\n*** ps -ef | grep -E '(fswebcam|scp)':\n`ps -ef | grep -E '(fswebcam|scp)'`\n*** killall fswebcam:\n`killall fswebcam`\n" | tee -a /tmp/fswebcam.script.log

test -d $OUTPUT_DIR || mkdir -p $OUTPUT_DIR

fswebcam --no-banner --rotate 180 --resolution 640x480 --fps 15 --png 7 --save $OUTPUT_FILE 2>&1 | tee -a /tmp/fswebcam.script.log

if scp -B -p -i /root/.ssh/id_rsa $OUTPUT_FILE 2>&1 >> /tmp/fswebcam.script.log; then
test -d /root/webcam_medlanky || mkdir -p /root/webcam_medlanky
mv $OUTPUT_FILE /root/webcam_medlanky/
echo -e "*** ls -la /root/webcam_medlanky/:\n`ls -la /root/webcam_medlanky/`\n" | tee -a /tmp/fswebcam.script.log

if [ "$BAD_STATE" -eq 1 ]; then
echo -e "Subject: Webcam script failed!\n\n`cat /tmp/fswebcam.script.log`\n" | ssmtp

chmod a+x /etc/fswebcam.script
echo "*/30 * * * * /etc/fswebcam.script" >> /etc/crontabs/root
/etc/init.d/cron enable
/etc/init.d/cron start

Collectd configuration:

/usr/bin/digitemp_DS9097 -a -i -c /etc/digitemp.conf -s/dev/ttyUSB0

mkdir -p /etc/collectd/conf.d
cat >> /etc/collectd/conf.d/my_collectd.conf << \EOF
LoadPlugin contextswitch
LoadPlugin memory
LoadPlugin uptime
LoadPlugin vmem
LoadPlugin users

LoadPlugin protocols
Value "/^Tcp:/"
IgnoreSelected false

LoadPlugin syslog
LogLevel "info"

uci set luci_statistics.collectd_ping.enable=1
uci set
uci set luci_statistics.collectd_df.enable=1
uci set luci_statistics.collectd_df.Devices=/dev/sda1
uci set luci_statistics.collectd_df.MountPoints=/mnt/sda1
uci set luci_statistics.collectd_df.FSTypes=fuseblk
uci set luci_statistics.collectd_disk.enable=1
uci set luci_statistics.collectd_disk.Disks=sda
uci set luci_statistics.collectd_dns.enable=1
uci set luci_statistics.collectd_dns.Interfaces="br-wan br-wifi_open br-wifi_private"
uci set luci_statistics.collectd_interface.Interfaces="br-wan br-wifi_open br-wifi_private"
uci set luci_statistics.collectd_irq.enable=1
uci set luci_statistics.collectd_netlink.enable=1
uci set luci_statistics.collectd_netlink.VerboseInterfaces="br-wan br-wifi_open br-wifi_private"
uci set luci_statistics.collectd_netlink.QDisc="br-wan br-wifi_open br-wifi_private"
uci set luci_statistics.collectd_network.enable=1
uci set luci_statistics.@collectd_network_server[0].host="\"\""
uci set luci_statistics.collectd_tcpconns.LocalPorts="22 80 443 667"
uci set luci_statistics.@collectd_exec_input[0].cmdline="/etc/digitemp.script"

/etc/init.d/luci_statistics enable

Useful commands:

swconfig dev rtl8366rb show
swconfig dev rtl8366rb vlan 1 show
cat /proc/net/vlan/config
snmpwalk -v2c -c public_wifi

Useful links: (in Polish)

Serial Port Temperature Sensors:

Dnsmasq script “hack” (I hope it will not be necessary to do this in the future): (in Polish)

Serial cable:

VN:F [1.9.20_1166]
Rating: 7.0/10 (2 votes cast)
OpenWrt (Backfire 10.03) and TL-WR1043ND, 7.0 out of 10 based on 2 ratings
  1. julian
    January 28th, 2012 at 08:08
    Reply | Quote | #1

    Excellent article. Just got my TL-WR1043ND router going with Openwrt latest stable. Your instructions are useful but I am not so bold to compile just yet. I am looking to expand the use of mine with external usb hard drive. I was going through some of your notes. I am not sure if I understood but it seemed you stated you could put a usb hub off the port and run several devices. Is that correct. Also I have an external USB hard drive and I am trying to get the filesystem to mount. I am still researching but any info you have on this would be helpful. Unless it doesnt have enough power to drive the external drive or I have to get an external drive that has a case which takes its own power source. Hope to hear from you as I am still in the research phase of learning about this wonderful router.


  2. January 28th, 2012 at 09:09
    Reply | Quote | #2


    Yes you are right. Actually I used USB Hub containing 4 ports. To these ports I connected thermometer, USB stick and webcam.

    Actually I have no experiences with connecting USB hard drive to to this devices – especially how it is with it’s power source. I’m using USB stick and it’s working fine.



  3. February 8th, 2012 at 05:12
    Reply | Quote | #3

    Great article. If I implemented your network, dhcp, dns, firewall setup, what do you think Luci would display in the GUI. Any chance of it working?


  4. February 8th, 2012 at 13:23
    Reply | Quote | #4

    I guess almost all the commands done using “uci” will show up in the Luci WebGUI. If you will do the changes in these “sections”: network, dhcp, dns, firewall – it should be in Luci for sure.

  5. February 8th, 2012 at 17:12
    Reply | Quote | #5

    I am dumbing down your configuration a bit as I am a newbie at this. I am removing the open wifi stuff for now (although a guest network is a really neat idea that I want to implement later) but can you tell me what is in your /etc/dnsmasq.script?

    And thanks for getting back to me so quickly. Have you thought of putting your config on the openwrt forum or wiki? It is really good stuff for us learners.


  6. February 9th, 2012 at 18:35
    Reply | Quote | #6

    Hi Petrův blog, you has lot of good informations in your blog, I just subscribed on RSS :)
    So, can you help me, after the step: make V=99

    Was generated those files:



    But where is: openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin

    Can I use some of those file to upgrade openwrt?