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…

Carambola IO board with 8 relays and 8 inputs

Time to interface this great Carambola board I have. The I2C board I made up in the last post worked really nicely with the Carambola development board, so this seemed the natural progression.. Piggyback the Carambola on the 8 channel IO board, give it some power, an Ethernet jack, and this should be a nice little board for control / monitoring.  The board can work either wired or wireless, and by using a LM2575 Buck switching regulator, the board can run from 5V to 40V.

Here is first sheet of the schematic:

Schematic for Carambola IO Board with relays (1 of 2)

Schematic for Carambola IO Board with relays (1 of 2)

The second:

Schematic for Carambola IO Board with relays (2 of 2)

Schematic for Carambola IO Board with relays (2 of 2)

All done in KiCad. Below is the PCB layout.  Might have got it onto a single sided PCB with a few links, but pushed the boat and went double sided for this one! The components are all through hole so this should be easy to make when the parts arrive. I’ve designed in a header on the right hand side that would allow a 1-wire DS18B20 to be connected along with breaking out the i2c, SPI and UART. The PCB layout fits neatly on a Eurocard PCB (100 x 160mm).

Two layered PCB for Carambola IO Board with relays

Two layered PCB for Carambola IO Board with relays

All the info you need should be here: Carambola IO Board.tar (KiCad project files, BOM for Farnell parts, etc)

Arduino – WiFi controlled RGB Leds

Following on from yesterdays post, I’ve decided that the remote control is not the way to go… I think these RGB LEDs need to be controlled from Internet.  Had a dig around in my parts bin and found a WiFly Shield, wrote a simple Telnet server for it that parses the colour data from the input and updates the PWMs.

Arduino WiFly Shield and RGB LED controller

Arduino WiFly Shield and RGB LED controller

Then wrote a PHP application that uses a colour wheel (jQuery based, called Farbtastic) to get a set colour and transmit the colour code over our network to the Arduino.

Basic RGB LED control page

Basic RGB LED control page

It uses a very simple socket connection to get the data over to the Arduino.. Here is the set colour handler:

<?php

$colour = $_REQUEST["c"];

$fp = fsockopen("10.0.0.67", 23, $errno, $errstr, 30);
$rply = '';
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = $colour."\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        $rply .= fgets($fp, 16);
    }
    fclose($fp);
}

if ( substr( $rply, 0, 2) == 'OK' ) {
    header("location:./?d=y&c=".urlencode($colour) );
    exit();
    }

header("location:./?d=n&c=".urlencode($colour) );
?>

Work nice, now I can set the light colour over the web… cool!