Friday, May 28, 2010

Getting your scanner to work with Ubuntu (gt68xx)

You try to use your scanner with XSane but it says that it cannot open the device and gives you the error «invalid argument»? If so, I may have an easy solution for you!

First of all, and after ensuring that you have the package sane-utils installed, open a terminal and run «scanimage -L». Look at the command’s output for the line matching your scanner, which may be something like «gt68xx:libusb:001:005 is a Mustek BearPaw 12: f00 CU flatbed scanner». If your line starts the same way, that is, with «gt68xx», then keep on reading! (If not, then I’m sorry but you’ll have to look somewhere else for instructions on how to get your scanner to work).

Alright, so now that you know for sure that your scanner works with the gt68xx driver, you only need to do one thing: install the firmware for your model. This is a «.usb» file which you can find in the driver CD for your scanner or at this website: firmware for gt68xx scanners, and you only need to copy it into the directory «/usr/share/sane/gt68xx/».

I have tried this with a Packard Bell Diamond 1200 Plus, which needs the firmware file «PS1Dfw.usb». So, I just copied that file from the driver CD (it’s in the directory WinXP; note that, if you prefer, you can also download the file from the above mentioned webpage) to my home folder and then using the terminal moved it by doing «sudo mv PS1Dfw.usb /usr/share/sane/gt68xx/» and set the right permissions for it with «sudo chmod 644 /usr/share/sane/gt68xx/PS1Dfw.usb».

That’s it, now you can go to Applications -> Graphics -> XSane Image Scanner and it will work just fine :).

To get your scanner running, you need a firmware file. The firmware is usually named *.usb (e.g. PS1Dfw.usb). You really need the firmware file for your specific scanner. E.g. the BearPaw 1200 CU's firmware will not work with the ScanExpress 1200 UB Plus. For most Mustek scanners the firmware can be downloaded from the status section. If your firmware isn't listed there, try one of the following methods:

* Recent Windows driver CDs contain the firmware file in the WinXP directory.
* For some scanners the driver that comes on CD or that can be downloaded from the manufacturer's website can be uncompressed using "unzip" and/or "cabextract" and/or "unshield" even if it's an .exe file. Some drivers can also be found on driverguide.com.
* If you can't get the firmware directly, you must install the Windows driver on a Windows platform. The firmware was located in c:\\windows\system32\drivers\PS1fw.usb in my case.
* There are some success reports with using WINE to install the Windows driver. The installation crashes but the firmware file can be retrieved from windows/System32/Drivers/ (or windows/) nevertheless. It may depend on the wine version, one success report was with Codeweavers WINE.

Put your firmware file in /usr/local/share/sane/gt68xx/ (or /usr/share/sane/gt68xx/ if you use a SANE package that came with your distribution). You may need to create this directory. Or use whatever directory you want, but you must specify the path in gt68xx.conf later. Example:

su -
mkdir /usr/share/sane/gt68xx/
cp PS1fw.usb /usr/share/sane/gt68xx/
chmod a+r /usr/share/sane/gt68xx/PS1fw.usb

Using the gt68xx backend

Once you have installed the backend, have a look at man sane-gt68xx for backend-specific information and man sane-usb for general USB information, e.g. for how to set permissions.

After successful installation, you may need to setup gt68xx.conf (in /usr/local/etc/sane.d/). That's necessary for some GT-6801-based scanners like the Mustek ScanExpress 1200 UB Plus (and clones), the Mustek BearPaw 2400 CU, and the Artec Ultima 2000 (+ clones). Uncomment the right override for your scanner in gt68xx.conf. If you use a different path for your firmware file or the firmware has a different name, add/uncomment a firmware line in gt68xx.conf. See man sane-gt68xx.conf for details.

Also check that "gt68xx" is listed in dll.conf.

Try sane-find-scanner now. If it doesn't find your scanner, there is a problem with access to the USB kernel drivers, a permission problem or sane-backends wasn't built with libusb support.

scanimage -L should find your scanner now.

Try scanning with "scanimage >out.pnm". If it complains about not finding the firmware, check gt68xx.conf again, especially the override and firmware lines.

"scanimage --help" lists the available options like --mode and --resolution. If something doesn't work, use "export SANE_DEBUG_GT68XX=255" to get debug output. Reports are welcome.

If your scanner works but is recognized with the wrong vendor/model names you can adjust them in gt68xx.conf (vendor/model lines).

If you have compiled your own SANE from source and if you want to use XSane (or any other graphical frontend), I recommend removing the distribution's sane and xsane packages completely and compile XSane from source. An alternative and rather ugly way is to keep the distribution's sane and xsane packages and to overwrite the sane installation by running configure in the gt68xx package with arguments like this: "configure --prefix=/usr --sysconfdir=/etc". All files are in /usr now including the firmware location "/usr/share/sane/gt68xx/". You may need to add "gt68xx" to dll.conf. No guarantees for the second approach, you are on your own.