Search:  
Gentoo Wiki

HOWTO_hpoj_/_CUPS

Image:Gentoo_tux.png

Base Install

  1. What is Gentoo?
  2. About
  3. Preparation
  4. Partitioning
  5. Configuring
  6. Stage Progression
  7. Kernel
  8. Bootloader
  9. Test
  10. Converting from or to a non-Gentoo distribution
  11. Troubleshooting
  12. Maintaining

Configuration

Base Extras

Server

Desktop

Other Articles

edit

Contents

Introduction

Getting your HP printer working under Linux is really easy, and you may be able to get just as much usage as you would under Windows.

I have a HP PSC 2210 (printer, scanner, copier, fax, card reader, coffee machine, etc...) so I will be focusing on that with this guide. If you have something different the instructions may differ slightly, but if you get it working edit this page.

The parts about setting up your printer with the HPOJ driver and CUPS were based on this post by 'elyre_elan'. The parts about scanning with SANE were based upon this post by 'zion1459'.

I have found the instructions at HPLIP to work well; those instructions suggest that HPOJ has now been superseded by HPLIP. Can anyone clarify?

Configuring the kernel for card readers support

This guide will provide you with instructions to compile support for card readers into your kernel. This means that you will need to reboot. If you don't want to for whatever reason you will have to compile the support as modules and load them seperately.

Kernel 2.4.x

cd /usr/src/linux
make menuconfig

<Options unknown, not using a 2.4.x kernel - most likely similar to 2.6.x ones so see what you can find out>

Compile the kernel, install it, make sure you have setup your bootloader, and reboot into it. Alternately, these options can be compiled as modules. Just be sure to edit /etc/modules.autoload.d/<your kernel> to make sure they load on reboot.

Kernel 2.6.x

cd /usr/src/linux
make menuconfig
Linux Kernel Configuration:
File systems --->
     <*> DOS FAT fs support
     <*>   MSDOS fs support
     <*>   VFAT (Windows-95) fs support
Device Drivers --->
   SCSI support  --->
        <*> SCSI support
        --- SCSI support type (disk, tape, CD-ROM)
        <*>   SCSI disk support
   USB support --->
        <*> Support for USB
        <*>   EHCI HCD (USB 2.0 Support)
        <*>   OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support
        <*>   UHCI (Intel PIIX4, VIA, ...) support
        <*>   USB Printer Support
        <*>   USB Mass Storage support

The filesystems stuff, SCSI support, and USB Mass Storage support is only if your printer has a card reader, and you want to use it.

EHCI support is for USB 2.0 - this may or may not be needed if you have USB 2.0 ports and a USB 1.x printer. If you just have USB 1.x you don't need it. Your system will support either OHCI or UHCI, just to be safe though you can compile both of them into the kernel. If you only compile one in and the system can't detect your printer try the other one.

Compile the kernel, install it, make sure you have setup your bootloader, and reboot into it.

Make sure your printer is detected

Plug your printer into your system and switch it on. If you run 'dmesg' you should see something like this:

Code: dmesg
usb 3-3: new full speed USB device using address 3
drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer \
dev 3 if 1 alt 0 proto 2 vid 0x03F0 pid 0x2911
devfs_mk_dev: could not append to parent for usb/lp0
scsi0 : SCSI emulation for USB Mass Storage devices
  Vendor: HP        Model: psc 2210          Rev: 1.00
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sda: 256000 512-byte hdwr sectors (131 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
 /dev/scsi/host0/bus0/target0/lun0: p1
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0,  type 0
USB Mass Storage device found at 3

If nothing has been detected make sure that you are using the correct kernel and you selected the correct options. If you selected OHCI or UHCI compile in support for the other one, or both. If you still haven't got anything connected make sure the printer is working properly by trying another system.

Note: Make sure hotplug is installed to populate the device files when the printer is plugged in to an already running system.

emerge -Duva hotplug
rc-update add hotplug boot
/etc/init.d/hotplug start

Finding out what driver you need

Have a look for your printer on the HP printers list of [1] to see how well your printer is supported and what drivers you will need.

My printer is a HP PSC 2210, as you can see I can get the best print quality using the 'hpijs' driver and Ghostscript. If the same is true for you, you may as well install them both now (I am not sure whether you will have problems installing them later).

emerge hpijs ghostscript

If your scanner supports scanning with SANE you may as well emerge that too.

emerge sane-backends sane-frontends

Everyone will need the HPOJ driver so there is a separate step for that below.

HPOJ driver setup

The next job is to set up the HPOJ driver. You may want to make sure your printer is supported by the driver before continuing by checking the list. You probably don't need the HPOJ driver if you are only interested in printing. The list also shows you what features are supported by the driver.

Installation is easy enough, just emerge it:

emerge hpoj

Note:If you cant emerge it because the package might be masked create a file /etc/portage/package.unmask and add a little voice:

#the syntax is =<package-group>/<package-name>-<its current version number>
#example:
=net-print/hpoj-0.91-r3


You then need to configure your system with it. Run ptal-init setup and follow the onscreen instructions. Just pressing enter will probably do the job. At the end it you will know whether it has found anything or not because if it does it will start the driver.

Code: ptal-init setup
Starting the HP OfficeJet Linux driver.
    mlc:usb:PSC_2200_Series

You can test connectivity by running the following (with the appropriate options from what You then need to configure your system with it. Run ptal-devid <printer id>, the printer id is the information that ptal-init setup gave you), it should print some 'information' about the device.

Code:
ptal-devid mlc:usb:PSC_2200_Series
   MFG:Hewlett-Packard;MDL:PSC 2200 Series;CMD:MLC,PCL,PML,DW-PCL,DYN;CLS:PRINTER; \
   1284.4DL:4d,4e,1;SN:MY2COF61GZ0G;S:0380008084021000002c1480020c2500009;AiO:0;

If you get error messages, then edit /etc/sane.d/dll.conf so that hpoj is listed (or uncommented) -- it also helps to delete all the other entries for printers if you don't need them.

Start hpoj, and add it to the default runlevel

/etc/init.d/hpoj start
rc-update add hpoj default

CUPS setup

Installation

The next job is to setup CUPS, again you will probably have to emerge it.

emerge cups

Once that is done you may want to edit the 'cupsd.conf' file so that you can access the web based configuration from other computers.

Basic Configuration

File: /etc/cups/cupsd.conf
<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.*
</Location>

<Location /admin>
AuthType Basic
AuthClass System
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.*
</Location>

You will also need to add this:

File: /etc/cups/cupsd.conf
Listen *:631
(Make sure that localhost is commented out)
#Listen localhost:631

You will still need to provide the root username and password to access the admin section of CUPS so nothing bad can happen by opening it to your LAN. Please be aware of the fact, that you will send your root password in cleartext over your LAN.

Next add it to the default runlevel and start it.

rc-update add cupsd default
/etc/init.d/cupsd start

Adding your printer

Now open your browser and go to:

  http://<server-ip>:631/admin/

You should get a box asking you to log in, enter your machine root username and password.

Click the Add Printer button and enter some information for your printer. This won't affect how it runs, and isn't nescessary - apart from a name. Also the name shouldn't have spaces in it (or be longer than 128 characters). Once you have done that click Continue.

Now for the moment of truth, whether you set everything up correctly. In the drop down list should be something called 'PTAL', space, the name of the device 'ptal-init' gave you, and the printer name in brackets. I get the following:

   PTAL mlc:usb:PSC_2200_Series (Hewlett-Packard PSC 2200 Series)

If you don't get that you did something wrong, if you do you can have a big sigh of relief because the rest should work without problems. Click Continue when you are done.

Now select the make, which will be 'HEWLETT-PACKARD' or 'HP'. If you click Continue you will be asked to select from a list of printers - both of these lists are different, so if your printer isn't on one it will most likely be on the other. My printer is under 'HP' as 'HP PSC 2210 Foomatic/hpijs (recommeneded) (en)'. If you haven't got the 'hpijs' driver installed yet, but the make you selected has it in its name now would be a good time to get it (see above). Next click Continue and you should be told it was added sucessfully.

If you can't see your particular printer listed at this point, you may not have the appropriate PPD file installed. Check back at LinuxPrinting.org, and find your printer. Download the appropriate PPD file, and save it under /usr/share/cups/model. Restart cups with

/etc/init.d/cupsd restart

Start the Add Printer process described here again. You should find your printer listed this time around.

Configuring your printer

Click the link to your printer and click the Configure Printer button. By default it set the paper size to 'Letter', but mine takes A4, so you may want to check and change this. Also for now you may want to set the printout mode to 'Draft' so you don't waste any expensive ink with a test page. Once you have finished setting stuff up click 'Continue' (you will get a message saying it has done, click the link to go back to the part about your printer.

Printing a test page

Next click the Print Test Page button, and with a bit of luck your printer should fire up into life and print a test page. On the page should be a colour wheel with a load of different colours and some settings about the paper size - I don't know how to change the settings to metric or change it another language though (e.g. proper English) so your are on your own there. If everything well congratulations, if not you did something wrong.

Scanning

Now you have your printer set up for printing, if it supports it, why not try scanning?

Installation

First you need to (if you haven't already) install sane and all the dependencies, and the xsane frontend.

emerge xsane

Configuration

Now that has finished you need to do the hard job of editing just one config file. Open up '/etc/sane.d/dll.conf' in your favourite editor. Somewhere should be 'hpoj' commented out, for me it was right at the bottom:

File: /etc/sane.d/dll.conf
...
#
# The following backends are not included in the sane-backends distribution
# If you want to use them, download them from their webpages and read their
# documentation
#
# HP OfficeJet backend homepage: http://hpoj.sf.net/
# Uncomment the following line if hpoj is installed:
#hpoj

If it is there just uncomment it, if it isn't just add it. Now save the file and SANE should now be able to detect the scanner.

On thing that nobody seems to mention is scanners running on the parallel port. Everyone seems to think that all the HP all-in-one devices run on USB..... not tru of the PSC 500 model! Don't worry though, setup is a breeze!

In the case of the PSC 500, you need to emerge the hpoj and hpijs drivers, according to LinuxPrinting.org. Do the following...

emerge -av hpijs



After you ensure that the USE flags are set properly, emerge the package. After that is complete, you need to run the following (part of the sane-backends I believe, which you should already have installed...)

ptal-init setup

This will scan the parallel ports (a step that is skipped by default) and locate any scanners you have attached. You shoudl see something like this:

Probe parallel port "-base 0x378 -basehigh 0x778 -device /dev/lp0" (y/[n])?  y

    Found "PSC 500"
    with serial number "MYJ09E1WW4WZ".

    This device will be set up as "mlc:par:PSC_500".
    Press <Enter> alone to continue or <Ctrl-D> to skip this device, or
    enter a different desired name suffix (without the "mlc:par:" prefix)
    here --->

Press enter and let it do it's thing. When it's done, simply run xsane or any other scanning frontend and the scanner will work as expected! Took me a bit of digging to find this, hope it helps someone out! --Skeezer65134 05:29, 20 October 2005 (GMT)

Testing

Use the following command to find out if it can detect anything (in the SANE documentation it tells you to run 'sane-find-scanner', but when I ran this it didn't detect anything - SANE runs fine though without it):

scanimage --list-devices
   device `hpoj:mlc:usb:PSC_2200_Series' is a Hewlett-Packard PSC 2200 Series multi-function peripheral

If you don't get anything with the above command make sure that your printer is connected, and that scanning is supported by the HPOJ driver for your printer. If it does fire up a GUI and run 'xsane' to try out some scanning. Try the various options and configurations to make sure everything is working properly.

Card reader setup

My printer also has a card reader so I will explain how to set that up (I also accidentally found my motherboard can boot from it :S). It is exactly the same as setting up a USB pendrive or other card reader, as a USB Mass Storage Device.

Note: The card reader can only read from one type of card at once, therefore only one card can be mounted at once.

This is easy enough to do (its even easier than scanning), but until you put a card into the card reader(the correct way around) nothing will be detected on the system. So make sure the printer can detect the card.

Once you have done that just issue these commands:

mkdir /mnt/usb
mount -t auto /dev/sda1 /mnt/usb

If you have other USB drives on the system it may not be /dev/sda1, I expect there is an easy way to find out which is which but trial and error is easy enough for this. You should now be able to access the files on the card.

cat /proc/partitions

will show you which drive is which, or at least offer a clue.

Troubleshooting

emerge hpoj: usb_xxx function not found

Note: If usb is set, you might encounter a possible compiletime hiccup where the emerge would complain that certain usb_xxx functions aren't found. This is a bug in libusb 0.1.8. In order to get it to work, type the following before you emerge hpoj:

cd /usr/lib/
ln -s libusb libusb.so

[ Nayan: Ensure that libusb.so points to an actual library, for example: libusb-0.1.so.4.4.0. So your command would be:

ln -s  libusb-0.1.so.4.4.0 libusb.so

Just FYI, my USE flags are:

USE="nptl ssl alsa kde qt moznocompose moznoirc cups foomatic foomatic-db ppds usb" ]

You can check what flags you are currently using by looking into the /etc/make.conf or through a tool named "ufed" which stands for user flag editor.

Now that you've done this, you can do the actual emerge.

See also

Internal guides:

External guides:

Retrieved from "http://www.gentoo-wiki.info/CUPS/HPOJ"

Last modified: Sat, 23 Aug 2008 14:21:00 +0000 Hits: 44,732