Agfa Snapscan 310 Scanner with Linux

RedHat 7.2, kernel 2.4.7-10, Sane 1.0.5

Steve D. Sharples

Last update: 13th May 2002

Random link: TCP/IP Control of a LeCroy DSO with Linux
Random link: Linux on a Dell Latitude CP M233XT
Random link: strip_nl: newline (CR) stripper
Random link: Eagle PCB -> LPKF Milling Machine Mini-How-To
Random link: Installing PCI230/PCI260 Comedi driver on a RedHat 9 system (PDF)
Random link: The steve (a new unit of measurement)

Pre-amble: skip this if you like

Introduction

I'll get round to this eventually. Basically I wanted a scanner to scan in photos to stick them on the web. I bought an Agfa Snapscan 310 off a mate for £20.

Me and Linux - Background

I'll get round to writing this bit soon. Basically been using Linux for a couple of years, self-taught, never really learnt it properly, just kinda pick things up. Much of this is bodged, and I'm sure there's a neater way of doing it. Feel free to email me (remove the no.spams) to tell me how to do things properly if you know better, and I'll update this page.

Scanner specifications

I don't know the specs of the scanner, but XSane lets you scan at a maximum of 300dpi, 8-bits per colour (so, I guess that's 24 bit colour, then?). It's attached to the computer via an Adaptec AVA-1505 SCSI interface... this is on an ISA card.

Useful resources

The following websites were useful in getting this thing working (in order of usefulness):

Suse support knowledgebase - VERY useful
Adaptec info on the scsi controller that comes with the scanner.
The Linux 2.4 SCSI Subsystem HOWTO
The Linux SCSI Generic (sg) HOWTO

Pre-install

The supplied SCSI driver is on a Plug and Play ISA card, although first you must disable this feature using a DOS config utility provided by Adaptec. First, you must find an available IRQ. You can do this by typing "cat /proc/interrupts"... pick a number that's not being used (I chose 11... the default for the card, 10, was being used by the USB interface). You've got 2 choices for IO addresses for the card - 0x140 and 0x340, settable by using a jumper on the board. Do "cat /proc/ioports" and hopefully you'll see one of those isn't being used. Right, you've now got enough info to run the Adaptec SCSI board config utility.

First thing you need to do is go to the Adaptec site to get a DOS program called "1505cfg.exe" (I can't put a link directly for the program here, you'll have to get it from their site and agree to terms and conditions etc). You need to put this on a DOS bootable floppy disk. The only way I know of making one of those is from a computer that's got Windows 98 on it.

To make a DOS bootable floppy, take a blank, DOS formatted floppy and stick it in a Windows machine. Right-click on "Floppy drive" or something similar and select "Format". Check the button that says "Copy system files only". That should do it. Then download the "1505cfg.exe" file, stick it on the DOS bootable floppy, and reboot your linux box with the floppy in the drive (don't forget to alter BIOS settings so that it boots off the floppy in preference to the hard drive).

Once you get a command prompt (A:/) type "1505cfg" ... this will create a couple more files on the floppy, called "1505ACFG.EXE" and "1505ACFG.BIN" Then type "1505ACFG" and you should get a menu-driven config utility.

The main thing to do here is to disable the "Plug and Play" option.... I think it's under something like "advanced options." You need to set the scsi device number to 7, and the IRQ number to one that doesn't clash (10 is default, I had to use 11). Make the changes, exit, and it'll tell you to power-cycle your computer. When you do, it'd be a good time to make sure you've got that jumper on or not... on=0x140, off=0x340.

Before you turn the computer back on, connect the scanner to the SCSI card, and turn on the scanner. Turn the computer back on, and hopefully nothing spectacular will happen.

Telling the computer about SCSI

My computer didn't know anything about SCSI, since it doesn't have a CD Writer. Here's where I generally get a bit muddled. People talk about "compiling things into the kernal" and that sounds kinda scary. But you can load in modules after you've booted up manually, and that's what I do. So, as root, issue the following commands:

/sbin/insmod scsi_mod
/sbin/insmod sg
/sbin/insmod aha152x aha152x=0x140,11,7,0

The aha152x driver works with the AVA-1505AE card, and the 0x140 is the IO port address (if you leave the jumper off, this would be 0x340), 11 is the IRQ, 7 is the card id (or something). The trailing 0 is a flag, something about reloading, as far as I remember. If you do all that and you get no errors, then you should be able to do:

cat /proc/scsi/scsi

I then got the following result:

Attached devices: Host: scsi0 Channel: 00 Id: 02 Lun: 00
Vendor: AGFA Model: SNAPSCAN 310 Rev: 1.90
Type: Scanner ANSI SCSI revision: 02

Yay!

SANE

Download SANE ("Scanner Access Now Easy") from the SANE homepage, or get the binaries from your Linux vendor cd. I found that I already had everything I needed installed as default with RedHat 7.2. If you've got RedHat, find out if you've got anything useful installed with:

rpm -qa |grep sane

Mine came up with:

sane-frontends-1.0.5-2
sane-backends-1.0.5-4.1
xsane-0.82-3.1
sane-backends-devel-1.0.5-4.1

Don't think you really need the devel package, but *shrug*. XSane is a pretty nifty graphical frontend.

Frontend programs (like xsane and xscanimage) use sane-backend drivers to do the communicating with the scanners. The driver for the Snapscan 310 is included as standard with the sane-backends distribution. It uses a short config file, /etc/sane.d/snapscan.conf which, amongst other things, tells sane where to look. It contains the line /dev/scanner and so you must make a link to the correct sg device. As root, I ran the command sane-find-scanner which came up with:

sane-find-scanner: found scanner "AGFA SNAPSCAN 310 1.90" at device /dev/sg0
sane-find-scanner: found scanner "AGFA SNAPSCAN 310 1.90" at device /dev/sga

If you look in /dev (" ls -l /dev/sg* ") you'll see that sga is a link to sg0. You need to create another link (as root):

cd /dev
ln -s sga scanner

In order to be able to run xsane etc as a normal [non-root] user, you need to alter the permissions of /dev/sg0:

chmod 666 /dev/sg0

I think that's about it!

HAPPY SCANNING!