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!