Bug 75157

Summary: Cannot print to /dev/lpt0 with HP Laserjet 1005 : Device Busy
Product: Base System Reporter: Hernán Di Pietro <hernandp>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Hernán Di Pietro 2004-12-16 16:40:17 UTC
Cannot print files to /dev/lpt0 with a Parallel HP Laserjet 1005 after
successfully uploading the HP Laserjet 1005 firmware.

Note that you can't upload anything with interrupt-driven port. If lpt
is set to polled mode with lptcontrol, it's possible to upload the 
firmware to the printer.

Seems that's a timing problem, because the firmware can be successfully
uploaded through the parallel port ONLY when the printer is powering up.
If you leave the printer ON for some seconds after powerup tasks,
sending the firmware with cat will output a Device Busy message.

Fix: 

The HP Laserjet 1005 firmware can be successfully uploaded to the printer if you set lpt to polling mode (device.hints at loader.conf w/ACPI disabled to avoid ACPI to reset the port to interrupt-driven). After bootup, turn off the printer. Type the command to upload the printer firmware, but do not press ENTER. Just execute the cat hp1005fw>/dev/lpt0 when the printer is doing the powerup tests. THe firmware will be successfully loaded.

After that, it won't respond to printing requests (Device busy error).
How-To-Repeat: * In interrupt-driven port, just try to send anything to the port, it won't respond.

* Set the port with lptcontrol at boot time to polled mode (-p). Turn off the printer. When the printer is powering up, send the HP 1005 firmware with 

cat Hp1005fw > /dev/lpt0

the firmware is uploaded correctly (you can check this because when you bootup the system the next time it will identify the printer with a string like):

ppc0: HP Laserjet 1005...... 200302xx

When the firmware is not loaded, it will just report the printer name, not any feature or manufacturing date.

Note that in Linux, this firmware uploading is required, and it can be done like in FreeBSD, altough it's possible to send any job to the printer. In FreeBSD, even with the firmware loaded, the printer does not respond.
Comment 1 tedm 2009-06-13 22:13:27 UTC
This problem also exists on my Emachines Celeron 600 running
FreeBSD 6.4 using the escputil program with an Epson printer.
I have the parallel port set to NIBBLE mode that may be part
of the problem.  However, the Epson has to use NIBBLE mode to
talk to the computer.  Here's a snippet of the dmesg:

ppc0: <ECP parallel printer port> port 0x378-0x37f,0x778-0x77f irq 7 drq 
3 flags 0x1 on acpi0
ppc0: Generic chipset (NIBBLE-only) in NIBBLE mode
ppbus0: <Parallel port bus> on ppc0
ppbus0: IEEE1284 device found /NIBBLE
Probing for PnP devices on ppbus0:
ppbus0: <EPSON Stylus C84> PRINTER ESCPL2,BDC,D4
plip0: <PLIP network interface> on ppbus0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
ppi0: <Parallel I/O> on ppbus0

cat /boot/loader.conf
hint.ppc.0.flags="0x1"
nat-rtr#

To demonstrate the problem

cd /usr/ports/print/gimp-gutenprint
make install
cd work/gutenprint-5.1.7/src/escputil
make install

./escputil -i -u -r /dev/lpt0
Escputil version 5.1.7, Copyright (C) 2000-2006 Robert Krawitz
Escputil comes with ABSOLUTELY NO WARRANTY; for details type 'escputil -l'
This is free software, and you are welcome to redistribute it
under certain conditions; type 'escputil -l' for details.

Cannot open /dev/lpt0 read/write: Device busy

lptcontrol -p -d /dev/lpt0.ctl
./escputil -i -u -r /dev/lpt0
Escputil version 5.1.7, Copyright (C) 2000-2006 Robert Krawitz
Escputil comes with ABSOLUTELY NO WARRANTY; for details type 'escputil -l'
This is free software, and you are welcome to redistribute it
under certain conditions; type 'escputil -l' for details.

          Ink color       Percent remaining
              Black                      17
               Cyan                      29
            Magenta                      26
             Yellow                      31

Setting lpt0 back to interrupt driven mode then makes the
escputil program get the device busy error message again
Comment 2 tedm 2009-06-14 09:07:10 UTC
One more note - /usr/sbin/lpd works perfectly with the port set
to interrupt mode.  It is only the escputil program that gets
the Device Busy error message if the port is in interrupt mode.
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:11 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped