OpenWrt Forum Archive

Topic: My serial hardware solution on my WRT54G v2.2

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Here are my notes from my serial project for the WRT54g.

This isn't pretty or necessarily well designed.  You can find plans for those elsewhere.
It's my quick and dirty, hurry up and get it done already using stuff lying around method:
I installed a pin header for the serial port using the pins below.
The missing pins make good polarity (I had to leave out pin 10 also as
the IDC connector was already filled for that hole).

I read in others experience to stick something in the hole
of the idc connector for pins 7&8  to make sure it doesn't get
put in backwards.  Excellent idea.

My WRT54G v2.2 serial port pinout:

  2 4 6 8 10
| o o o - o |
| o o o - o |
  1 3 5 7 9
Pins 1,2 = 3.3v
Pins 3,4 = TX (ttyS1,ttyS0)
Pins 5,6 = RX (ttyS1,ttyS0)
Pins 7,8 = NC
Pins 9,10 = GND

I took two male DB9 connectors I salvaged from a 486 machine
that terminate as 10 pin idc connectors (with pin 10 blocked).
(They were to connect the serial ports from the mobo to the case).

I cut off the IDC connectors, discarded one and soldered the wires
of the other directly to the breadboard to form the connection
between the WRT and the breadboard.

The breadboard was a corner of a piece of copper clad perf-board from Radio Shack.

Next, I soldered on the DB9 connectors using only 3 wires each,
making sure that I pinned out the ribbon cable to the DB9 connector pins!

I used a stock TI MAX232N from for 78 cents plus 5
electrolytic 1uf caps for the basic level shifter.

The chip normally does  5Volts for +/-8v RS232 levels.
With a 3.3V supply, it still worked for me and my PC (terminal)
I measured (+4.81, -5.76v levels for rs232)

Schematic:  (Observe polarity of caps)

 WRT pins 1/2 ---------> ^ +3.3v        1uf
                         +--------------+||------------- to GND
                   |            |
 WRT pin 6  <--- 9 | from rs232 | 8 <--- rs232 DB9(a) pin 2
                   |   (ttyS0)  |
 WRT pin 4  --> 10 |  to rs232  | 7  --> rs232 DB9(a) pin 3
        .......... | .........  |...........
 WRT pin 5  <-- 12 | from rs232 | 13 <-- rs232 DB9(b) pin 2
                   |   (ttyS1)  |
 WRT pin 3  --> 11 |  to rs232  | 14 --> rs232 DB9(b) pin 3
                   |            |
       +-------- 5 |   max232   |
       |   1uf     |            |
       +---||+-- 4 | <-charge   |
                   |   pump     |      1uf
       +-------- 3 | <-caps     | 6 ----||+--- to GND
       |   1uf     |        --> |      1uf
       +--+||--- 1 |            | 2 ---+||---- to GND
                   |     15     |
 WRT pins 9/10  ---------+------------- connect to pin 5 on
                         |              both DB9(a) and DB9(b) serial connectors

After putting everything on the breadboard, I enclosed it in
discarded plasic packaging to avoid shorts and located it in the box,
bringing the two DB9's out via a dremmeled slit between the
top cover and the front blue piece.

I needed a male to male converter AND a null modem cable to
communicate with the PC.

I set communcations to 115200,N,8,1 with NO Flow Control,
connected DB9(a) and was treated to WRT kernel messages
at bootup.

YMMV.  Try this only  at your own risk.

Disclaimer: Don't blame me for anything that results from your own experience,
for instance, if your router smokes, or if your house burns down, or if the shiny new computer you hook this up to frys!

Comments, questions, success or horror stories  welcomed.

Good Luck!

ttyS0 defaults to 115200,N,8,1,No Handshaking.
ttyS1 defaults to 9600,N,8,1,No Handshaking.

ttyS0 can be written to by sending data to /dev/tts/0
ttyS1 can be written to by sending data to /dev/tts/1

At the risk of repetition, but with the advange of adding this in a relevant place, as well as the searchable forum, I quote from the

2.1. Spawn a shell on serial console
By default, no shell is initiated on the serial console line. Remember that stock out-of-the-box OpenWRT points /etc/inittab to /rom/etc/inittab, which means you should follow the  FAQ question coverting how to do this.
Add the following to /etc/inittab. Make sure this line comes IMMEDIATELY after the ::shutdown: entry, and before any other services (dnsmasq, etc...)!:

::respawn:/bin/ash 0</dev/console 1>/dev/console 2>&1

Then send a HUP signal to init (kill -HUP 1). You should now have a working shell via serial console.
If you may receive the message: ash: can't access tty; job control turned off, then /bin/ash isn't the first application spawned by init; the first application gets control of the tty. If dnsmasq or other toys come first, they will have control of the tty, hence the lack-of job control.

Are you sure that the pinouts for the MAX232 are correct?

I've built this twice and still no joy.... Remembering that the pins on the MAX232 go:

1  16
2  15
3  14
4  13
5  12
6  11
7  10
8  9

EDIT: found the problem. RS232 pins are reversed. Pin 2 should connect to the max232 on pin 7, and RS232 pin 3 should connect to max232 pin 8.

Just a piece of information on /dev/tts/1.

This second serial port is kinda slow not just because of the default rate of 9600 bps but because there's no IRQ assigned to it, causing the device driver to do polling.

You can fix it by using setserial.

setserial /dev/tts/1 irq 3


The way you hook up the RS232 pins depends if you want to configure it as DTE or DCE equipment.  PC's are DTE, and since the Linksys is (to me) a small PC, I wired it as DTE.  To use it with a PC,  you would need a null modem cable, which switches those rx and tx lines around.

If you want it to be DCE  (I.e. like a modem or something that hooks directly to the PC), then you are correct to switch the pins (and use no null modem cable).

I am very happy to hear that someone else has tried and had success with this method.


Here's a simpler circuit with an exact specification part:
3.0-3.6 supply voltage, and produces true RS232 levels (greater than +5/-5V).
and just one capacitor needed (between VCC and GND)
Much pricer though at $8+ from digikey
(a bit cheaper from maxim-ic direct).

 WRT pins 1/2 ---------> ^ +3.3v
                         |             .1uf
                       +-+-------------+||---------- to GND
                     10| | 9
                   |            |
 WRT pin 6  <--- 6 | from rs232 | 8 <--- rs232 DB9(a) pin 2 (for DTE config, or
                   |   (ttyS0)  |                       pin 3 for 'to PC' DCE)
 WRT pin 4  -->  4 |  to rs232  | 7  --> rs232 DB9(a) pin 3 (for DTE config, or
                   |            |                       pin 2 for 'to PC' DCE)
        .......... | .........  |...........
                   |            |
 WRT pin 5  <--  1 | from rs232 | 20 <-- rs232 DB9(b) pin 2 (for DTE config, or
                   |   (ttyS1)  |                       pin 3 for 'to PC' DCE)
 WRT pin 3  -->  3 |  to rs232  | 19 --> rs232 DB9(b) pin 3 (for DTE config, or
                   |            |                       pin 2 for 'to PC' DCE)
                   |  max3233   |
                   |   ecpp     |
                   |  in 20pin  |
                   |    dip     |
                   |            |
                   |     18  5  |
                         |   |
 WRT pins 9/10  ---------+---+--------- connect to pin 5 on
                         |              both DB9(a) and DB9(b) serial connectors

YMMV.  The usual disclaimers apply.

Here is a Picture of my Layout. Dont watch at the art-value.
Its easy to build on a platine with hole-striped-copper (dont know the english word in german its "Lochstreifenplatine").

Its the view from upper side so you wont see the copper-stripes as viewed in the picture.

You need:

1 MAX3232  (about 5 Euro)
1 hole-stripe-board (or whatever the name is)
5 1uF electrolyte caps  (16 Eurocent each)
1 9 Pin Sub-D for connection to PC

Hope someone can use it.
Layout is in the picture attached to this post.

caps are drawn as circles. black points mean contacts. lines are wireconnections.

Everything you do is on your own risk.
It works for me quite good (helped me debricking 2 Routers)

It's called "breadboard", I believe Gunni.

Thanks for your tip gunni. How do we recognize the caps' cathode from the anode on your draw ?

Maybe someone knows a layouter program (freeware or opensource) that is easy to handle so i can easy post a better layout (the one i posted was made with the gimp, in a fast and lazy way ... wink )

You can use Dia for example, or kivio, there are quite similar. But can you tell me how should I put my caps ? which is positive pin or the negative one ?

RItalMan, gunni's layout is based on the schematics in the first post in this thread, and the connections should be:

(casode) ---||+-- (anode) 


it is very interesting idea about implementing RS232 port into linksys router.

I would like to develop intersting device based on WRT54G witch will transmit rs232 signals over ethernet(internet) . The brief drawing looks like this

                  ---------------------                                                 -------------------------
           RX   {                        }                                               {      LINKSYS            }   TX
: RS232       {  LINKSYS         } ethernet ---------------- ethernet {        WRT54G         } RS232 :
           TX   {    WRT54G        }                                                {                              }   RX
                   --------------------                                                  -------------------------

and later on

                  ---------------------                                                  -------------------------
           RX   {                        }                                                {      LINKSYS            }   TX
: RS232       {  LINKSYS         } ethernet ---INTERNET-- ethernet {        WRT54G         } RS232 :
           TX   {    WRT54G        }                                                {                              }   RX
                   --------------------                                                   -------------------------
The configuration stated above will simulate this device:

ESB-1 or ESB-2 Etherseries Asynchronous Ethernet Bridge … Bridge.htm

What kind of software we need to build it ?
Whoever interested please let me know, I will really appreciate that.



Just bare in mind there is no hardware handshake with the WRT54 serial mods.

The discussion might have continued from here.