WRT54GL MAX232 Serial

From DD-WRT Wiki

Jump to: navigation, search

Contents

[edit] Serial port on a Linksys WRT54G/GL router using a MAX232 interface IC

This brief tutorial describes how to add two standard RS-232 serial ports to a Linksys WRT54GL router; the same is applicable to several other models based on the same hardware (WRT54G line et all). The MAX232 is a level converter IC for serial communications which is cheap and available pretty much anywhere.

An alternative is connecting the TTL-level signals directly to a serial-to-USB converter.

[edit] Technical overview

Most routers of the WRT54G line include two serial ports, complete with pinholes on the circuit board. These operate at 3.3v (TTL) level, so they need a level converter in order to work with a regular RS-232 serial port. This is normally done with a level converter IC, and of all available, MAX232 is the most popular. The problem is that this IC requires at least 4v in order to work properly, and the pin header provides 3.3v.

A solution proposed in several sites is to use a compatible device which allows operation at 3.3v (MAX3232, MAX233), but this are normally more expensive and (most important) difficult to find in several parts of the world. This document describes a workaround which allows us to power a MAX232 with 5v within the circuit board, which allows the use of this IC and provides excellent performance. Since the MAX232 detects a signal level change at around 2v and we're providing 3.3v signals, it works flawlessly.

[EDIT - Bib 7 nov 2008]: Max233 only works with 5V supply, but doesn't require the 4 C3-C6 capacitors as they are built in. It only needs to short 3 pairs of pins. Be careful, the pin out is completely different than Max232: check data sheet.

My favourite is the Max3233: works from 3V to 3.6V (so doesn't need the below red wire nor 78L05 C1 C2 & 4 C3<->C6 built in capa). Once again, check data sheet for pin out. An other interesting feature is the "AutoShutDown Plus" circuitry that can decrease the power consumption to about 1µA when no input signal is detected, by shutting down the charge pump that builds the 10/11Vpp needed at Tx outputs.

[edit] Details

What we'll do is basically to take power directly from the power connector and convert it to 5vdc. The serial pinout arrangement allows to do this without the need for an additional cable over the board, but this is NOT RECOMMENDED, as it involves soldering a power wire (directly from the wall adapter!) into the serial header. It can be done, but if you don't feel comfortable doing this I'd recommend soldering a wire and taking power directly from it instead through the serial header.

The voltage conversion is done using a 78L05 5vdc voltage regulator, which is cheap, small and does the job nicely. I considered using a simple zenner regulator, but from what I've seen the wall adapter voltage varies wildly between models and even regions, so the 78L05 regulator will do a much better work here.

The first step is to solder a pin header to the serial pinholes on the board - this will allow us to work easier and without further soldering on the board. The detailed pinout is for a Linksys WRT54GL / WRT54G v4; the pinout for other models is similar, but you'll need to check them out.

Image:max232_serial_mod_-_header_closeup.jpg

(Ignore the black wire there - it's from a SD/MMC mod on the same router)

Now, you need to locate the power input on the board and solder a wire to it - this can be done directly on the underside of the board:

Image:max232_serial_mod_-_board_underside_closeup_-_1.jpg

We'll be using this wire to power our adapter board. What i did here was connecting this wire directly to the two unused pins on the serial header, in order to keep a tidier wiring. AGAIN: DON'T DO THIS IF YOU'RE NOT COMPLETELY CONFIDENT OF YOUR SOLDERING SKILLS - the unused pins lie between ground and the Rx serial inputs. This means that a bad solder can either fry your serial ports, your power adapter, or the router entirely. Just taking this wire directly to the adapter board will work just as well, even if it's a bit messier.

Image:max232_serial_mod_-_board_underside_closeup_-_2.jpg

Image:max232_serial_mod_-_board_underside.jpg

(Again, that rogue connector is for the MMC/SD socket. Disregard).

This wire/pin will provide with at least 9vdc which we can use to power the MAX232 IC. The adapter schematic is rather simple, and as follows:

The pinouts for serial port 1 (female DB9) and serial port 2 (male DB9) can be found on the web. VCC is the wire/pin we just added/modified. All caps should be rated for 50v (they're small at those capacitances), and the regulator is, as mentioned, a 78L05. A regular 7805 will work just as fine, but it's much bigger and might present issues due to the low power draw of the MAX232.

I built mine on a small perfboard which plugs into the pin header and goes to an old PS2 board plug which i inserted in the back panel. Then i built a cable which provides the two regular DB9 serial connectors (if you're missing two caps, they're on the underside).

Image:max232_serial_mod_-_adapter.jpg

Serial port 1 provides kernel messages during bootup and a console, so it can be used for testing. Set your serial port config to 115200, 8 bits, no parity, 1 stop bit (8N1), reboot your router and you should get something like:

CPU type 0x29008: 200MHz
Total memory: 16384 KBytes

Total memory used by CFE:  0x80300000 - 0x803A39C0 (670144)
Initialized Data:          0x803398D0 - 0x8033BFE0 (10000)
BSS Area:                  0x8033BFE0 - 0x8033D9C0 (6624)
Local Heap:                0x8033D9C0 - 0x803A19C0 (409600)
Stack Area:                0x803A19C0 - 0x803A39C0 (8192)
Text (code) segment:       0x80300000 - 0x803398D0 (235728)
Boot area (physical):      0x003A4000 - 0x003E4000
Relocation Factor:         I:00000000 - D:00000000

Boot version: v3.7
The boot is CFE

mac_init(): Find mac [00:1C:10:34:40:40] in location 0
Nothing...

eou_key_init(): Find key pair in location 0
The eou device id is same
The eou public key is same
The eou private key is same
Device eth0:  hwaddr 00-1C-10-34-40-40, ipaddr 192.168.1.1, mask 255.255.255.0
        gateway not set, nameserver not set
Reading :: Failed.: Timeout occured
Loader:raw Filesys:raw Dev:flash0.os File: Options:(null)
(...)

The circuit is pretty straightforward - if you have any issues, check first the output voltage of the regulator and the pinouts for both the IC and the serial Rxs and Txs. Good luck!

[edit] Disclaimer

Of course, i cannot be held responsible for damages which result from carrying out this procedure. It worked for me, but you are completely on your own if you decide to do it. And needless to say, this mod WILL void your product warranty.