README.linux 6.78 KB
Newer Older
1 2 3 4 5 6 7
Information about USB scanners:

With Linux 2.4.* you could either use the kernel scanner module or libusb to
access USB scanners.  In Linux 2.6.4 the kernel scanner module was removed.
Therefore with this and later kernels libusb must be used.

8 9
While SANE automatically uses libusb when the library and its header file were
11 12 13
present during the build of sane-backends, setting permissions will require some
attention. So if scanimage -L lists your scanner as root but not as normal user
read on this text.

15 16 17 18 19 20
Most distributions support setting permissions without much manual
configuration. Usually you must just add the users that are allowed to access
the scanner to group "scanner". To make that change active, the user must login
again. For more details, see your distribution's documentation e.g. for Debian:
README.debian.gz. If this doesn't work you you want to know more, read on.

The device files used by libusb are located in /proc/bus/usb/
Henning Geinitz's avatar
Henning Geinitz committed
22 23 24 25 26 27
(e.g. /proc/bus/usb/001/003) or in /dev/bus/usb/ (e.g. /dev/bus/usb/001/003), if
you use udev.  The exact file name can be found out by running sane-find-scanner
which would print "libusb:001:003" in this case.  While setting permissions with
e.g. "chmod a+rw /proc/bus/usb/001/003" works, this change is not permanent.
The permissions will be reset when the scanner is replugged or Linux is

29 30 31 32 33 34
One solution to set permissions on-the-fly is Linux udev which comes with
current distributions. SANE comes with a udev rules file in the tools/udev
directory which may be used by distributions or can be copied to
/etc/udev/rules.d manually. The file format is explained on top of the file
itself. Either you need libusb 0.1.12 or newer or USB_DEVFS_PATH=/dev/bus/usb
must be exported as a system-wide environment variable.

36 37 38
Older distributions may use the Linux hot-plug tools (or hotplug-ng). Your
distribution should have set up the scripts to automatically change permissions
correctly. Look for "libsane.usermap" and "libusbscanner" in /etc/hotplug/usb.
39 40 41 42
If you build SANE from source you can use the hotplug script that comes with
SANE. See the tools/hotplug/ directory in the source distribution. Please refer
to the README in that directory for the details.

43 44
Gentoo information:
45 46
Gentoo users: If your USB scanner is not detected at all check that USE=usb is
set when emerging.

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
Information about SCSI scanners:

Under Linux, your kernel must have generic SCSI support (sg) as well as a
driver for your SCSI adapter. You may want to increase the SCSI buffer size
to increase scan speed. Details on all of the above can be found in

If your SCSI and sg driver are build as moduls you will need to load them
with modprobe:

# modprobe your-driver-name
# modprobe sg

You may find error messages in /var/log/messages. Look at the documentation
for your SCSI driver. Maybe you need to add options like the io port.

Now the SCSI adapter and your scanner should be visible at /proc/scsi/scsi.

# cat /proc/scsi/scsi
Host: scsi0 Channel: 00 Id: 06 Lun: 00
  Vendor: SCANNER  Model:                  Rev: 2.02
  Type:   Scanner                          ANSI SCSI revision: 01 CCS
72 73 74 75 76 77 78

In this case the real vendor and scanner name are not shown (Mustek
Scannexpress 12000SP) but SANE will detect it nevertheless.

If your scanner is supported by SANE, scanimage -L will list it now:

# scanimage -L
device mustek:/dev/scanner' is a Mustek ScanExpress 12000SP flatbed scanner
80 81 82

If this doesn't work you may have to add the right SCSI generic device name
to the configuration file. This should be documented in the man page for
your backend. To find out about the right SCSI device use sane-find-scanner:

# sane-find-scanner
Henning Geinitz's avatar
Henning Geinitz committed
86 87
found SCSI scanner "SCANNER  2.02" at /dev/scanner
found SCSI scanner "SCANNER  2.02" at /dev/sg0
found SCSI scanner "SCANNER  2.02" at /dev/sga

Henning Geinitz's avatar
Henning Geinitz committed
90 91
It may help to set a symbolic link /dev/scanner to the respective device if
automatic detection does not work.
92 93 94 95 96 97 98 99

If you need more information on the Linux SCSI subsystem, look at Although this
documentation is about the 2.4 kernels, large parts are also valid for
older kernels. One important exception is the section on "Device Names
in devfs".

Adaptec 1542 SCSI adapter:
  Using buffer sizes of more than 32768 bytes with the aha1542 driver can
  lead to kernel panic with older kernels. To avoid this, run configure with
  the option --enable-scsibuffersize or set the environment variable
103 104
  SANE_SG_BUFFERSIZE to 32768 before running scanimage or another frontend,
  or download and install the SG driver 2.1.37 or newer from
106 107 108 109 110 111 112

  The Linux kernel "Emulation of a SCSI host adapter for IDE ATAPI
  devices" (idescsi) is reported to cause problems in connection with
  SANE. If your scanner isn't found or you encounter segmentation faults
  try to disable idescsi.

113 114 115 116
SCSI Direct IO: Recent versions of the Linux SG driver for the 2.4 kernels
  support direct IO, i.e., the SCSI adapter's DMA chip copies data directly
  to/from user memory. Direct IO reduces memory usage, but it can lead to
  access conflicts, if a backend uses shared memory. SANE does not use
  direct IO by default. If you want to use it, run

	configure --enable-scsi-directio=yes

121 122 123 124 125 126 127 128 129
Very old Linux distributions are missing the /usr/include/scsi directory.  In
such a case, it is necessary to copy the relevant files from the kernel
distribution.  Normally, the command:

  cp -a /usr/src/linux/include/scsi /usr/include

should fix this problem. Don't do this if you don't get compilation errors
about missing SCSI headers.


131 132 133
Other Information

134 135 136 137 138 139 configuration:
  "/usr/local/lib/sane" or "/usr/lib/sane" MUST NOT be listed in
  /etc/ If your scanner is not detected or only Video for Linux
  devices are found, check for one of the above lines in
  A line "/usr/local/lib" or "/usr/lib" in is ok, however.

Excessive warnings "pointer of type `void *' used in arithmetic":
  Some older versions of glibc generate these warnings not related to SANE
142 143 144 145 146
  source code. To suppress these warnings do

  export CFLAGS="-g -O2 -D__NO_STRING_INLINES"

  and rerun configure.
147 148 149

If you use DEC cc on Linux Alpha, you may need to set LDFLAGS="-N" to
  be able to build sane-backends.
150 151 152 153 154 155 156 157 158 159 160 161 162 163

The Intel C++ Compiler for IA32 and IA64 isn't supported yet. If you want
  to try nevertheless, you will experience undefined references to inb
  and outb functions. To avoid those replace #include <sys/io.h> with

  #if defined(__ICC) && __ICC >= 700
  # define __GNUC__ 2
  #include <sys/io.h>
  #if defined(__ICC) && __ICC >= 700
  # undef __GNUC__
  #elif defined(__ICC) && defined(HAVE_ASM_IO_H)
  # include <asm/io.h>
164 165

Have a lot of fun with the latest SANE backend.