How to use the serial ports on a Linksys WRT54GS with DD-WRT v24
This is Andrew’s Guide to DD-WRT network serial ports.
Part 1 – TCP connections
A Linksys WRT54G / WRT54GS router makes a great wireless network serial port. In the following guide I will go over the techniques I use to allow TCP or UDP connections. This tutorial covers how to do this with the DD-WRT firmware. The WRT54GS has two serial ports. The first one is connected as a serial console at startup. The second one can be used easily for connecting GPS units, microcontrollers, weather stations or any other serial device.
DD-WRT Homepage
http://www.dd-wrt.com/site/index
Rod Whitby has an article that explains how to solder the required header pins onto your WRT54GS router.
http://www.rwhitby.net/projects/wrt54gs
Using the pinout from Ron Whitby’s site you can either hook up a 3.3 Volt serial device directly to your WRT54GS router or, with additional work, you could make / get a voltage converter board to allow true rs-232 serial voltage levels to be converted to 3.3 Volt TTL levels. This type of converter board device would use a Maxim-IC MAX3233E chip. A 10 pin IDC connector ribbon cable can run from your voltage converter board to your header pins soldered onto the WRT54GS. The converter board can draw its power off the router terminal pins through the ICD connector.
Note: Crimping standard servo terminal type connectors onto your serial device’s cable will make wiring up the serial port connections to the Linksys WRT54GS easy during prototyping. This type of connection is shown in the two pictures below:
Requirements:
3.3 Volt Locosys GPS
Linksys WRT54G / WRT54GS router
DD-WRT firmware (v24 suggested)
0.1” 10 pin header
SSH Client Software:
Putty or Terminal
I have packaged up the utilities you require for this project into two ZIPs:
http://www.andrewhazelden.com/files/2010/January/dd-wrt_serial_TCP.zip
http://www.andrewhazelden.com/files/2010/January/dd-wrt_serial_UDP.zip
The first archive will allow you to set up a network TCP/IP connection on your DD-WRT router using the /dev/tts/1 serial port. The archive dd-wrt_serial_TCP.zip has the following programs:
libncurses_5.6-1_mipsel.ipk
netcat_0.7.1-1_mipsel.ipk
ser2net_2.3-1_mipsel.ipk
The second archive will allow you to set up a network UDP connection on your DD-WRT router using the /dev/tts/1 serial port. The archive dd-wrt_serial_UDP.zip has the following programs:
busybox-stty-setconsole.zip
gps2udp.sh
setserial_2.17-1_mipsel.ipk
———————————————————————————————————————————
Step 1.
Follow Ron Whitby’s instructions and solder the 10 pin header onto your router.
http://www.rwhitby.net/projects/wrt54gs
Step 2.
Install the dd-wrt v24 firmware on your WRT54G / WRT54GS Linksys router.
Step 3.
Set up your network and wireless settings. I recommend setting the router up with a fixed IP address. I use 192.168.1.80 for the wireless router. You will have to decide if you will use either client bridged or client routed modes for the Linksys router or you might even make it an access point.
Step 4.
Enable JFFS2 Support on your router.
You must compete this step if you want the process to work!
To do this go to the Administration > management section in the dd-wrt user inteface.
Scroll down to the JFFS2 Support section. Enable the JFFS2 and Clean JFFS2 options.
Click Apply.
Now reboot the router.
This will allocate storage in the flash memory where you will save the programs on your router. I find you have to reboot your router once after enabling JFFS2 Support for it to work properly.
Step 5.
SSH into the router. ( You could also use telnet.)
On Windows I recommend the PUTTY program as an SSH Client:
http://www.chiark.greenend.org.uk/~sgtatham/putty/
On Mac OS X I recommend using the Terminal application found in your
/Applications/Utilities folder.
Assuming your router’s IP address is 192.168.1.80 and your dd-wrt username is root, use the following command:
ssh -l root 192.168.1.80
The default password is admin
Last login: Sun Jan 17 15:40:52 on ttys000 Mac-Pro:~ DSI$ ssh -l root 192.168.1.80 DD-WRT v24 std (c) 2008 NewMedia-NET GmbH Release: 04/24/08 (SVN revision: 9433) root@192.168.1.80's password: ========================================================== ____ ___ __ ______ _____ ____ _ _ | _ \| _ \ \ \ / / _ \_ _| __ _|___ \| || | || | || ||____\ \ /\ / /| |_) || | \ \ / / __) | || |_ ||_| ||_||_____\ V V / | _ | | \ V / / __/|__ _| |___/|___/ \_/\_/ |_| \_\|_| \_/ |_____| |_| DD-WRT v24 http://www.dd-wrt.com ========================================================== BusyBox v1.9.2 (2008-04-24 06:02:12 CEST) built-in shell (ash) Enter 'help' for a list of built-in commands. root@dd-wrt:~#
Step 6.
Download the files to your dd-wrt.
The technique I use is to download the files using the wget command on the dd-wrt router.
On Mac OS X you can enable web sharing in your System Preferences Control Panel.
Click on the Sharing Option.
In the Sharing section enable Web Sharing.
This enables the Apache based HTTP web server built into your Mac. You can place files either in the computer’s sharing folder or in your user account’s sharing folder.
If you type your computer’s IP address in your favorite web browser you will see a directory listing. For example, my computer’s local IP address is 192.168.1.8 so I would type the following in the address bar:
http://192.168.1.8
The local path to your computer’s web-sharing folder is:
/Library/WebServer/Documents/
Step 7.
Installing TCP serial software
The local IP address of my desktop computer is 192.168.1.8 . You should substitute your IP address where you see 192.168.1.8 in the following examples.
Type the following into your ssh session window:
cd /jffs/tmp
If there is no /jffs/tmp directory that would likely indicate the you need to enable JFFS2 support. See Step 4.
To download the software to the dd-wrt:
wget http://192.168.1.8/libncurses_5.6-1_mipsel.ipk
wget http://192.168.1.8/netcat_0.7.1-1_mipsel.ipk
wget http://192.168.1.8/ser2net_2.3-1_mipsel.ipk
To install the software packages using the IPKG installer:
ipkg install libncurses_5.6-1_mipsel.ipk
ipkg install ser2net_2.3-1_mipsel.ipk
ipkg install netcat_0.7.1-1_mipsel.ipk
Step 8.
Connect your serial device to the dd-wrt. This example expects that your serial device is connected to TTS/1. I am using a Lococsys 10 Hz GPS connected at 38,400 baud. I set up the serial device to output data on TCP port 3001 but any other port number could be used. The ser2net program only allows a single TCP connection to the serial port at a time.
In the SSH session window type in:
ser2net -C “3001:raw:600:/dev/tts/1:38400 NONE 1STOPBIT 8DATABITS -XONXOFF -LOCAL -RTSCTS”
To check if the program is installed properly and running, type in:
top
This shows the currently running programs on the dd-wrt router. In the right hand column labeled COMMAND you should see ser2net listed part way down. Press Control-C to quit top.
Step 9.
Set up the startup script.
To make the serial software ser2net start at boot time we will make it a startup script. Connect to the Linksys router. In my case, I will connect to http://192.168.1.80/Diagnostics.asp
This will load up the Administration / Commands section in the dd-wrt software.
Paste the following text into the Command Shell section of the web-gui of the dd-wrt router firmware control panel:
ser2net -C “3001:raw:600:/dev/tts/1:38400 NONE 1STOPBIT 8DATABITS -XONXOFF -LOCAL -RTSCTS”
Click the Save Startup button.
Reboot the router.
Step 10.
Let’s now test if everything is working!
Open a new terminal window.
On Mac OS X and Linux there is a handy Unix tool called Netcat. Netcat is also known as “nc” for short. It allows you to easily test UDP and TCP network connections. If you search on Google there are also pre-compiled versions of Netcat for windows.
Type the following into your terminal window:
nc 192.168.1.80 3001
This tells Netcat to connect to the Linksys router on port 3001 using the TCP protocol.
If your serial device is properly connected you should see data scrolling by in the terminal window.
Step 11.
Conclusions
You can now access the serial port on a dd-wrt either through the Ethernet port on the router or wirelessly using WIFI.
On Mac OS X it is possible to use BSD Sockets to connect and transfer data between desktop software and the remote network serial port.
On Windows you can either use a TCP socket and connect directly or you can use virtual serial port software that will make the network TCP data look like it is coming in on a Windows COM port.
A free program for Windows that maps the TCP serial data to a virtual serial port is:
HW VSP3 – Virtual Serial Port
http://www.hw-group.com/products/hw_vsp/index_en.html
Some people like to use Python scripting for its easy network socket programming.
http://www.python.org/
Another way to access the network TCP serial data is to use the Simple Directmedia Layer “SDL” with the SDL_net cross-platform networking library. This works equally well on Mac / Windows / Linux platforms.










February 16th, 2010 at 5:27 am
I like to made an fast same project(from your tutorial)… dd-wrt to fonera 2100 like use as wi232 – wibox (serial on wlan)…
I made steps what are in tutoral but (after tftp files) when i like to “ipkg install libncurses_5.6-1_mipsel.ipk ” get an error message… can’t continue…
Please help!