Mis-adventures in OpenWRT (TL-WR741ND)

While waiting for a long 3D print job to finish, I got to installing OpenWRT on a TP-Link router I have here in the office… The long and short of it, I managed to brick the device. Even thought the TL-WR741ND is supported by OpenWRT, I managed to flash the wrong image on to it.

So what to do next.. It was cheap and I was going to scrap it and forget about it, but I couldn’t let it go!  I popped to cover and read about console access over on the OpenWRT site.

I dug out one of my USB FTDI cables and got soldering…

TP Link TL-WR741ND with cover off

TP Link TL-WR741ND with cover off

Simple enough to connect to a serial lines back to the FTDI break out board. TP4 is TX, TP5 is RX and ground is taken from the bare copper trace.

Tap points for UART

Tap points for UART

Got a serial terminal program up and running on my lab PC, set to 11520,n,8,1.  Turn on the power and bingo, console data coming thick and fast! Cool.. except the Linux image I had flashed didn’t want to boot.  Corrupt image file, the boot loader was stuck in a loop.

How to stop uBoot from cycling all the time and get access to the CLI?
Tried the ESC key a few time, no joy.. Reading around the web someone else suggested the ~ key.. still no luck.  I found a post about another TP-Link router and mention of the keystroke “tpl” to get to the uBoot CLI.  Typing really fast then the “Autobooting in 1 seconds” message came on the console, bingo the boot loop stopped and I had a CLI.

Serial uBoot debugNext, how to get a new image flashed? Well that is quite easy with uBoot.. One can flash an image from a TFTP server. So armed with the correct image and a running TFTP server, this is what I did on the console:

ar7240> setenv serverip <TFTP server IP>
ar7240> setenv ipaddr <Temp IP address on my network>
ar7240> tftpboot 0x80000000 orig.bin
ar7240> erase 0x9f020000 +0x3c0000
ar7240> cp.b 0x80000000 0x9f020000 0x3c0000
ar7240> bootm 0x9f020000

Reboot, and we’re good…

Using command line to find image of a certain size

Just a quick post of a solution to a problem I was faced with today…

So I have a directory with about 8,000 images in it and I needed to find an image that was 280 pixels in width.  How to find the images using the command line?

Well here is what I came up with:

for f in *.jpg;do if [ `identify $f | cut -f3 -d\ | cut -f1 -dx` -eq 280 ] ; then echo $f;fi;done

Works nice..  There are other versions of this out there, but they work on PNG’s not JPEG’s because the “file” commend does not return the size of a JPEG.

# file somefile.png
somefile.png: PNG image, 755 x 70, 8-bit/color RGB, non-interlaced
# file somefile.jpg
somefile.jpg: JPEG image data, JFIF standard 1.01

Bummer; but “identify” does return size data, cool..

# identify somefile.jpg
somefile.jpg JPEG 80x100 80x100+0+0 8-bit DirectClass 2.64KiB 0.000u 0:00.000

Cut the output and check for the matching size.. easy!

BeagleBone and USB GSM Stick

More sysadmin than electronics today!

I have an O2 USB modem and I was wondering about getting the BeagleBone hooked up to it.  It would be cool to have the BeagleBone “phone home” if is was out in the field logging, or whatever.

Front side of my USB GSM modem

As you can see form the photo of the back-side it’s a Huawei Mobile Broadband E1752C USB modem.

The back side of the Huawei Mobile Broadband E1752C USB stick

It turns out to be really easy to use this (or any other USB GSM modem) with Ubuntu.  It a little “old school” without a GUI to work in, but hay, command line is king after all!.. It brings back memories of using pppd and chat scripts when I used Linux to connect over a copper phone line to the “Internet!”.

On the O2 network here in Ireland my /etc/ppp/peers/o2 file looks like this:

connect "/usr/sbin/chat -v -f /etc/chatscripts/o2"
user "o2"
password "o2"
ipcp-max-failure 5
lcp-echo-failure 5
lcp-echo-interval 30


# compression

And my chat script looks like this:


""    AT
OK    "ATD*99#"

Nice little trick here for the PIN entry.. You need it the first time the modem boots up, but not for re-connecting the “TIMEOUT 5 ERROR-AT-OK” will allow the PIN code to fail (because it already been entered) and not stop the script.

As I want to remote connect to BeagleBone, I’ve got it to send it’s IP address back to base (every time the PPP interface comes up).  You will need to set up shared SSH keys between your server and the Bone to get this to work without a password.

Then I created the following little script ( /etc/ppp/ip-up.d/001updateIP ):

# scp the current IP address back to base...
# (MMcK 2012-11-19)

/sbin/ifconfig -a \
    | awk '/inet addr/ { print $2 }' \
    | awk -F: '{ print $2 }' \
        > /tmp/bone.ipaddr

/usr/bin/scp -q /tmp/bone.ipaddr <me>@<my server>:

Now every time the Bone comes online over the PPP interface I can connect to it by looking up it’s new IP address.