crontab -e
*/5 * * * * echo "every 5 minutes" >> /tmp/tick.txt
/etc/init.d/cron start
/etc/init.d/cron enable

OpenWrt on TP-Link TL-WR902AC V3

Peter Lundkvist March 17, 2018, 5:47 p.m.:
TP-Link TL-WR902AC v3 is a pocket-size dual-band (AC750) router
based on MediaTek MT7628N + MT7650E.

- MediaTek MT7628N/N (580 Mhz)
- 64 MB of RAM
- 8 MB of FLASH
- 2T2R 2.4 GHz and 1T1R 5 GHz
- 1x 10/100 Mbps Ethernet

* MT7650 ac chip isn't not supported by LEDE/OpenWrt at the moment.
  Therefore 5Ghz won' work.

Flash instruction:

The only way to flash LEDE image in TL-WR902AC v3 is to use
tftp recovery mode in U-Boot:

1. Configure PC with static IP and tftp server.
2. Rename "openwrt-ramips-mt76x8-tplink_tl-wr902ac-v3-squashfs-tftp-recovery.bin"
   to "tp_recovery.bin" and place it in tftp server directory.
3. Connect PC with the LAN port, press the reset button, power up
   the router and keep button pressed for around 6-7 seconds, until
   device starts downloading the file.
4. Router will download file from server, write it to flash and reboot

uci show (to check for errors)

uci show firewall
# > uci: Parse error (EOF with unterminated ') at line 127, byte 2283


opkg update
opkg install iwinfo
iwinfo wlan0 info
wlan0     ESSID: "......."
          Access Point: 18:D6:C7:A7:06:64
          Mode: Client  Channel: 10 (2.457 GHz)
          Tx-Power: 18 dBm  Link Quality: 48/70
          Signal: -62 dBm  Noise: -90 dBm
          Bit Rate: 39.0 MBit/s
          Encryption: WPA2 PSK (CCMP)
          Type: nl80211  HW Mode(s): 802.11bgn
          Hardware: unknown [Generic MAC80211]
          TX power offset: unknown
          Frequency offset: unknown
          Supports VAPs: yes  PHY name: phy0

WR710n - unbrick with TFTP

store credentials / password

git config credential.helper store

just that...

sysupgrade form url

this seems to work but it actually doesn't install anything

# does-not-work: sysupgrade -v -n

the alternative (downloading with wget to /tmp) works well:

cd /tmp && wget && sysupgrade -v -n latest.bin

add alias in /etc/profile

alias nr="/etc/init.d/network reload"

list installed packages

opkg list_installed

or as one string of package names:

echo $(opkg list_installed | awk '{ print $1 }')

show devices

cat /sys/kernel/debug/usb/devices

kun je php gebruiken?

Ja! als je ruimte hebt of eerst ruimte maakt met exroot kun je daarna stappen volgen op

opkg install php7 php7-cgi
vi /etc/config/uhttpd
  list interpreter ".php=/usr/bin/php-cgi"
  option index_page 'index.html index.php'


tcpdump -i wlan0 -vvv -ttt -p -U


"By default, uHTTPd is bind to which also includes the WAN port of your router."

easy-extroot image

lede mr3020 extroot

lan client


config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr ''
        option netmask ''

config globals 'globals'
        option ula_prefix 'fd96:d76f:5a52::/48'

config interface 'lan'
        option ifname 'eth0'
        option force_link '1'
        option type 'bridge'
        option proto 'dhcp'
        option ip6assign '60'


config wifi-device  radio0
        option type     mac80211
        option channel  11
        option hwmode   11g
        option path     'platform/ar933x_wmac'
        option htmode   HT20
        option disabled 0

config wifi-iface
        option device   radio0
        option network  lan
        option mode     ap
        option ssid     ...
        option encryption psk2
        option key      ...

TP-Link MR-3020 v3

backup script for saving settings and home folder in failsafe mode

  1. start the wifibox in failsafe mode
  2. set your local IP to
  3. run this script locally (it starts a netcat server in the background and then executes remote commands through telnet)
nc -l 3333 > backup.tar.gz &
  echo "sysupgrade --create-backup /tmp/backup.tar.gz" ; # sysupgrade executed remotely
  sleep 5;  # local
  echo "nc 3333 < /tmp/backup.tar.gz" ; # # nc executed remotely
  sleep 5;  # local
} | telnet


  • it looks to me like ser2net can not communicate on 250000 bps.
  • there is a version/fork of ser2net that can do http/websockets.

extroot summary

on osx:

diskutil list
diskutil unmount /dev/disk#s#
sudo $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 /dev/disk#s#

on openwrt

opkg update
opkg install block-mount kmod-usb-storage kmod-fs-ext4
block info
mkdir /mnt/usb
mount /dev/sda1 /mnt/usb
ls /mnt/usb # to check...
#copy everything to usb
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/usb -xf -
umount /tmp/cproot

#confiure fstab
cat >> /etc/config/fstab << EOF
config mount
        option target        /
        option device        /dev/sda1
        option fstype        ext4
        option options       rw,sync
        option enabled       1
        option enabled_fsck  0
df -h

backup and restore config files

a nice workflow seems to be to backup config files using scp when you've got a working setup.

scp wifibox:/etc/config/* .

then you can mess up everything (even reflashing the device) and then to restore the configuration just run:

scp * wifibox:/etc/config/

(also checkout sysupgrade --create-backup /tmp/backup.tar.gz It creates a tar with the contents of the whole /etc folder)

UCI show

uci show firewall
#  firewall.@defaults[0]=defaults
#  ...
#  firewall.@zone[1].network='wan' 'wan6' 'wwan'    #this is called a list

UCI add_list

uci add_list firewall.@zone[1].network='TEST'


#root@OpenWrt:~# cat connect
STA_SSID=Vechtclub XL F1.19

set -x

uci set dhcp.@dnsmasq[0].rebind_protection=0
uci add_list firewall.@zone[1].network='wwan'

uci add wireless wifi-iface
uci set network.lan.ipaddr=
uci set network.wan=interface
uci set network.wan.proto=dhcp
uci set network.wwan=interface
uci set network.wwan.proto=dhcp

uci delete wireless.@wifi-device[0].disabled
uci set wireless.@wifi-iface[0].network=wwan
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].encryption=psk2
uci set wireless.@wifi-iface[0].ssid="$STA_SSID"
uci set wireless.@wifi-iface[0].key="$STA_KEY"

uci set wireless.@wifi-iface[1].device=radio
uci set wireless.@wifi-iface[1].network=lan
uci set wireless.@wifi-iface[1].mode=ap
uci set wireless.@wifi-iface[1].encryption=psk2
uci set wireless.@wifi-iface[1].ssid="$AP_SSID"
uci set wireless.@wifi-iface[1].key="$AP_KEY"

uci commit


uci set wireless.@wifi-iface[0].ssid=$ssid
uci set wireless.@wifi-iface[0].key=$key
uci set wireless.@wifi-iface[0].network=wan
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].encryption=psk2
uci set network.lan.ipaddr=
uci delete wireless.@wifi-device[0].disabled
uci set network.wan=interface
uci set network.wan.proto=dhcp
uci commit

loglite voor wifibox

firmware / web server api logs: cat /tmp/wifibox.log | loglite print3d logs: cat /tmp/print3d-ttyACM0.log | loglite

auto flash wifibox


ln -s `realpath $0` ~/bin/flash > 2&>null #installs this script as executable 'flash'

if [[ $# -ne 2 ]] ; then
    echo "Usage: flash {HOST} {FILE.BIN}"
    exit 1

if [ ! -f $2 ]; then
    echo "File not found: $2"
    exit 1


#add myself to the autorized keys on the wifibox
cat ~/.ssh/ | ssh root@$host 'cat > /etc/dropbear/authorized_keys'

#upload the file to the wifibox:/tmp/
scp "$2" root@$host:/tmp/

#sysupgrade the wifibox
ssh root@$host sysupgrade -v /tmp/$(basename $2)

install doodle3d-client in docker container

scripts/feeds update customfeeds
scripts/feeds install doodle3d-client
cat /home/openwrt/config/diffconfig >> .config
make defconfig
#make V=s package/doodle3d-client/compile
#make V=s
cp -r bin /home/openwrt/shared/

but check also [[|]]

wifibox .profile

root@wifibox:~# cat .profile
# DO NOT MODIFY - this block of lines has been added by the wifibox package.
alias d='ls -la'
alias encore='ulimit -c unlimited'
alias wopkg='opkg -f /usr/share/lua/wifibox/opkg.conf'

alias tailfw='loglite /tmp/wifibox.log firmware'
tailp3d() {
  if [ $# -gt 0 ]; then logfile=$1; fi
  loglite "$logfile" print3d

image generator test doodle3d with docker

BIN_DIR: custom output folder for packages

make package/doodle3d-firmware/compile BIN_DIR="/home/openwrt/shared/bin/" V=s

install print3d

scripts/feeds update customfeeds
scripts/feeds install print3d
make package/print3d/compile

install doodle3d-firmware (package name = wifibox)

scripts/feeds update customfeeds
scripts/feeds install wifibox   #where 'wifibox' is actually the package in 'doodle3d-firmware' repo
make package/doodle3d-firmware/compile # but make seems to use the name of the folder instead of the name of the package

Makefile:5: *** missing separator. Stop.

this might indicate spaces instead of tabs in one of your Makefile

SDK: glob failed: No files found "package/utils/busybox/config/libbb/"

(possible) solution: ln -s ../feeds/base/package/utils package/utils

SDK: configure: error: C compiler cannot create executables

solution: install 'ccache' on the host system (Ubuntu in my case)

minimal file upload using cgi script from stdin to /dev/null (or usb)

<form target="frm" action="" enctype="multipart/form-data" method="post">
<input type="file" name="datafile" size="40">
<input type="submit" value="Send">
<iframe name="frm" width="100%" height="300">
echo "Content-type: text/plain"
echo ""
- > /dev/null  # or cat > /dev/null
echo "ok"
echo ""
echo ""

tail logs through netcat

on router: logread -f | nc 8081

on pc: nc -l 8081

system.lua source

How to transfer a file from OpenWrt to your computer in Failsafe mode

On OpenWrt

sysupgrade --create-backup /tmp/backup.tar.gz   # create the file
nc 3333 < /tmp/backup.tar.gz        # push the file to the netcat server on your computer

On your computer:

nc -l 3333 > backup.tar.gz          # run a server to receive the file from the router

Flash new firmware in failsafe mode (via netcat)

read sliding switch on boot to select network configuration

info about file upload/post to openwrt

image generator osx

docker run -it ubuntu /bin/bash
apt-get update
apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc
make image PROFILE=TLMR3020 PACKAGES="kmod-usb-storage block-mount kmod-fs-ext4 kmod-usb-serial-ftdi kmod-usb-serial kmod-usb-acm uclibcxx liblua libuci luafilesystem libuci-lua libiwinfo-lua uhttpd uhttpd-mod-lua libusb-1.0 libncurses openssh-sftp-server -luci"
#last step fails

minimale aanpak

verbind met internetverbinding van je router

uci set network.lan.ipaddr=
uci delete wireless.@wifi-device[0].disabled #enable radio
uci set wireless.@wifi-iface[0].network=wan
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].ssid=Baksteen
uci set wireless.@wifi-iface[0].key=...
uci set wireless.@wifi-iface[0].encryption=psk2
uci set network.wan=interface 
uci set network.wan.proto=dhcp #get ip from router
uci commit

avahi voorbeelden toevoegen voor Bonjour/zeroconf:

opkg update
opkg install avahi-daemon-service-ssh avahi-daemon-service-http

uhttpd installeren

opkg update
opkg install uhttpd
echo hoi > /www/index.html
mkdir /www/cgi-bin
#plaats een cgi script zie


standaard zit er al wget op. dat zit in busybox. maar het ondersteund geen SSL.


tmpfs heeft ongeveer 13MB RAM vrij. dus wget zou in principe een bestand van die grootte moeten kunnen bewaren in /tmp. (getest met een GIFje, dat gaat goed). Maar beter wat ruimte overlaten.


opkg update
opkg install ser2net
#wat info hier:
#en hier een filmpje:
vi /etc/ser2net.conf
#alle /dev devices uitcommenten behalve degene van jouw seriele poort, of die toevoegen:
# 1234:raw:0:/dev/ttyACM0:9600

eerst misschien nog driver voor USBserieel installeren:

opkg install kmod-usb-acm

vervolgens kun je als ser2net draait letterlijk via telnet ontvangen en versturen. maar ja.. je wil het liefst een groot bestand in stukje gaan binnenhalen vanaf het web en ook in stukjes sturen vanaf de box zelf naar de seriele poort… Dus misschien is UltiFi ( of iets anders zelf geschreven nog niet zo gek.

minimal settings for internet and lan

uci set network.lan.ipaddr=
uci delete wireless.@wifi-device[0].disabled #enable radio
uci set wireless.@wifi-iface[0].network=wan
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].ssid=........
uci set wireless.@wifi-iface[0].key=........
uci set wireless.@wifi-iface[0].encryption=psk2
uci set network.wan=interface 
uci set network.wan.proto=dhcp #get ip from router
uci commit

settings from Doodle3D WiFi-Box

Disabling default route and DNS server for lan network interface

This way you don't have to set the order of WiFi and Ethernet.

uci set dhcp.lan.dhcp_option='3 6'
uci commit dhcp
/etc/init.d/dnsmasq reload

add custom Bonjour/mDNS/zeroconf etc service


<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <name replace-wildcards="yes">%h</name>

/etc/init.d/avahi-daemon reload

discussion about doodle3d network module

dev tutorials

own packages

clone package source

to have the make file clone from the PKG_SOURCE_URL update the PKG_VERSION

./up3dload: line 1: syntax error: unexpected "("

Cause: When you get this error on the binary you try to run on your OpenWrt device has the wrong architecture. Run file up3dload to see the architecture.

Solution: Make sure the .o files and the osx executable are not copied to the build_dir. Perform a make clean in the src/ folder of the package before make package/up3dload/compile when you did a make in your src folder to test locally.

get all strings from a binary

strings testscript

/bin/ash: testscript: not found

/bin/ash: testscript: not found

file not found usually means that a dependant library wasn't found.

file /Volumes/OpenWrt/openwrt/build_dir/target-mips_34kc_musl-1.1.14/testscript/ipkg-ar71xx/testscript/bin/testscript
/Volumes/OpenWrt/openwrt/build_dir/target-mips_34kc_musl-1.1.14/testscript/ipkg-ar71xx/testscript/bin/testscript: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, 
dynamically linked (uses shared libs), corrupted section header size

this was caused by having installed the downloaded binary of OpenWrt 15.05 instead of the one I compiled against. Maybe the difference between uClibC vs musl?

default_postinst: not found

probably because trying to install a package compiled on 15.05 to a 14.07.

build single package


(different snippets)

./scripts/feeds update customfeeds
./scripts/feeds install up3dload

# ? ./scripts/feeds update -a
# ? ./scripts/feeds install testscript
make package/testscript/prepare
make package/testscript/compile -j1 V=s
make package/testscript/install
make package/print3d/prepare
make package/print3d/compile
make package/print3d/install
make package/index


Howto Automated Wifi network change if the current fails

AP + STA at the same time

Stappen Image Builder

  • staat op : rick@ubuntu:~/Desktop/OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64

  • start Linux (bijv in Parallels met de mogelijkheid om vanaf OSX te verbinden via SSH)

  • download:

  • untar:

    tar -xvjf OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64.tar.bz2
  • zorg voor dependencies:

    apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc
  • voeg customfeeds toe aan de packages folder (maak een mapje customfeeds met daarin ipk bestanden van je customfeeds dus die moet je wel eerst ergens bouwen)

    mkdir packages/customfeeds
  • run image generator

    make image PROFILE=TLMR3020 PACKAGES="wifibox -ppp -kmod-ipv6"
  • creates image in bin/ar71xx folder. scp ….squashfs-sysupgrade.bin file to the /tmp folder of the box and run

    sysupgrade -v- n /tmp/openwrt….squashfs-sysupgrade.bin
  • Er was nog een probleem met dat er iets niet geconfigureerd was als je het gemaakte image op een wifibox plaatste. Volgens mij werd de print3d niet automatisch opgestart of herstart. inotify ging niet goed ofzo omdat dat een SETTING was ipv een DEPENDENCY.

ch340 driver info

updated sources list for barrier_breaker


dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
src/gz barrier_breaker_base
src/gz barrier_breaker_telephony
src/gz barrier_breaker_oldpackages
src/gz barrier_breaker_packages
src/gz barrier_breaker_routing
src/gz barrier_breaker_luci
src/gz barrier_breaker_management

set baudrate in uboot baudrate: a decimal number that selects the console baudrate (in bps). Only a predefined list of baudrate settings is available. When you change the baudrate (using the "setenv baudrate ..." command), U-Boot will switch the baudrate of the console terminal and wait for a newline which must be entered with the new speed setting. This is to make sure you can actually type at the new speed. If this fails, you have to reset the board (which will operate at the old speed since you were not able to saveenv the new settings.) If no "baudrate" variable is defined, the default baudrate of 115200 is used.

  • connect to serial: screen /dev/tty.usbserial 115200
  • type tpl when 'Autobooting' message is visible
  • printenv to see variables
  • setenv baudrate 9600 gives error Baudrate 9600 bps not supported

Allow SSH on WAN interface

Add to /etc/config/firewall

config rule
        option name             allow-SSH-wan
        option src              wan
        option proto            tcp
        option dest_port        22
        option target           ACCEPT
        option family           ipv4

restart firewall service /etc/init.d/firewall reload

Allow HTTP on WAN interface

Add to /etc/config/firewall

config rule
        option name             allow-HTTP-wan
        option src              wan
        option proto            tcp
        option dest_port        80
        option target           ACCEPT
        option family           ipv4

restart firewall service /etc/init.d/firewall reload


/lib/netifd /var/run

documentation for 'iw'

change ip temporary

ifconfig eth0

failsafe tftp


netwerk status

cat /var/state/network

openwrt mirror op github

setup wireless AccessPoint & connect as a station to an existing WiFi network (simultaneously)

# remove default OpenWrt AccessPoint
uci delete wireless.@wifi-device[0].disabled
uci delete wireless.@wifi-iface[0]

# Wireless AccessPoint
uci set wireless.ap=wifi-iface
uci set wireless.ap.device=radio0
uci set
uci set wireless.ap.mode=ap
uci set wireless.ap.encryption=none
uci set wireless.ap.ssid=Doodle3D

# Wireless Station
uci set wireless.sta=wifi-iface
uci set
uci set wireless.sta.mode=sta
uci set wireless.sta.ssid=Baksteen
uci set wireless.sta.encryption=psk2
uci set wireless.sta.device=radio0

# Setup network interface ‘lan’ to be used by Wireless AccessPoint
uci delete network.lan.ifname
uci set network.wan=interface
uci set network.wan.proto=dhcp
uci set network.lan.ipaddr=

# Save settings
uci commit

restore from rom

mtd -r erase rootfs_data better solution: firstboot

uci defaults

create /etc/uci-defaults/my-uci-defaults. It will be executed once when the router boots. When it exits with 0 the file will be deleted.

uci set network.lan.ipaddr=
uci commit network
exit 0

AP+STA tegelijk



ubus over http

  • uhttpd-mod-ubus
  • /usr/share/rpcd/acl.d
  • /etc/init.d/rpcd restart
  • curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "00000000000000000000000000000000", "network.interface.lan", "status", { } ] }' http://wifibox/ubus


Build dependency: Please install the openssl library (with development headers)

(in doodle3d buildroot with ubuntu when trying to make menuconfig after deleting Barrier Breaker trunk and cloning 15.05 Chaos Calmer) sudo apt-get update sudo apt-get install libssl-dev

get list of installed packages

echo $(opkg list_installed | awk '{ print $1 }')

openwrt sdk

image generator / imagebuilder

octoprint on OpenWrt

serial pins on the mr3020


buttons on the mr3020

opkg update
opkg install kmod-button-hotplug --force-depends
mkdir /etc/hotplug.d/button

create a file /etc/hotplug.d/button/my-script with your script:

sleep 1
logger "log: $BUTTON -- $ACTION  -- $SEEN"


lua serial on openwrt

veel handige info

USB-drive support on a Doodle3D WiFi-Box

  • have the box join an existing WiFi network to get internet access
  • opkg update
  • opkg install block-mount
  • opkg install kmod-usb-storage Error: collected errors: satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-usb-storage: kernel (= 3.10.49-1-0114c71ed85677c9c1e4911437af4743) - kernel (= 3.10.49-1-0114c71ed85677c9c1e4911437af4743) opkg_install_cmd: Cannot install package kmod-usb-storage.

This is because Doodle3D creates a custom firmware image. Because of this the kernel version/id is different. kmod-usb-storage needs the exact right kernel version.

Solution: 1) Install all the Doodle3D packages on a clean OpenWrt image. 2) Add the kmod-usb-storage package to the firmware (in make menuconfig)

mDNS, ZeroConf, Bonjour etc...

Multiple Access Points per radios (Multiple SSID's)

replace dropbear by openssh-server


Accessing utilities like iwinfo through ubus might also be interesting, see:

De nieuwe Luci (LuCI2) lijkt ook ubus over http te gebruiken?

steps to get started with extroot

  • flash the wifibox with a regular OpenWrt image (May be one be without LUCI to save diskspace)
  • connect an ethernet cable between the wifibox and your computer
  • setup your computer's ethernet interface to (/24 means subnetmask
  • telnet to
  • set a password with passwd to enable ssh
  • exit telnet
  • ssh root@
  • vi /etc/config/network
  • optional: choose another static ipaddress for the LAN connection (for example
  • add an interface for wlan setting the protocol to dhcp
config interface wlan
option proto 'dhcp'
  • exit vi (ESC, :, w, q)
  • vi /etc/config/wireless
  • remove the disabled option (in vi use dd to remove a line)
  • add the country option and set to NL (or other country code) (don't know why this is needed but otherwise 'Network is unreachable')
  • change the mode of the wifi-iface to 'sta' (to become a WiFi client/station instead of an accesspoint)
  • change the wifi-iface network to wlan
  • set the ssid option to that of your home WiFi network.
  • set the key to your network's password.
  • choose the right encryption for example psk2.
  • exit vi
  • reboot
  • set your computer's ethernet interface to receive a DHCP address.
  • connect with ssh
  • update the packages list: opkg update
  • opkg install block-mount kmod-usb-storage kmod-fs-ext4
  • in case you get this error: kmod: failed to insert /lib/modules/3.10.49/ext4.ko reboot your OpenWRT device
  • on your computer setup a ext3 or ext4 filesystem on a USB drive
diskutil list
diskutil unmount /dev/disk#s#
#brew install e2fsprogs   
sudo $(brew --prefix e2fsprogs)/sbin/mkfs.ext4 /dev/disk#s#
  • connect the usb drive to the OpenWrt and type block info to get info about the block devices. Check if /dev/sda1 is listed.
  • create a folder to mount the drive to mkdir /mnt/usb
  • mount sda1 to the new folder mount /dev/sda1 /mnt/usb
  • (if you get a Segmentation Fault reboot the box first)
  • (if you get an 'Invalid Argument'... then check if ext4 is listed in cat /proc/filesystems. If not then probably something went wrong while installing kmod-fs-ext4, out of diskspace for example.)
  • copy all files on the device to the usb drive:
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/usb -xf -
umount /tmp/cproot
  • mount the drive on boot by adding settings to /etc/config/fstab:
cat >> /etc/config/fstab << EOF
config mount
        option target        /
        option device        /dev/sda1
        option fstype        ext4
        option options       rw,sync
        option enabled       1
        option enabled_fsck  0
  • reboot the device.

  • type mount to see if your usb drive (/dev/sda1) is mounted to /

  • use df -h to see the large amount of space available now!

  • note that the contents of /etc/config/fstab is now different. This is normal because the contents of the file on the device is different then the one on the usb drive. The usb drive is installed 'on top of' the original filesystem. When booting the device without the usb drive you will get your original files.

  • Thanks to




image generator



boot from USB

list installed packages

opkg list

make & scp & sysupgrade

make scp /Volumes/OpenWRT/trunk/bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-sysupgrade.bin wifibox:/tmp ssh wifibox sysupgrade -v -n /tmp/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-sysupgrade.bin

oneliner: cat & make & scp & ssh sysupgrade cat ~/.ssh/ | ssh wifibox 'cat >> /etc/dropbear/authorized_keys' && make V=s && scp /Volumes/OpenWRT/trunk/bin/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin wifibox:/tmp && ssh wifibox sysupgrade -n -v /tmp/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin

add public key to authorized_keys on openwrt

cat ~/.ssh/ | ssh root@ 'cat >> /etc/dropbear/authorized_keys' or cat ~/.ssh/ | ssh wifibox 'cat >> /etc/dropbear/authorized_keys'

after that it easy to scp files without entering passwords. scp /Users/rick/Documents/Doodle3D/3dprintserver/doodle3d-firmware/src/rest/api/api_sketch.lua wifibox:/usr/share/lua/wifibox/rest/api

scp file when local file changes



while true    
   ATIME=`stat -f %Z $1`

   #echo $ATIME --- $LTIME
   if [[ "$ATIME" != "$LTIME" ]]
       echo "scp $1 $2"
       scp $1 $2
   sleep 1


error building package

make[3]: *** No targets specified and no makefile found.  Stop.
make[2]: *** [/Volumes/OpenWRT/trunk/build_dir/target-mips_34kc_uClibc-] Error 2
make[2]: Leaving directory /Users/rick/Documents/VechtclubXL/door-bell
make[1]: *** [package/feeds/bell/door-bell/compile] Error 2
make[1]: Leaving directory /Volumes/OpenWRT/trunk

in our case the folder-name containing the package did not match the package name.

while adding packages: Ignoring feed 'bell' - index missing

solution: ./scripts/feeds update -a instead of: ./scripts/feeds update

tip van Ruben over mr3020

opkg update fails

~# opkg update
wget: server returned error: HTTP/1.1 404 Not Found
Collected errors:
* opkg_download: Failed to download, wget returned 1.

solution: In a live Openwrt system, the last lines in /etc/opkg.conf should be:

src/gz chaos_calmer_base
src/gz chaos_calmer_luci
src/gz chaos_calmer_management
src/gz chaos_calmer_packages
src/gz chaos_calmer_routing
src/gz chaos_calmer_telephony

instead of that one line src/gz something )


controlling LEDs through GPIO

cd /sys/class/leds/tp-link\:green\:3g/ echo 1 > brightness

echo 0 > brightness

wifi repeater


Hidden Sound System

 <li><a href="javascript:play('')">Pinguin Radio</a>
function play(url) {

function stop() {

function get(url) {
  var xmlhttp = new XMLHttpRequest();"GET", url, false);


  textarea {
    width: 100%;
    height: 90%;
    font-family: monospace;
    font-size: 1em;

<form action="cgi-bin/save" method="POST">
<input type="submit" value="Save">
<input type="button" value="Cancel" onclick="location.href='/'">
<textarea id="txt" name="txt"></textarea>

var xmlhttp, text;
xmlhttp = new XMLHttpRequest();'GET', 'index.html?'+Math.random(), false);
document.getElementById('txt').value = xmlhttp.responseText;



echo "Content-type: text/plain"
echo ""
killall madplay -q
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i)')
url=`uhttpd -d $url`
wget -O - $url | madplay - & 
echo "ok"
echo ""
echo ""


#echo "Content-type: text/plain"
#echo ""
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i)')
cp index.html index.bak
uhttpd -d $txt > index.html
#cat index.html
echo "Status: 301 Moved"           
echo "Location: /"                   
echo ""                            
echo ""


echo "Content-type: text/plain"
echo ""
killall madplay -q
echo ""
echo ""

FAT-fs (sda1): IO charset iso8859-1 not found (while mounting a usb device)

/sbin/insmod nls_iso8859-1

environment variables including hostname in cgi-bin

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


uci show

create a dumb AP

config wifi-iface
        option device   radio0
        option network  lan
        option mode     ap
        option ssid     OpenWrt
        option encryption none

authorized keys instructions with dropbear

  • put your public key string in '''/etc/dropbear/authorized_keys'''

AirPlay on the MR3020

usb over IP


TP-Link wr702n

draait geen OpenWrt maar kan wel als Arduino shield gebruikt worden:

cgi-bin read GET QueryString

echo "Content-type: text/plain"
echo ""
#echo $QUERY_STRING     
#read QUERY_STRING                                                      
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i)') 
#txtOutput=`uhttpd -d $b`         
echo $b > /dev/ttyACM0
echo ""
echo ""

arduino connected to internal serial port

wifi settings


config wifi-device  radio1
    option type     mac80211
    option channel  11
    option macaddr  ec:88:8f:dc:c6:4e
    option hwmode   11ng
    option htmode   HT20
    list ht_capab   SHORT-GI-20
    list ht_capab   SHORT-GI-40
    list ht_capab   RX-STBC1
    list ht_capab   DSSS_CCK-40

config wifi-iface
    option device   radio1
    option network  wan
    option mode     sta
    option ssid     Globe4D
    option encryption psk2
    option key  .........

toggle USB power on MR3020

ON: echo 1 >/sys/class/gpio/gpio8/value
OFF: echo 0 >/sys/class/gpio/gpio8/value

voip on openwrt

opencv on openwrt


dit nog uitproberen:

flash existing openwrt install from remote

create a shell script:

if [ $# -eq 1 ]; then
    FILENAME=`basename $IMAGE`
    scp $IMAGE root@wifibox:/tmp
    ssh -t root@wifibox "sysupgrade -v -n /tmp/$FILENAME"

restart uhttpd

bash/etc/init.d/uhttpd restart

scp a doodle3d file to the box

scp /Users/rick/Documents/Doodle3D/3dprintserver/doodle3d-firmware/src/conf_defaults.lua wifibox:/usr/share/lua/wifibox/
scp /Users/rick/Documents/Doodle3D/3dprintserver/doodle3d-firmware/src/util/* wifibox:/usr/share/lua/wifibox/util/

stop a (doodle3d) process and start manually in verbose mode

/etc/init.d/print3d stop
print3d -v

updating firmware


scp openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-sysupgrade.bin root@


mtd -r write openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-sysupgrade.b
in firmware

usb over IP

check if this works:

save contents of form variable to file in /tmp


<form method="post" action="cgi-bin/">
<textarea name="txtOutput" rows=50 cols=100></textarea>
<input type="submit">


echo "Content-type: text/plain"
echo ""
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i)')

txtOutput=`uhttpd -d $txtOutput`
echo $txtOutput > /tmp/file.txt

echo ""
echo ""

automatic install OpenWrt firmware on TPLink MR3020

restore original MR3020 firmware

get mac address

ifconfig wlan0 | awk '/HWaddr/ { print $5 }'

replace dropbear by open-ssh-server

mount usb disk on startup

in /etc/config/fstab

config 'mount'
        option 'target'   '/mnt'
        option 'device'   '/dev/sda1'
        option 'fstype'   'ext2'
        option 'enabled'  '1'
        option 'enabled_fsck' '0'

on osx to prepare a ext2 usbstick

locate mke2fs
diskutil list
diskutil unmount /dev/disk{...}
mke2fs /dev/disk{...}
mkfs.ext2 /dev/disk{...}

(not tested: or install '''' and use the Mac OSX Disk Utility to erase the usb-drive using fuse-ext2)


follow log file

logread -f

network/wireless config files gemaakt op ohm2013


config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr ''
option netmask ''

config interface 'lan'
option ifname 'eth0'
option type 'bridge'
option proto 'static'
option netmask ''
option ipaddr ''

config interface 'wan'
option _orig_ifname 'wlan0'
option _orig_bridge 'false'
option proto 'dhcp'


config wifi-device  radio1
    option type     mac80211
    option channel  11
    option hwmode   11ng
    option path 'platform/ar933x_wmac'
    option htmode   HT20
    list ht_capab   SHORT-GI-20
    list ht_capab   SHORT-GI-40
    list ht_capab   RX-STBC1
    list ht_capab   DSSS_CCK-40
#   option disabled 1

config wifi-iface
    option device   radio1
    option network  wan
    option mode     sta
    option ssid     OHM2013
    option proto    dhcp
    option encryption none

start up script

not finished....

#!/bin/sh /etc/rc.common
start() {
        /Doodle3D/Doodle3D > /dev/null 2> /dev/null &

enable wireless

By default the wireless is OFF. You can turn it on in the /etc/config/wireless by changing disabled 1 to disabled 0 In UCI CLI you do this with:

uci set wireless.@wifi-device[0].disabled=0; uci commit wireless; wifi

scan script

ifconfig wlan0 down
iw phy phy0 interface add scan0 type station
ifconfig scan0 up
iwlist scan0 scan | grep ESSID  | cut -c 27- | tr -d '"'
iw dev scan0 del
ifconfig wlan0 up

connect script

uci set wireless.@wifi-iface[0].ssid=$1
uci set wireless.@wifi-iface[0].encryption=$2
uci set wireless.@wifi-iface[0].key=$3
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].network=wan
uci commit wireless

accesspoint script

uci set wireless.@wifi-iface[0].ssid=Doodle3D
uci set wireless.@wifi-iface[0].encryption=none
uci set wireless.@wifi-iface[0].key=''
uci set wireless.@wifi-iface[0].mode=ap
uci set wireless.@wifi-iface[0].network=lan
uci commit wireless

scan for wireless networks

Failsafe mode

Regenerate Wireless Configuration

To rebuild the configuration file, e.g. after installing a new wireless driver, remove the existing wireless configuration (if any) and use the wifi detect command with stdout redirected to the /etc/config/wireless file:

rm -f /etc/config/wireless
wifi detect > /etc/config/wireless

bootstrap skin for OpenWrt by nut&bolt

  • download and install the 'luci-theme-bootstrap' package

press for connect


  • more from [[|batman]]
    uci delete wireless.wifi0.disabled
    uci delete wireless.@wifi-iface[0].network
    uci set
    uci set wireless.@wifi-iface[0].mode=adhoc
    uci set wireless.@wifi-iface[0].ssid=afrimesh
    uci set network.lan.mtu=1500
    uci set network.lan.ifname="eth0 bat0"
    uci set network.lan.proto=dhcp
    uci delete network.lan.ipaddr
    uci delete network.lan.netmask
    uci set network.wifi0=interface
    uci set network.wifi0.ifname=ath0
    uci set network.wifi0.proto=none
    #uci set network.wifi0.mtu=1524
    uci set network.wifi0.mtu=1548
    uci set network.bat0=interface
    uci set network.bat0.ifname=bat0
    uci set network.bat0.proto=none
    uci set network.bat0.mtu=1500
    uci set batman-adv.bat0.interfaces=ath0
    uci commit

forward all DNS traffic to device


list address            '/#/'
uci add_list dhcp.@dnsmasq[0].address='/#/'
uci commit dhcp

wifi scan and show in list

echo "Content-type: text/plain"
echo ""
iwlist wlan0 scan | grep ESSID  | cut -c 27- | tr -d '"'
  <script src=""></script>

    $.get("cgi-bin/wifi-scan", function(data) {
      data = data.split("....fixme.....");
      var options = $("#boxNetwork");
      $.each(data, function(index,value) {
    if (value!="") options.append($("<option />").val(value).text(value));


    <select id="boxNetwork">
        <option value="" disabled selected>Scanning for neworks...</option>
    <input id="txtPassword" placeholder="password" value="" type="password">
    <input id="btnConnect" type="button" value="Connect">


cross compile on Mac

Create case sensitive HFS:

hdiutil create -size 15g -fs "Case-sensitive HFS+" -volname OpenWRT ~/OpenWRT.sparsebundle
hdiutil attach OpenWRT.sparsebundle 

Checkout OpenWRT source:

cd /Volumes/OpenWRT && svn co svn://;

Run 'feeds update' script:

cd trunk; scripts/feeds update -a

selfupdate & subversion

sudo port -v selfupdate; sudo port install subversion

install dependencies:

sudo port install coreutils e2fsprogs ossp-uuid asciidoc binutils bzip2 fastjar flex getopt gtk2 intltool jikes \ zlib openssl p5-extutils-makemaker python26 rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget \ gmake ncurses findutils

make menu

make prereq; make defconfig; make menuconfig

install everything for cross-compiler...

make V=s


reading and writing config values through uci (recommended)

uci get wireless.@wifi-iface[0].key
uci set wireless.@wifi-iface[0].key=YOURKEY
uci set$wifichannel
uci set wireless.wificlient.ssid="$wifissid"
uci set wireless.wificlient.encryption=$wifimode
uci set wireless.wificlient.key=$wifipass
uci commit wireless
wifi down

how to debrick

show login intro text

bashcat /etc/banner

How do I access the syslog messages?

bash logread

list connected dhcp clients

bashcat /tmp/dhcp.leases


scan for wifi networks

iwlist wlan0 scan | grep ESSID  | cut -c 27- | tr -d '"'

get current wifi configuration

iwconfig wlan0

ideale setup voor doodle3d box zou zijn

  • eerst proberen te verbinden met een het laatst verbonden netwerk
  • als die niet beschikbaar is dan proberen te verbinden met vorige etc.
  • als geen enkel netwerk zichtbaar is dan zelf een AP starten waarmee in een vriendelijke webpagina (die automatisch toont via dns route) gescand kan worden naar beschikbare netwerken.



network restart

/etc/init.d/network restart

settings with cat


config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr ''
    option netmask ''

config interface 'lan'
    option ifname 'eth0'
    option type 'bridge'
    option proto 'static'
    option netmask ''
    option ipaddr ''

config interface 'wan'
    option _orig_ifname 'wlan0'
    option _orig_bridge 'false'
    option proto 'dhcp'

config wifi-device 'radio0'
    option type 'mac80211'
    option channel '11'
    option macaddr 'ec:88:8f:c6:10:a6'
    option hwmode '11ng'
    option htmode 'HT20'
    list ht_capab 'SHORT-GI-20'
    list ht_capab 'SHORT-GI-40'
    list ht_capab 'RX-STBC1'
    list ht_capab 'DSSS_CCK-40'
    option txpower '27'
    option country 'US'

config wifi-iface
    option device 'radio0'
    option mode 'sta'
    option ssid 'Blendid'
    option encryption 'psk2'
    option key '...................................'
    option network 'wan'

cat <<

cat << EOM >> tmp.txt
.... paste text here

getting started

running in wifi client mode


config interface 'wan'
        option ifname 'wlan0'
        option proto 'dhcp'


config wifi-iface                  
        option device radio0 
        option network wan   
        option mode sta      
        option ssid ...
        option encryption psk2
        #or psk instead of psk2
        option key ....

scan for wifi networks

bashiwlist scanning bashiwlist wlan0 scan


useful wiki by acemonstertoys

list serial devices

ls -1 /dev/ttyACM*

process ID

echo $$


cgi script extracting POST variables

echo "Content-type: text/plain"
echo ""
#???? read QUERY_STRING
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i)')

#echo $txtOutput

txtOutput=`uhttpd -d $txtOutput`
echo $txtOutput

serial port

Alleen ''opkg install kmod-usb-acm'' lijkt nodig.

opkg update
opkg install coreutils-stty 
opkg install kmod-usb-serial
opkg install kmod-usb-serial-ftdi
#opkg install kmod-usb-serial-cp210x 
opkg list | grep -i acm
kmod-usb-acm - - Kernel support for USB ACM devices (modems/isdn controllers)
opkg install kmod-usb-serial
opkg install coreutils-stty 
opkg install kmod-usb-acm

By default everything that comes to WR703N serial port is echoed back. If you also want to send commands to Arduino, the buffer will be full with echoed data. Need to set no echo option in sstty. bash/usr/bin/stty -F /dev/ttyACM0 raw speed 115200 -echo

Arduino is reset every time it is read by command "head" To disable reset by DTR pin add option to stty

/usr/bin/stty -F /dev/ttyACM0 raw speed 115200 -echo
cat /dev/ttyACM0

sh scripting for serial

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


if  [ -c $PORT ]; then                                                       
      /usr/bin/stty -F $PORT raw speed 115200 -echo -hupcl                   
      while [ 1 ]; do                                                        
              if [ -c $PORT ]; then                                          
                      head -n 8 $PORT                                        
                      sleep 1                                                
                      # USB dissapeared.                                     
                      echo "Arduino no longer attached"                      
      echo "Arduino not attached"                                            

disk usage

du * -sh

symbolic link from www folder to /mnt

ln -s /mnt/ www2

install opkg packages on usb-stick

* add bashdest usb /mnt/ to bash/etc/opkg.conf

export USB=/mnt
export PATH=$PATH:$USB/usr/bin:$USB/usr/sbin
export LD_LIBRARY_PATH=$USB/lib:$USB/usr/lib
opkg install unzip -d usb

compilen vanaf windows of linux voor openwrt

*[[|Sourcery CodeBench Lite Edition]]

scp (secure copy)

scp from to

scp root@ 

create large file with zeros (10MB)

dd if=/dev/zero of=/mnt/largefile bs=1024 count=10240

usb storage

opkg install kmod-usb-storage block-mount kmod-fs-vfat  kmod-nls-cp437 kmod-nls-iso8859-1 
mount /dev/sda1 /mnt



writable permanent store


for humans diskfree info

df -h


bevat textfiles met info over je systeem zoals bashcat /proc/filesystems

mount usb drive

flush firewall settings

iptables -F
iptables -L


captive portals


opkg update
opkg install openssh-sftp-server
  • ??? bashgcom info -d /dev/ttyUSBx


  • use '''kmod-usb-storage''' for usb drive support

  • config


cross compiling

using Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux on Windows

 mips-linux-gnu-gcc -static -s -msoft-float -muclibc hello.c -o hello