# HP 1018 / foo2zjs



## mdl90 (Feb 13, 2017)

Having given up on a solution to installing a Samsung 1660 printer with foo2zjs on FreeBSD 10.3, I moved to an HP 1018 type printer:

When I try to build foo2zjsfor this printer, using `gmake`, the script stops with an error: gs not found.

Is anyone able to tell me how to point the installer at the location of gs on FreeBSD, or otherwise report on successful installation of this printer on FreeBSD with CUPS?

(I tried posting in foo2zjs forums, but did not receive a response.)


----------



## ASX (Feb 13, 2017)

gs is for ghostscript, and is installed from package ghostscript9-agpl-base-9.16_5

foo2zjs is available in FreeBSD repository ... no need to build it yourself.


----------



## mdl90 (Feb 13, 2017)

gs (yes, ghostscript) is installed. I think I must have gone to build as I couldn't get hp printer to function correctly using pkg from FreeBSD repository: when I set up printer with cups and then go to cups admin interface, select print test page, I get the error: Unsupported format "text/plain". What am I missing here?

CUPS error log:


```
E [13/Feb/2017:20:24:41 +0000] [Client 119] Returning IPP client-error-document-format-not-supported for Print-Job (ipp://localhost:631/printers/HP_LaserJet_1018) from localhost
```


----------



## shepper (Feb 13, 2017)

Two factors with foo2zjs printers is that a firmware file has to be downloaded and loaded into the printer.  I do not see the 1018 firmware listed in the pkg-plist for foo2zjs and it may have a "non-free"distribution status that requires you to directly download the firmware.

Linux uses a udev rule to correctly load the firmware - not sure how to load the firmware in FreeBSD but I'll web search after I post this.

I (shep) put some links into this recent debian forums post regarding the same printer.    Another option, which is more bloated, is to use print/hplip.

Edit:  here is an older FreeBSD search hit for a similiar printer and an circa 9.1 forum Thread 38048


----------



## mdl90 (Feb 14, 2017)

http://hplipopensource.com/node/309

hp-setup ... looks like.

However ... there are problems

running hp-plugin also fails:


```
eval: ./hplip-plugin-install: not found
error: Python gobject/dbus may be not installed
error: Plug-in install failed.
```

Following may be relevant:

https://lists.freebsd.org/pipermail/freebsd-ports/2015-June/099421.html


----------



## mdl90 (Feb 14, 2017)

https://david.dw-perspective.org.uk...sources/HP-Laserjet-1018-Linux-Fedora-Ubuntu/

Case for make fooz2js from tarball?

Or, perhaps the hp installer is looking for python 2.7:

http://go2linux.garron.me/linux/2010/11/hplip-syntax-error-invalid-syntax-816/


----------



## shepper (Feb 14, 2017)

Bias alert:  I try to avoid bloated software, which may have unmet dependencies, in order to simply print.

With that said, I would start from scratch by removing hplip cups and foo2zjf and deleting any cups configuration files.  Then install cups and foo2zjs and follow the instructions in the link I provided for downloading and installing the printer firmware, enabling ulpt, setting user permissions for ulpt and the devfs rule to install the firmware via ulpt. I would search the forums for devfs rules as there is an indication that the rule syntax has changed.


----------



## mdl90 (Mar 3, 2017)

Despite the explanations, I am still stumped. I think I've done as you suggest. As far as I know permissions are set correctly (and ultp is enabled by default).

dmesg


```
ugen6.2: <Hewlett-Packard> at usbus6
ulpt0: <Hewlett-Packard HP LaserJet 1018, class 0/0, rev 2.00/1.00, addr 2> on usbus6
ulpt0: using bi-directional mode
```


```
ls -l /dev/ugen6.2
lrwxr-xr-x  1 root  wheel  9  3 Mar 17:52 /dev/ugen6.2 -> usb/6.2.0
```

CUPS error log shows:


```
W [03/Mar/2017:18:22:29 +0000] [Job 4] The printer is in use.
W [03/Mar/2017:18:22:33 +0000] [CGI] Missing NickName and ModelName in /usr/local/share/cups/model/foomatic-db-ppds/BrotherE [03/Mar/2017:18:22:33 +0000] [cups-driverd] Bad driver information file \"/usr/local/share/cups/model/foomatic-db-ppds/Kyocera/ReadMe.htm\"!
...(and some more like that)...
W [03/Mar/2017:18:22:39 +0000] [Job 4] The printer is in use.
W [03/Mar/2017:18:23:11 +0000] [Job 5] The printer is in use.
W [03/Mar/2017:18:23:16 +0000] [Job 5] The printer is in use.
E [03/Mar/2017:18:23:26 +0000] [Job 5] The printer is not responding.
```

hmm...Maybe time to abandon the effort and find another printer.


----------



## shepper (Mar 3, 2017)

There is a FreeBSD port for foo2zjs and the changelog shows it was updated about 7 weeks ago.  One point of confusion is suggested by your use of "gmake" in the 1st post and building foo2zjs from a "tarball".  I would stick to foo2zjs that is provided by FreeBSD packages or ports.

If you compiled it yourself using the upstream source code it is likely that the ppds were installed in the wrong directory.  If possible, I would try to uninstall the source build.  Then build print/foo2zjs or install the package.  Download and install the firmware and double check /etc/devd.conf.  Reboot and check to see that the firmware gets loaded (should be in the dmesg).  Then use the cups web interface "http://localhost:631".  The web interface should allow you to select /dev/ulpt and the hp1018.ppd.


----------



## mdl90 (Mar 10, 2017)

I made a clean package install of foo2zjs
Instead of issuing `./getweb 1018`
I downloaded the firmware:
http://prdownloads.sourceforge.net/hplip/hplip-3.16.11.tar.gz
I found my way to the following install instructions:
http://hplipopensource.com/hplip-web/install/manual/distros/freebsd.html
Step 4 `./configure` results in:

```
checking for dlopen in -ldl... no
configure: error: "cannot find libdl support"
```
Apparently this is about dynamic linked libraries and libc ...
https://forums.freebsd.org/threads/5799/
I have Makefile.in and Makefile.am but am not sure what/whether to edit


----------



## shepper (Mar 10, 2017)

You did not download just the firmware, but the entire hplip source code.  This encompasses many of HP printer/scanner models and includes python based configuration gui's.  The firmware is buried in the print/hplip-plugin seen here.

Myself and @ASX have both advised you to use the FreeBSD package and yet you continue to try and build outside of the FreeBSD ports system.  You are making this incredibly hard on yourself.


----------



## mdl90 (Mar 11, 2017)

Ok. So I haven't understood.

Where you say, "follow the instructions in the link I provided for downloading and installing the printer firmware" I now understand the link you are referring to is http://www.freshports.org/print/hplip

When you say, "Another option, which is more bloated, is to use print/hplip." I now understand you were saying, either use foo2zjs with the firmware, or use foo2zjs with the full print/hplip package (which contains the firmware)?

What I didn't make clear in my OP is that I started out with foo2zjs and hplip installed from packages and the printer apparently not responding. Now, with both installed from packages:

dmesg on reboot (firmware loaded?):


```
ulpt0: <Hewlett-Packard HP LaserJet 1018, class 0/0, rev 2.00/1.00, addr 2> on usbus2
```
When I go to the CUPS interface, I am offered only usb option.

I install the available printer with .ppd:

/usr/local/etc/cups/ppd/HP_LaserJet_1018_USB_KP1DMLC_HPLIP.ppd

The printer in CUPs appears as:


```
HP LaserJet 1018 Foomatic/foo2zjs-z1 (recommended) (grayscale)
Connection: hp:/usb/HP_LaserJet_1018?serial=KP1DMLC
```
..and the printer apparently is not responding

FWIW:

```
less /etc/devfs.rules
[system=10]
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups
add path 'usb/2.2.0' mode 0660 group cups
```


----------



## shepper (Mar 11, 2017)

There are 2 usb options as described in section 9.2 in the handbook.  Were both options presented in the cups web interface?  There is a freebsd CUPS GUIDE that also mentions that your user needs to be a member of the cups group.  There is also a pkg-message.in with instructions for print/foo2zjs.  It indicates that /usr/local/l/etc/devd/foo2zjs.conf needs to be looked at to ensure firmware loading.  I would also look at the /var/log/cups/error_log.  Finally, the freebsd cups guide also has a troubleshooting section.


----------



## mdl90 (Mar 12, 2017)

In cups admin GUI "List available printers" shows `printer HP_LaserJet_1018_USB_KP1DMLC_HPLIP`
Via "Add printers" the one connection offered is `hp:/usb/HP_LaserJet_1018?serial=KP1DMLC`
I've run through those resources again, checked that the firmware is loading, and the permissions are correct (adding also user to group cups)
GUI shows "Driver:HP LaserJet 1018 Foomatic/foo2zjs-z1 (recommended) (grayscale)"
For the installed printer, error_log for browser GUI selection "print test page":

```
D [12/Mar/2017:20:38:52 +0000] cupsdSetBusyState: newbusy="Dirty files", busy="Active clients and dirty files"
D [12/Mar/2017:20:39:02 +0000] [Client 52] HTTP_STATE_WAITING Closing for error 32 (Broken pipe)
D [12/Mar/2017:20:39:02 +0000] [Client 52] Closing connection.
```
for "print self test page":
	
	



```
[Job 46] PID 3880 (/usr/local/libexec/cups/filter/commandtops) exited with no errors.
D [12/Mar/2017:21:03:06 +0000] [Job 46] STATE: +connecting-to-device
D [12/Mar/2017:21:03:06 +0000] cupsdMarkDirty(---J-)
D [12/Mar/2017:21:03:06 +0000] cupsdSetBusyState: newbusy="Dirty files", busy="Printing jobs and dirty files"
D [12/Mar/2017:21:03:06 +0000] Discarding unused printer-state-changed event...
D [12/Mar/2017:21:03:06 +0000] [Job 46] STATE: -connecting-to-device
D [12/Mar/2017:21:03:06 +0000] cupsdMarkDirty(---J-)
D [12/Mar/2017:21:03:06 +0000] cupsdSetBusyState: newbusy="Printing jobs and dirty files", busy="Dirty files"
D [12/Mar/2017:21:03:06 +0000] Discarding unused printer-state-changed event...
D [12/Mar/2017:21:03:06 +0000] [Job 46] STATE: -media-empty-error,media-jam-error,hplip.plugin-error,cover-open-error,toner-empty-error,other

...

D [12/Mar/2017:20:38:52 +0000] cupsdSetBusyState: newbusy="Dirty files", busy="Active clients and dirty files"
D [12/Mar/2017:20:39:02 +0000] [Client 52] HTTP_STATE_WAITING Closing for error 32 (Broken pipe)
```
for "clean print heads":

```
printer_state_message[0]=\"Invalid printer command \"Clean\".\"
```
Of possible interest, is that connecting this printer to a linux machine via usb shows similar problems (i.e. printer recognized, instructions apparently sent to but not actioned by the printer). Also, this is an old cartridge (media-empty-error?).


----------



## shepper (Mar 12, 2017)

I put "cupsdMarkDirty" and HP 1018 into a web search and got a number of hits for linux systems.  Many suggested turning the printer off/on while the OS was running would allow them to print a test page.


----------



## mdl90 (Mar 13, 2017)

I didn't try that query, but I did try that solution.


----------



## shepper (Mar 13, 2017)

The printer firmware should be reloaded each time the usb recognizes the printer and should show up in your dmesg.  I would cycle the printer off/on and check the last entry in dmesg.  This would ensure that /usr/local/l/etc/devd/foo2zjs.conf is working correctly.  I do not use cups so I have no experience as to the need to specify unlpt vs ulpt - does anyone know if cups does this automatically and correctly?

There are three other options:  1) lpr printing with a foomatic-filter using the hp1018.ppd.  This would allow you to specifically choose unlpt vs ulpt.  2)  print/hplip + print/hplip-plugin 3)  Reach out to the port maintainer.


----------



## Martin Paredes (Mar 25, 2017)

*mdl90*, for the part of the firmware, ensure you downloaded the image in

/usr/local/share/foo2zjs/firmware/sihp1018.img

When you installed print/foo2zjs, it create the file

/usr/local/etc/devd/foo2zjs.conf

Just uncomment the part the HP LaserJet 1018, so each time you connect the printer, the firmware is downloaded to the printer

I had the HP LaserJet 1018 working with the LDP/LPR spooler

The /etc/printcap is:


```
LaserJet1018|lp|HP LaserJet 1018:\
    :banner.disable:tty.device=/dev/ulpt0:\
    :filt.input=/home/martin/if-MAPS:\
    :spool.dir=/var/spool/lpd/LaserJet1018:\
    :spool.log=/var/spool/lpd/LaserJet1018/filter-errors:
```

Create the spool directory

mkdir -p /var/spool/lpd/LaserJet1018
chmod 770 /var/spool/lpd/LaserJet1018
chown -R daemon:daemon /var/spool/lpd/LaserJet1018

The input filter /home/martin/if-MAPS is in my home directory, and the content is


```
#!/bin/sh
GS_DEVICE=pbmraw
GS_FONTPATH=/usr/local/share/ghostscript/fonts:/usr/local/lib/X11/fonts/Type1
GS_LIB=
GS_OPTIONS="-g5100x6600 -r600x600 -q -dBATCH -dSAFER -dNOPAUSE"
export GS_DEVICE GS_FONTPATH GS_LIB GS_OPTIONS
/usr/local/bin/gs -sOutputFile=- | /usr/local/bin/foo2zjs -d1 -g5100x6600 -m1 -p1 -n1 -r600x600 -s -t -T3 -u150x150 -l150x150 -L0 -P -z1
```

This work for paper size letter and all print job been PostScript


----------



## mdl90 (Apr 9, 2017)

I've worked through your instructions, referring to:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing-lpd.html#printing-lpd-filters

Still there is no printing happening. On CUPS restart, its logfile reports HP1018 profile being successfully loaded for the printer. CUPS log now says:

`cupsdSetBusyState: newbusy="Dirty files", busy="Dirty files"`
...
`Discarding unused server-started event`
...
`Discarding unused job-progress event...`
...
`D [09/Apr/2017:17:14:46 +0100] Discarding unused printer-state-changed event...
D [09/Apr/2017:17:14:46 +0100] cupsdMarkDirty(---J-)
D [09/Apr/2017:17:14:46 +0100] cupsdSetBusyState: newbusy="Printing jobs and dirty files", busy="Printing jobs and dirty files"
D [09/Apr/2017:17:14:46 +0100] [Job 91] Removing document files.
D [09/Apr/2017:17:14:46 +0100] cupsdMarkDirty(---J-)
D [09/Apr/2017:17:14:46 +0100] cupsdSetBusyState: newbusy="Dirty files", busy="Printing jobs and dirty files"
D [09/Apr/2017:17:14:47 +0100] [Job 91] Unloading..`
I'm not sure where to look next...any ideas?

(( After I set up the printer as LPR via CUPS with
/usr/local/etc/cups/ppd/HP_LaserJet_1018_USB_KP1DMLC_HPLIP.ppd I noticed service `dbus` was not running, causing CUPS to log `avahi-daemon` communication error on restart (why's that?) ))


----------



## mdl90 (Apr 9, 2017)

http://www.openprinting.org/driver/Postscript


shepper said:


> The printer firmware should be reloaded each time the usb recognizes the printer and should show up in your dmesg.  I would cycle the printer off/on and check the last entry in dmesg.  This would ensure that /usr/local/l/etc/devd/foo2zjs.conf is working correctly.  I do not use cups so I have no experience as to the need to specify unlpt vs ulpt - does anyone know if cups does this automatically and correctly?



There seems to be only one option, which is ulpt


> There are three other options:  1) lpr printing with a foomatic-filter using the hp1018.ppd.  This would allow you to specifically choose unlpt vs ulpt.  2)  print/hplip + print/hplip-plugin 3)  Reach out to the port maintainer.



Thanks for these suggestions. For information, with the plugin from ports and printer installed with the hp cups driver, printing in CUPS gives 'filter failed'


----------



## shepper (Apr 9, 2017)

Some new confusion this time between cups and LPR.  These are 2 different printing systems and you cannot jump between them.  Following Martin Paredes post will result in the simplest, least bloated setup.  It does not use cups at all but the LPR system which is included in the base install.  The handbook link your provided is for the LPR spooler - NOT cups.

Martin's setup just needs print/foo2zjs added.  I am unfamiliar with Matins's printcap syntax but I'm guessing that 
	
	



```
:banner.disable:
```
 does the same thing as 
	
	



```
:sh:
```
 (suppress header).  Given the detail he provided one option would be to copy/paste his example.


----------



## shepper (Apr 9, 2017)

Detailed instructions for using print/foo2zjs, print/cups-filters with the base LPR print spooler were found for the equivalent OpenBSD ports.
In OpenBSD there is also a ulpt firmware port which easily supplies the firmware for the HP 1018.

Instructions for
foo2zjs
and
foomatic-rip with LPR.

These instructions can be implemented on FreeBSD although the /var/spool directories have different names and you need to uncomment the above script for the firmware upload.

In OpenBSD, your printer firmware would install automatically as a ulpt device


> If your printer attaches as ulpt(4) device the firmware will be loaded automatically.


.


----------



## mdl90 (Apr 13, 2017)

shepper said:


> Some new confusion this time between cups and LPR.  These are 2 different printing systems and you cannot jump between them.  Following Martin Paredes post will result in the simplest, least bloated setup.  It does not use cups at all but the LPR system which is included in the base install.  The handbook link your provided is for the LPR spooler - NOT cups.



Yes, the handbook link I provided is for the LPR spooler - not cups. CUPS interface offers set up for printer with LPR/LPD. I tried this after failing to print directly with LPR.


----------



## shepper (Apr 14, 2017)

mdl90 said:


> CUPS interface offers set up for printer with LPR/LPD.



The CUPS interface does not configure FreeBSD's lpr/lpd system.  It is confusing.  Prior to CUPS being developed, BSD's users would print from the command line with lpr(1).  CUPS tried to provide the same command line syntax and unfortunately duplicated the command.  In recent FreeBSD versions, when cups is installed, it disables the lpr command in the base install.


----------



## giorgiob (Sep 6, 2021)

I ran into the same problem and I have edited /usr/local/etc/devd/foo2zjs.conf so that it looks like:


> # HP Laserjet 1018
> attach 100 {
> match "vendor" "0x03f0";
> match "product" "0x4117";
> ...



However, I can find no package providing the firmware sihp1018.img and I do not understand where I can download it. I have read through this thread but I cannot find any indication regarding the location of the firmware.


----------



## Tieks (Sep 6, 2021)

giorgiob said:


> I can find no package providing the firmware sihp1018.img


I suppose both files arm2hpdl and sihp108.img used to come with port/package print/foo2zjs back in 2017. Nowadays cups/foo2zjs work with .ppd files. Did you install the port/package?


----------



## giorgiob (Sep 6, 2021)

Tieks said:


> I suppose both files arm2hpdl and sihp108.img used to come with port/package print/foo2zjs back in 2017. Nowadays cups/foo2zjs work with .ppd files. Did you install the port/package?


I have installed foo2zjs and arm2hpdl is there but sihp1018.img is not installed.
I have set the driver HP-LaserJet_1018.ppd.gz in CUPS and CUPS says that the printer is configured correctly.
I can also print a test page and CUPS says that the job was completed correctly, but the printer does absolutely nothing.

So I thought that I may need to load the firmware to the printer. Does the .ppd contain the firmware already? If so, it seems that it is not loaded automatically by CUPS.


----------



## Tieks (Sep 6, 2021)

giorgiob said:


> I have set the driver HP-LaserJet_1018.ppd.gz in CUPS and CUPS says that the printer is configured correctly.


That is the right way to install a printer in CUPS. You removed the foo2zjs config from /usr/local/etc/devd? Instead, you should have a cups.conf there that makes the printer device available to users in group cups.
Next files to check are the logs in /var/log/cups, they may point to an error too. The web-interface localhost:631, under 'Administration' has an option 'Save debugging information for troubleshooting', you may want to use that.
Last but not least: If the printer status line says it's paused, please choose 'Resume printer' under 'Maintenance' (happened to me more than once).


----------



## bsduck (Sep 6, 2021)

I use a HP LaserJet 1000 so I have a similar setup.

You're supposed to use the `getweb` utility that comes with foo2zjs to download the firmware.

A current problem is that the original upstream website (http://foo2zjs.rkkda.com/) has been down since last year (I don't know why, maybe the original author died) and the version distributed in ports has not been modified yet to match the current website, which is https://foo2zjs.linkevich.net/, so getweb won't be able to download anything.

In the meanwhile you can download your firmware here: https://github.com/koenkooi/foo2zjs/blob/master/sihp1018.img 
Then move it into /usr/local/share/foo2zjs/firmware/


----------



## giorgiob (Sep 7, 2021)

bsduck said:


> I use a HP LaserJet 1000 so I have a similar setup.
> 
> You're supposed to use the `getweb` utility that comes with foo2zjs to download the firmware.
> 
> ...


Thanks, you made my day! I had been on this problem for a few days. My printer is working now.


----------



## astyle (Sep 7, 2021)

Hey!!! I have a LaserJet P1102W, which also requires this foo2zjs CUPS filter!!! A successful way to do this is to specify this as printer address in CUPS web interface: `http://printer-ip:9100`. This assumes that you have print/foo2zjs successfully installed.


----------

