ALINK="#FF0000">

"Linux Gazette...making Linux just a little more fun!"


How I got my Adaptec AVA 1502 SCSI card to work with Linux and SANE

By James M. Rogers


I have a Microtek ScanMaker E3 that I have ran under windows for a few years to allow me to convert from hard copy to digital.  I have never been satisfied with the performance of this scanner under windows because I was so limited in the size of the images that I could process.  I won't bore you with the details, suffice it to say that it was slow, tedious and the results were only adequate.

I have heard about Scanner Access Now Easy (SANE) for a few years.  It is a project to implement a consistent scanner interface across all scanners, digital cameras, and other items.  It only works with SCSI scanners at this time.

It took me three tries to get the program to work for me.

Try one:

The SCSI driver card that came with my scanner claimed to be an AVA-1502E.  I couldn't find a driver to work with this under Linux.

Try two:

I thought that this card is an Adaptec card so I tried to load the Adaptec modules, concentrating on the aha152x.o  The most I got was the insmod program seeming to lock up.  At no point in this process did it recognize my card.

Try three:

I peeled the sticker off of the main chip and saw that it was an 6360 chip (Doing this probably voids the warranty.)  So I dug into the Linux source code. In /usr/src/linux-2.0.32/drivers/scsi/  there is a file called aha152x.c.  I read this file several times and got a general picture of how this file worked.  I then modified the file /usr/src/linux-2.0.32/drivers/scsi/Makefile and commented out the line following line:

    AHA152X = -DDEBUG_AHA152X -DAUTOCONF

turns to:

    #AHA152X = -DDEBUG_AHA152X -DAUTOCONF

I then added this line right below the commented line:

    AHA152X = -DDEBUG_AHA152X -DSKIP_BIOSTEST -DSETUP0="{ 0x140, 11, 7, 0, 0, 0, 100, 0 }"

Basically we are telling the module to stop trying to autoconfigure the card, don't try to see which card it is and to use the given settings.  I will contact the maintainers of this code and work with them on getting this driver to autorecognize this card, if possible.

The first two numbers are the ones that you care about.  These numbers correspond to the the jumpers on the card.  The first number is 0x140 if the jumper is on the card , or 0x340 if the jumper is removed.  The 11 corresponded to the irq setting on my card.  This number can be 9, 10, 11 or 12 depending on how the jumper was set.

If you want to know more about these other settings look in the source code and

I then changed to /usr/src/linux-2.0.32/  put a floppy disk in the drive and did a

    make dep ; make clean ; make zdisk

Once the disk had been made I put the disk in my Linux box with the scanner attached and rebooted.  It came up and saw my card and told me that the card was device /dev/sga.  When I looked in /dev/ for a device called sga I couldn't find one.  So I made a link from /dev/scanner to /dev/sg0 instead with the following command:

    cd /dev
    ln -s sg0 scanner

I then configured my /etc/sane.d/dll.conf to look like this:

# enable the next line if you want to allow access through the network:
#net
microtek
pnm

I configured my /etc/sane.d/microtek.conf to look like this:

#Uncomment the following if you are tired of seeing the dump of the
# scanner INQUIRY every time the backend starts up...
nodump
/dev/scanner

Then I ran the following command and it worked!!!:

    scanimage --help -d microtek

This tells you the other commands that will work with the scanner.

I then scanned in stuff with the command line command and with xscanner

    scanimage -dmicrotek -x214 -y296 --resolution 97 > test.pnm

The above command is a full scan of the entire page at 200dpi. The output of these programs is pnm format which allows you access to hundreds of filters to process and convert your output to the exact format that you desire.  See the man pnm page for more details.

I have already done some 11MB graphics files and used some pnm utilities to filter them, edited them with gimp, cut out the area that I wanted and saved them as jpg's.  The neat thing is that I am testing out SANE by running it on a machine with only 16MB of memory and no swap.  (I am processing the files on a different, faster machine) So far SANE has only failed on full screen images above 200dpi which is not bad.  Once I have a baseline I will put this machine to 32MB RAM and 32MB swap space.

I love the ability of Linux to get in there and let me really control my hardware configuration.  With Microsoft the only option that I would have had would have been to buy a "compatible" product and install one of the manufactures full featured (bloated), buggy driver programs.  The support tech would have probably sneered at me as he said this.  This is the first time that I have "dug into" the kernel driver code, researched a problem and found a solution.  Just the satisfaction of being able to fix the kernel to recognize the hardware that I have already paid for is very rewarding.

Next month I will talk about getting the networking portion of SANE up and running.
 


Previous "The Standard C Library for Linux" Articles

The Standard C Library for Linux #1, February 1998


Copyright © 1998, James M. Rogers
Published in Issue 31 of Linux Gazette, August 1998


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next