What do you need?
- A wireless router like D-Link DIR-320, which has at least one USB port, with Oleg's firmware inside.
- An USB printer. In my case I have HP LaserJet 1018, change it to your printer model.
- An USB hub if you want to connect more device (USB flask stick, scanner, etc) to the router.
Fig. 1. HP LaserJet 1018 connected to wireless router D-Link DIR-320 through an 4-port USB hub
Why is Oleg's firmware?
Because original
router firmware doesn't work with host-based printer like HP Laserjet 1018, thus it's needed to load some
printer firmware to this kind of printer to make it operates properly. And beside that, you don't have much things to do with the manufactor's firmware. Oleg's firmware gives you more freedom of operations. If you have a D-Link DIR-320, you can see how to reflashing your router
in my other post. The owner of other router can check
Oleg's firmware website and
forum.
1. Server settings
The main idea here is putting printer firmware in some place, where the router can find and load it to printer when the last one is connected. You need to download/create some files as below:
1.1. sihp1018.dl
This is the printer firmware. We need to load this file to printer. After login to the router by ssh, you can get this firmware from Oleg's firmware website as below:
$ wget http://oleg.wl500g.info/hplj/sihp1018.dl -O /tmp/sihp1018.dl
All the files in /tmp will be deleted every time the router rebooted. Remember to download printer firmware again if you don't have external storage media. In case you have an USB hub and an USB flash stick mounted under /opt, you can have second copy of firmware on the USB stick:
$ mount /dev/discs/disc0/part1 /opt
$ cp sihp1018.dl /opt
1.2. /usr/local/sbin/usb_printerid
wget http://oleg.wl500g.info/hplj/usb_printerid -O /usr/local/sbin/usb_printerid
1.3. /usr/local/sbin/hotplug.sh
This file is a hotplug script, which will load printer firmware automatically every on/off cycle.
#!/bin/sh
LOG=/tmp/hotplug.log
PRN_BIN=/usr/local/sbin/usb_printerid
PRN_FRM1=/tmp/sihp1018.dl
PRN_FRM2=/opt/sihp1018.dl
# Logging
echo --------------- >> $LOG
date >> $LOG
echo $* >> $LOG
set >> $LOG
if [ "$ACTION" = "add" ] || [ "$1" = "usb" ] || [ "$DEVFS" = "/proc/bus/usb" ]; then
sleep 5
$PRN_BIN /dev/usb/lp0 | grep -q FWVER || cat $PRN_FRM1 > /dev/usb/lp0;
$PRN_BIN /dev/usb/lp0 | grep -q FWVER || cat $PRN_FRM2 > /dev/usb/lp0
echo "Printer OnLine" >> $LOG
else
echo "Printer OffLine" >> $LOG
fi
killall hotplug.sh
1.4 /usr/local/sbin/post-boot
Commands in this file will be executed after router's booting. Here I use it to mount USB flash stick, load firmware to printer if it is on and connected and the firmware is not presented on printer. At last, the hotplug script about is load to kernel's hotplug.
#!/bin/sh
# Mount USB flash disk
if [ -w /dev/discs/disc0/part1 ]; then
mount /dev/discs/disc0/part1 /usr/local/flashdisk
fi
# Load firmware to printer if the printer is connected and
# firmware is not loaded (grep -q FWVER)
if [ -w /dev/usb/lp0 ]; then
/usr/local/sbin/usb_printerid /dev/usb/lp0 | grep -q FWVER || cat /tmp/sihp1018.dl > /dev/usb/lp0;
/usr/local/sbin/usb_printerid /dev/usb/lp0 | grep -q FWVER || cat /opt/sihp1018.dl > /dev/usb/lp0
fi
# Hotplug script
echo "/usr/local/sbin/hotplug.sh" >> /proc/sys/kernel/hotplug
After downloading/creating files, we need to make some of them executable and then save the flashfs:
$ chmod +x /usr/local/sbin/*
$ flashfs save
$ flashfs commit
$ flashfs enable
$ reboot
That's all from server side. Now you can connect printer to router, turn it on and configure the client side, after what — print.
2. Client side
2. 1. Linux client
Ubuntu for example. Install and run cupsd:
$ sudo apt-get install cups
Then add printer through GNOME interface (wizard). Not very hard to do. And don't forget to add users to
lp group!
Fig. 2. Network printer properties
2. 2. Windows(R) client
I won't show you. I hate Windows users ;).
Read here instead:
http://oleg.wl500g.info/printing/
Note:
1. When try:
$ flashfs save && flashfs commit && flashfs enable && reboot
and get
[admin@(none) local]$ flashfs commit
/tmp/flash.tar.gz: File is to big (73504, max 65536)
mean your flash file is not fit on flash ROM. Maybe you download printer firmware to some where in /usr/local. Need to check it:
$ ls -lR /usr/local
lrwxrwxrwx 1 admin root 12 Aug 22 11:35 /usr/local -> ../tmp/local
$ ls -lR /tmp/local
2. If you have connected, for example, 4-port USB hub to the router, then you have more posibilities other than network printing:
- network storage device,
- network camera,
- network scanning, etc.
3. Do not use 3-m USB-cable and over, can cause problem with USB 2.0.