DDWRT print server

If you're reading this page, I assume you're in the process of configuring a "fresh" ddwrt install to act as a print server. I had a lot of trouble trying to do this.

Part of this is because the information available is referring to different (old) versions or the default settings of the packages are not correct (anymore).If you have the possibility to add more than 1 usb device (by using a hub for example) you should really attach a flash disk or external hard disk and go for Optware (http://www.dd-wrt.com/wiki/index.php/Optware%2C_the_Right_Way). It has much more up-to-date packages. In my case, everything had to fit on the router itself, so I decided to make a write-up of how I got my printserver running. It could save you some valuable hours.

Prerequisites

I'm using a Netgear WNR3500L running DD-WRT v24-preSP2 rev 14311. This firmware uses kernel 2.6.24.111 with usb support (obviously). In what follows, I assume your router is already properly setup though the web gui for internet access and whatnot.

JFFS

First of all, you need to enable JFFS in the web gui. This will allow the downloading and installation of addon packages through ipkg. Go to the Adminstration tab and scroll down.

The available free size will depend on the firmware image you installed and the amount of flash memory in your router. At first I used a "mega" or "big" flash image, which only left about 700KB of free JFFS space. This was not enough so I had to use a "normal" image. Also, remember that a lot of settings need a reboot of the router to have full effect. I can't stress this enough.

USB printer support

Next, enable USB support, under the Services tab

I enabled everything except Storage as my router's single USB port will be occupied by my HP Laserjet P2015D printer.

SSH or telnet access

In the next steps, some commans will be issued on the router. You can login to your router by using ssh (recommended) or telnet, both of which can be enabled in the Services/services tab. More information on this can be found in the dd-wrt wiki (http://www.dd-wrt.com/wiki/index.php/Ssh).

Install packages

Check JFFS

At this point your router should be rebooted, and then you can login. Check if the JFFS filesystem is mounted by typing "mount":

> mount
...
/dev/mtdblock/4 on /jffs type jffs2 (rw)

The output should contain a line referring to /jffs (typically at the bottom). You can check the free space on the jffs "disk" by typing "df -h":

> df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.5M      3.5M         0 100% /
/dev/mtdblock/4           2.6M    508.0K      2.1M  19% /jffs

You should see something similar as the above output. Let's move on to installing the printer drivers

Ipkg printer package installation

Ipkg is a minimalist package manager for ddwrt and similar systems. Update its package list by issuing "ipkg update". You will of course need an active internet connection.

> ipkg update
......
Updated list of available packages in /jffs/usr/lib/ipkg/lists/backports

Ipkg needs /jffs to be present, otherwise an error will be printed. Now we can install the printer modules with "ipkg -force-depends install kmod-usb-printer":

> ipkg -force-depends install kmod-usb-printer
......
Unpacking kmod-usb-printer...Done.
Configuring kmod-usb-printer...Done.

Now reboot your router by entering "reboot". When it's up again, log in via ssh or telnet again and plug in your usb printer. Now you can check if your printer is recognized.Issue dmesg|grep "usb". You should see something very similar to this:

> dmesg|grep "usb"
......
usb 2-1: new high speed USB device using ehci_hcd and address 2
usb 2-1: configuration #1 chosen from 1 choice
usblp0: USB Bidirectional printer dev 2 if 0 alt 0 proto 2 vid 0x03F0 pid 0x3817
usbcore: registered new interface driver usblp

What matters is that there is mention of the new interface driver usblp (last line) and the device usblp0 (line before that). If you don't see these lines, try replugging your printer or rebooting your router again. If all this doesn't help, you'll probably need to install some extra drivers or your printer is not compatible with linux. Generally, if you prnter works with cups in Linux, it should work.

Ipkg printer server package installation

Enter "ipkg -force-depends install" to install a simple print server:

> ipkg -force-depends install p910nd

The two configuration files that now matter are:

  • /jffs/etc/default/p910nd
  • /jffs/etc/init.d/p910nd

At least one of them most likely *will* need to be changed. The file /jffs/etc/default/p910nd probably does not need changing and looks like this:

# printing port list, in the form "number [options]"
# where:
#  - number is the port number in the range [0-9]
#    the p910nd daemon will listen on tcp port 9100+number
#  - options can be :
#    -b to turn on bidirectional copying.
#    -f to specify a different printer device.
#
0  -b -f /dev/usb/lp0

The last line shows that /dev/usb/lp0 will be used as the printer device, and the -b flag enables duplex printing. I read it can cause trouble, but having a duplex printer it works for me.

Important: For 2.4 kernels, the printer device usually is /dev/lp0, while for kernel 2.6, it is /dev/usb/lp0. Some dd-wrt versions use 2.4 kernels while others use 2.6. You should check this if things do not work right away!

The file /jffs/etc/init.d/p910nd in its default trim refers to /etc/default/p910nd. Change it to the right locations:

#!/bin/sh
DEFAULT=/jffs/etc/default/p910nd
RUN_D=/jffs/var/run
...

Now you can start the print server software by typing "/jffs/etc/init.d/S70p910nd start". Check if it is listening on port 9100 with:

> netstat
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
...
tcp        0      0 0.0.0.0:9100            0.0.0.0:*               LISTEN     

If you see the last line, the print server is running. Try adding your printer in your favorite OS: http://www.dd-wrt.com/wiki/index.php/Printer_Sharing#Workstation_setup and print a testpage.

Problems and troubleshooting

Printer online, no pages come out

If you can print on your workstation but the printer does not start, you should check the printer device on your router. On my router with kernel 2.6 it is called /dev/usb/lp0. When issuing dmesg|grep "usb" the device lp0 was mentioned, but it did not exist in the folder /dev/usb/. This is mentioned here (http://www.dd-wrt.com/wiki/index.php/Printer_Sharing#Notes_for_K26) I had to manually create it with mknod -m 660 /dev/usb/lp0 c 180 0. It will disappear every reboot, so I added this line in /jffs/etc/init.d/p910nd. This will make sure the device exists when the router starts up.

Starting everything on boot

Go to your router's webadministration page and navigate to "Administration>Commands". In the textbox, I entered two lines:

/jffs/etc/init.d/p910nd start;

mknod -m 660 /dev/usb/lp0 c 180 0;

Press "startup" to save it so it is run during the router startup sequence:

Now you're done and your server is fully ready to act as a printserver!