"Hier staunt der Laie und Fachmann wundert sich."

Samstag, Mai 21, 2005

HOWTO: Installing a USB-Scanner (Epson Perfection 1670)

Another quick step-through for Debian-linux with a >=2.6.4 kernel. Since kernel version 2.6.4 the scanner driver has been removed from the kernel and one needs to use libusb. Don't worry if libusb does not mean anything to you.
For some of this, you need to be root.

Before you begin

I'll assume that USB support is up and running. Check this by opening a shell and running "tail -f /var/log/messages". This will output the last lines of you log-file and any new log-messages (you terminate with the usual CTRL-C). Now plug-in you scanner and turn it on. The shell-window should show something like
kernel: usb 4-4: new high speed USB device using ehci_hcd and adress 4
The actual message my vary, depending on your USB-device, but essentially something should happen when you plug-in the scanner and it should not sound like an error.
Another thing you will need is the firmware-file for your scanner (some scanners don't need one, mine does). Check out this list of firmware-file-names to determine the exact name of the firmware-file. For my Epson-scanner the firmware was (under Windows) in "c:\program files\EPSON\ESCD\ESFW30.BIN". I simply copied this file to my linux-partition ("/usr/share/EPSON-firmware/ESFW30.BIN" seemed a good place). You will need this file later.

Installation step by step

  1. Use your favorite packet-manager to install the "sane" package and its dependencies. (SANE stands for "Scanner Access Now Easy" -- and it really is.) This includes "xscanimage" which can be used to, well, scan an image.
  2. Now you have to determine your scanner product and vendor-id. Have look at the output of "less /proc/bus/usb/devices". The list can be quite long if you have a lot of USB-devices. Your scanner should be somewhere among them. It looks something like this:
    [...]
    D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1
    P: Vendor=04b8 ProdID=011f Rev= 1.10
    S: Manufacturer=EPSON
    S: Product=EPSON Scanner
    C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=100mA
    I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
    [...]
    We are interested in the vendor- and product-id (in my case "04b8" and "011f").
  3. Open "/etc/sane.d/epson.conf" (or whatever your scanner manufacturer is) with your favoriate editor and add the following line, using your own vendor- and product-id, of course:
    usb 04b8 011f
    Save and close the file.
  4. Last thing we need to do is tell the scanner driver where it can find the firmware. For many scanners this is done in "/etc/sane.d/snapscan.conf". Change the line starting with "firmware" to point to your firmware-file. Mine looks like this:
    firmware /usr/share/EPSON-Firmware/ESFW30.BIN
  5. The scanner should work now. Try "sane-find-scanner". It outputs a whole lot of stuff, but one line should read something like "found USB scanner (vendor=0x04b8 [EPSON], product=0x011f [EPSON Scanner]) at libusb:004:004".
  6. We're almost there. You could go ahead and scan your first image -- but you will only be able to do so as root. What we need to do is set the permissions for the USB-device. This can be very tricky because the device may change everytime you plug in your scanner. Luckily, the isntallation of the sane-package has created a new user-group called "scanner" and it also makes sure that members of that group always have access to the right USB-device. (It does this by using the hotplug-mechanism.) All you have to do is add the users that should be able to scan to the scanner-group. Simply open "/etc/groups" in your favorite editor, locate the line beginning with "scanner" and add the user(s) seperated with colons (":"). Mine looks like this:
    scanner:x:109:stefan

  7. One last thing: The scanner-users also need access to the firmware-file. So you need to change the permissions approiately, in my case "chmod 666 /usr/share/EPSON/ESFW30.BIN". This allows everyone full access to the file. You could restrict this to the members of the scanner-group. This is left as an exercise.
  8. Congratulations! You're done. Start "xscanimage" to scan your first image.