Setting up a scanner server
Setting up a scanner server on the Buffalo Linkstation
I'm going to describe the steps I followed to get saned (http://http://penguin-breeder.org/sane/saned/) cross compiled, and installed on my Linkstation.
- Host: Ubuntu 10.04 laptop
- Target: Linkstation Live v2 LS-CHL with opened stock firmware 1.07
- Toolchain: Codesourcery ARM toolchain version arm-2007q1
- Scanner: Canon MP610 multiunction printerr/scanner
- Download the sane-backends source from http://www.sane-project.org/source.html.
I used sane-backends-1.0.22.tar.gz which was the latest available.
- Download the libusb source that matches your linkstation. In my case I have:
-rwxr-xr-x 1 root root 28868 Jun 27 2008 /usr/local/lib/libusb-0.1.so.4.4.4
In http://sourceforge.net/projects/libusb/files/libusb-0.1%20%28LEGACY%29/ I saw that 0.1.12 was the last release and its date was older than the file above so I figured it was good enough which proved to be the case
- Configure and build libusb:
cd /path/to/libusb/source ./configure --host=arm-none-linux-gnueabi --prefix=/usr/local/codesourcery/arm-2007q1 make make install
The above will install to /usr/local/codesourcery/arm-2007q1. Just make sure you install somewhere that does not override your native Ubuntu files !! In my case make install complained that:
mv: cannot stat `libusbpp-0.1.so.4.4.4': No such file or directory libtool: install: error: relink `libusbpp.la' with the above command before installing it
As it happens this error can be ignored because the libs and headers needed to build saned are installed before the failure
- Configure and build saned:
cd /path/to/sane-backends CPPFLAGS=-I/usr/local/codesourcery/arm-2007q1/include LDFLAGS=-L/usr/local/codesourcery/arm-2007q1/lib ./configure \ --host=arm-none-linux-gnueabi --build=i686-pc-linux-gnu --prefix=/opt/sane make make install
Note that it makes things easier if --prefix above points to the same path where saned will be installed on the target. This is because this path is compiled into the code and used for looking for configuration files, etc. In this case saned gets installed in /opt/sane
- Tar up the /opt/sane directory you just created at the end of the build process in the previous section:
tar cvjf sane-backends-1.0.22.tar.bz2 /opt/sane
- Copy that over to the linkstation and untar it into /opt/sane
- chown -R root:root /opt/sane
- Add a new user and group for sane:
root@LS$ adduser saned
- Add a new file /opt/sane/sbin/saned_wrap and make it executable:
#!/bin/bash # All in the same line SANE_CONFIG_DIR=/opt/sane/etc/sane.d LD_LIBRARY_PATH=/opt/sane/lib /opt/sane/sbin/saned $@
- Add the following to /etc/inetd.conf:
sane-port stream tcp nowait saned.saned /opt/sane/sbin/saned_wrap saned
- Add to /etc/services:
sane-port 6566/tcp # SANE network scanner daemon
- Restart inetd:
root@LS$ /etc/init.d/inetd.sh restart
- Run /opt/sane/bin/sane-find-scanner:
# sane-find-scanner will now attempt to detect your scanner. If the # result is different from what you expected, first make sure your # scanner is powered up and properly connected to your computer.
# No SCSI scanners found. If you expected something different, make sure that # you have loaded a kernel SCSI driver for your SCSI adapter.
found USB scanner (vendor=0x04a9 [Canon], product=0x1725 [MP610 series]) at libusb:001:017 # Your USB scanner was (probably) detected. It may or may not be supported by # SANE. Try scanimage -L and read the backend's manpage.
# Not checking for parallel port scanners.
# Most Scanners connected to the parallel port or other proprietary ports # can't be detected by this program.
root@LS$ telnet localhost 6566
Connection should not be refused
- In a separate window run ps to check saned is running as user saned
- Uncomment localhost from /etc/sane.d/net.conf
root@LS$ /opt/sane/bin/scanimage -L
device `pixma:04A91725_108A04' is a CANON Canon PIXMA MP610 multi-function peripheral device `net:localhost:pixma:04A91725_108A04' is a CANON Canon PIXMA MP610 multi-function peripheral
- Now that you can access the scanner from localhost (i.e. the linkstation) let's allow all other hosts in the LAN to access the scanner. Add the following to /opt/sane/etc/sane.d/saned.conf:
or whatever your LAN settings are. Of course you can also enable access per host. Check saned documentation.
- Finally we need to make sure the USB device is accessible by user saned. We also need to ensure that this accessibility persists across reboots or plug/unplug USB cycles. This is achieved by adding a new file libusbscanner.hotplug in /etc/hotplug.d/usb_device:
#!/bin/sh # This file is a modified version of the one delivered as part of sane-backends. # # This script changes the permissions and ownership of a USB device under # /proc/bus/usb to grant access to this device to the saned user. # # Ownership is set to saned:saned, permissions are set to 0660. # # Arguments : # ----------- # ACTION=[add|remove] # DEVPATH=/class/usb_device/usbdevx.yy # SUBSYSTEM=usb_device IF=`echo $DEVPATH | sed 's:.*usbdev\([0-9]*\)\.\([0-9]*\):\1:'` DEV=`echo $DEVPATH | sed 's:.*usbdev\([0-9]*\)\.\([0-9]*\):\2:'` DEVICE=`printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV` if [ "$ACTION" = "add" -a "$SUBSYSTEM" = "usb_device" ]; then chown saned:saned "$DEVICE" chmod 0660 "$DEVICE" fi
- Edit /usr/local/etc/sane.d/net.conf (or /etc/sane.d/net.conf):
# This is the net backend config file.
## net backend options # Timeout for the initial connection to saned. This will prevent the backend # from blocking for several minutes trying to connect to an unresponsive # saned host (network outage, host down, ...). Value in seconds. connect_timeout = 60
## saned hosts # Each line names a host to attach to. # If you list "localhost" then your backends can be accessed either # directly or through the net backend. Going through the net backend # may be necessary to access devices that need special privileges. # localhost 192.168.15.33
- Check the client can see the scanner
user@client$ scanimage -L device `net:192.168.15.33:pixma:04A91725_108A04' is a CANON Canon PIXMA MP610 multi-function peripheral
- You should now be able to use a GUI frontend such as simple-scan to access your scanner over the network