Sunday, November 13, 2011

Make host based USB printer work with OpenWrt’s P910nd print server

A host-based printer like HP-LaserJet 1020 needs to download a firmware every time when boot up or else it won’t print.  These printers works fine when connect to Windows that has drivers install.  For Linux, foo2zjs may help upload the firmware to printer by USB hotplug daemon.

It is very hard to make host-based printers work with networked print server appliance as the printer won’t work without firmware.  Most print server appliance don’t have firmware ready or it won’t upload the firmware to printer.

Some print server like D-Link DPR 1061 claims to work with host based printer but it is a different story.  A software (PS-Link or PS-Wizard) is required to deploy on workstations in network to act as USB redirector to send firmware to printer.  This isn’t a favor solution as it increase deployment effort on workstation.

This topic use TP-Link 1043ND wireless router as hardware device to act as printer server alternative to those branded printer server in market.  The TP-Link 1043ND is patched with Gargoyle WRT (backed by OpenWrt).  A small printer daemon p910nd is installed in the device to serve as printer server for network.

Here are some brief steps to install and configure:

  1. Find a low cost router that has few RJ45 network sockets (usually 4 LAN port + 1 WAN port) and USB port
  2. Patch the device with OpenWrt or Gargoyle Wrt
  3. Install p910nd daemon
  4. Download Printer Firmware
  5. Configure USB hotplug daemon to send firmware to printer
  6. Add a printer device in Windows / Linux workstation that print to Standard TCP/IP port (e.g.: Port 9100)

Print Server Device: TP-Link 1043ND

In this article, A gigabit wireless router: TP-Link 1043ND is used as example.  The router has 4 LAN + 1 WAN ports and a USB port mainly for flash drive.  We will make the USB port work with USB host based printer.

Printer: HP Laser Jet 1020

HP laser jet 1020 is a USB host based printer that is not friendly to many network print server in the market.

Patch with Gargoyle WRT

Download suitable flash firmware for TP-Link 1043ND from Gargoyle.  Follow instruction to patch the device.  After finish patching, do some simple configuration:

  1. Set the root access password
  2. Set IP address for the device (e.g.: 192.168.1.1)
  3. Enable SSH access to the device (e.g.: port 22)
  4. Try using SSH console like Putty to access the device

Install software on device

  1. SSH into device. e.g.: ssh 192.168.1.1
  2. Enter “root” as username and supply with password
  3. Update OpenWRT software packages:
    root@Gargoyle:~# opkg update
  4. Install Kernel modules for USB Printer support:
    root@Gargoyle:~# opkg install kmod-usb-printer
  5. Install printer server:
    root@Gargoyle:~# opkg install p910nd

Configure Printer Server: P910nd

  1. Enable p910nd daemon that sustain for device fresh booting:

    root@Gargoyle:~# /etc/init.d/p910nd enable
  2. Start p910nd daemon for current session
    root@Gargoyle:~# /etc/init.d/p910nd start

Printer Firmware

  1. Download a suitable printer firmware (e.g.: http://oleg.wl500g.info/hplj/)
    root@Gargoyle:~# wget -o /usr/lib/sihp1020.dl http://oleg.wl500g.info/hpl
    j/sihp1020.dl
    root@Gargoyle
    :~# ls -al1 /usr/lib/si* -rw-r--r-- 1 126151 Nov 12 16:31 /usr/lib/sihp1020.dl
  2. Create a USB hotplug script file (/etc/hotplug.d/20-hpjl1020) for printer HP1020:
    root@Gargoyle:~# cat /etc/hotplug.d/usb/20-hplj1020
    #!/bin/sh
    
    FIRMWARE="/usr/lib/sihp1020.dl"
    DEVICE=/dev/lp0
    LOGFILE=/var/log/hp
    
    if [ "$PRODUCT" = "3f0/2b17/100" -a "$ACTION" = "add" ]
    then
            for i in $(seq 30); do
                    if [ -c $DEVICE ]; then
                            echo "$(date) : Sending firmware to printer." > $LOGFILE
                            cat $FIRMWARE > $DEVICE
                            echo "$(date) : done." >> $LOGFILE
                            exit
                    fi
                    sleep 1
            done
    fi
  3. You may adjust parameters in the script file to suit you environment.
  4. Product ID: “3f0/2b17/100” is the printer ID for my HP Laser Jet 1020.  Change it to suitable ID for the printer you attempt to connect.  You may attempt to grep the printer ID by patching the script file to output printer id to a log file.

Test Printer Firmware

  1. Plug printer USB cable to device and check log file:
    root@Gargoyle:~# cat /var/log/hp
  2. The log file consist some information that is useful for troubleshooting
  3. Power off both printer and device
  4. Power on both printer and device
  5. Check log file again to make sure firmware may send to printer properly

Print from Windows

  1. Logon to Windows workstation and add a local printer:
    1
  2. Create a new Standard TCP/IP port for the printer:
    2
  3. Enter IP Address for the printer: e.g.: 192.168.1.1
    3
  4. Specify additional information for the connection:
    4
  5. Choose “Raw” protocol and set port number. e.g.: 9100
    5
  6. Pick a suitable printer driver:
    6
  7. You may try to print a test page to the printer.

Reference

  1. p910nd Printer Server. URL: http://wiki.openwrt.org/doc/howto/p910nd.server

5 comments:

Anonymous said...

Hi! what to do with that type of problem

root@Gargoyle:~$ wget -o /usr/lib/sihp1020.dl http://oleg.w1500g.info/hplj/sihp1
020.dl
wget: invalid option -- o
BusyBox v1.15.3 (2011-06-27 18:48:16 CEST) multi-call binary

Usage: wget [-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document file]
[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
[-U|--user-agent agent] url

Retrieve files via HTTP or FTP

Options:
-s Spider mode - only check file existence
-c Continue retrieval of aborted transfer
-q Quiet
-P Set directory prefix to DIR
-O Save to filename ('-' for stdout)
-U Adjust 'User-Agent' field
-Y Use proxy ('on' or 'off')

root@Gargoyle:~$ ls all/usr/lib/si
ls: all/usr/lib/si: No such file or directory

polszn80 said...

use --o

Robert

polszn80 said...

Use insted --o


Robert

Craigs Webs said...

Hi

The link/command to the firmware you provide is not longer available. Do you know of an alternative?

Craigs Webs said...

sorry about my last comment - i had an error in the url :)