USB devices including CUPS printing, scanners, and webcams

'' This article Based on work by Myno, andre, mindbender, downlalaway, Thorongil, frontalot, and TcT. Originally by downlalaway at Linkstationwiki.org '' This is a basic run through of USB devices connecting for Debian on an PPC LinkStation. The USB hard drive is USB 2.0 at 3Mb/s (on a laptop HD). NB. This was based on using the original kernel #990 conversion of the LS 1 and not the Freelink project. It has been updated for use with Freelink 1.11 but requires run-throughs by others to check. USB and hotplug was/is a little flakey on 2.4 kernels in recognising devices. A reboot while the device is in should make things work. The 2.6 debian kernel is highly recommended if hot-swapping of usb devices might occur.

CUPS Printer
Assuming you're running testing or unstable then:

apt-get install cupsys cupsys-driver-gutenprint cupsys-pt cups-pdf

As at July 06 cupsys-driver-gutenprint is not in Debian stable 'Sarge' (default freelink 1.11) - you can either dist-upgrade to testing 'etch' (use caution -which is why its not described) or just install the odd package from testing or unstable, such as gutenprint by following: (http://www.nas-central.org/index.php?title=Articles/DebianUnstablePackages) and adjusting as you feel appropriate. Testing instead of unstable is generally fairly up-to-date but with fewer problems.

apt-get install gs-common gs-esp gs-gpl gsfonts xpdf for pdf and possibly to help gimp-print drivers apt-get install hotplug usbview usbutils

for easier usb device info -if you haven't done it already for a usb hard drive [(see usb hard drive part)]

cd /dev; ./MAKEDEV -v usb (probably unnecessary) mknod /dev/usblp0 c 180 0 (think this makes the show work) mknod /dev/usblp1 c 180 0 (added this for luck)


 * Personal note: I ran the above three lines, agonized for hours over configuring CUPS, then ended up going to /dev again, deleting usblp0 and usblp1, running ./MAKEDEV again (this time without any parameters), and voila my testpage suddenly appeared (it had been trying to print for a long time, but said the printer was disconnected. I'm not an expert in devices either so I have no idea why this solved my problem - but it seems it did.

Probably reboot LS (for kernel 2.4.17). Reboot printer then insert.

lsusb It should show the printer connected somewhere

usbview

This should show it again (in a gui via vnc) and show the Name:usblp and interface number (mine is 1 possibly due to it being also a scanner). Go through the cups web interface http://localhost:631 if you have mozilla running on-board. Alternatively edit cupsd.conf and scroll down to the Allow localhost lines near the bottom and add

Allow From @LOCAL

below the lines:

Allow From 127.0.0.1

This will allow locally networked computers to access and admin the printer config. Turn off the @LOCAL or modify for your IP only if you don't trust everyone to be able to admin it.

'''NB. Cupsys 1.2 and 1.2.1 have changed a little and have an apparent bug (or zealous security feature):

The Allow From localhost line in the /etc/cups/cupsd.conf line locks out any other added Allow lines, e.g. local network connections. Replace it with Allow 192.168.1.x for the LS's LAN address and add Allow @LOCAL for your lan and any others you need. It seemed to work... Check access with typing http://linkstationip:631 into a browser.

'''If you probably have problems in accessing the https-sites:

I found the hint here

You have to create a ssl-certificate in /etc/cups/ssl

openssl req -new -x509 -keyout /etc/cups/ssl/server.key -out /etc/cups/ssl/server.crt -days 365 -nodes

Select printers, add printer, enter the Name, location descripton etc (there are notes about no spaces in names - maybe an old version of cups tho). Select usb #1 interface and then your printer from the next lists. If your printer isn't in gutenprint then you might need to check it in linuxprinting.org. Cupsys-gutenprint gives you every printer possible, a bit unnecessary usually. Hopefully returning to the printer page it should show it on

usb:/dev/usblp0

USB 1 interface number printer gives usblp0, USB 2 interface gives usblp1 etc. Both worked for me!?

Print a test page from the web interface and be very joyful if it works first time. To troubleshoot: Reboot the linkstation, unplug the printer, reboot the printer while plugged in... trying test pages. Often it springs into life when not expecting and then works for evermore. Do usbview through a vnc link to see if it connected properly at each stage.

Now there's two ways of setting up to be able to print from your other networked computers -IPP printing and samba printing. IPP is preferred since samba currently shows delays in printing.

Cups-IPP Printing
You can share you printer to your network without using Samba. Thus, you can easily share your printer without bothering about Samba configs.

Working with RAW printers (you use the driver on your client, simply add the printer with driver "RAW" in CUPS web interface) is in my case sped up by the factor 100, as Windows and Samba and Cups do not need to argue about the driver to be used and access rights.


 * Personal note: In my CUPS web interface (version 1.2.2), I never got the option of adding a printer with driver "RAW", it just offered me a subset of the available printers, seemingly based on some autoconfiguration options (I only saw HP printers, which is what I have). Disconnecting the printer did not result in RAW being offered. After a great deal of trial and error I removed the "MyPrinterName.ppd" file which was automatically created in /etc/cups/ppd/ . After removing this file, my printer was finally listed as a "Raw Printer" in the CUPS web interface, and I managed to print according to the instructions below (I needed to have my printer driver disk ready to install, since each client needs its own driver due to the lack of a device-specific driver on the server).

For sharing to your net 192.168.0.x, you simply add "allow from 192.168.0.*" to the line configuring access to CUPS in cupsd.conf. Or one can use @LOCAL -see above.

To add the printer in Windows, goto Settings, Printers & Faxes, Add a printer, say "Network printer", now select "Connect to Printer on Internet or your Intranet via HTTP" and put in:

http:// :631/printers/

Now you are prompted for a driver, if CUPS does not provide one. In the case of a RAW printer, you must always select a driver and use it.

Thats it, you are done, wasn't that easier than fumbling around with smbd.conf?

Cups-PDF Printing
Cups-pdf is installed to do a pdf printer, but I think the gs files are needed to allow it to work. xpdf is used to view the pdfs (through a vnc connection). To activate a cups-pdf printer: go to Cups web interface then add printer, insert name etc (no spaces), find Virtual Printer(PDF printer) at bottom, select postscript (I did at least), 'Generic postscript color..' on next page and go back to the start.

One can adjust resolution if needed. Print a test page. It should end up in /root/cups-pdf since logged in as root in the web interface. Otherwise it will print in the /home/username/cups-pdf/. There's error messages available in the web interface too. There appears to be no direct way to change the output directories, but it can be shared by creating a symlink to the /home/username/cups-pdf directory within an area already shared in samba. If samba share permissions allow access to the cups-pdf folder the pdf files will appear in this new directory when you print them. e.g. If you have guest access on the samba share check read permissions for others apply to the cups-pdf folder and pdfs. Also make sure wide links=no is not in smb.conf for that share. A command to create the symlink will go as:

ln -s /home/username/cups-pdf /mnt/sambashare/pdfoutput

Replacing username with your standard samba share user and sambashare with the directory name (or path) that you want the new pdfoutput directory to appear. This needs clarifying a little but should work with a little investigation.

Samba for Printers (although IPP is recommended & faster)
All the following Samba configurations can be done more easily through Webmin (see Articles/DebianWebmin) instead of manually editing the conf file. Samba settings for M$ printing. My config in /etc/samba/smb.conf (relevant section):

[global] . . load printers = yes printing = cups printcap name = cups show add printer wizard = No guest account = nobody [printers] comment = All Printers path = /tmp browseable = yes printable = yes create mask = 0777 use client driver = yes print command = lpr -P %p -o raw %s -r guest ok = yes guest account = nobody [print$] comment = Printer Drivers path = /etc/samba/drivers browseable = yes read only = yes guest ok = no write list = root It works ok for me! Others may wish to change guest access for internal network security.

Do a /etc/init.d/samba restart then switch to your M$ box. Find each printer on your linkstation in network neighbourhood and double click etc and select the correct driver for the physical printer and the Apple Color LW 12/660 PS printer for the PDFprinter. For the PDF printer check that colour is selected in the default printing properties on the M$ box -can default to B&W. All this took a few evenings to finally sort out (thanks for help to wartstew). The breakthrough was getting cups with gimp-print drivers to run (it broke first time) and getting the usb port right.

Scanner Setup
For scanner I originally used xsane -this can test if your scanner actually works. Confident people might go straight to sane.

apt-get install xsane

It worked and found the scanner first time through a vnc link as root -before I did ./MAKEDEV or mknod etc. If xsane works this is a good start.

There is a good way of networking your scanner -this is pretty impossible in windows except with a corporate commercial program I saw. You need to install sane on the LS as per:

apt-get install sane sane-utils

I used versions 1.0.15-10, a newer version is now current. sane-utils sets up a 'saned' user and group which are the safe ways to access instead of root as xsane used. Best to check this is in /etc/group.

The main difficulty is giving your scanner access to non-root. There's a number of tricks depending on hardware (mine an Epson CX3200 printer/scanner). This is how I (downlalaway) did it: As root do scanimage -L this should find a scanner - if not reboot and reboot/replug scanner. Hopefully a found scanner is id'd and uses libusb. Try as a non-root user - it probably won't find it yet.

'''Note: the following script was unnnecessary when using udev on 2.6.16 experimetning on a debian Linksys NSLU2, and is expected to be the same with udev on a linkststation.

So to get non-root access to the scanner I had to add a small script to automatically give the scanner group as 'scanner' -details from: http://www.freecolormanagement.com/sane/libusb.html And the relevant section: Save the script as /etc/hotplug/usb/epson_scanner and make it executable.

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ] then chown root "${DEVICE}" chgrp scanner "${DEVICE}" chmod 660 "${DEVICE}" fi
 * 1) !/bin/bash

Check in /etc/group there's a group 'scanner' and add any usernames you want access and the saned user.

scanner:x:102:root,username,saned

Reboot the scanner and LS to update group list. Now we need to log in as saned and check saned access. As root type:

linkstation#su -s /bin/sh - saned saned@linkstation$scanimage -L

This should find your scanner again if its all worked -try some rebooting/repluggin first if not and check root still finds it. So it works for non-root locally now to get networked follow the advice at: http://penguin-breeder.org/sane/saned/

The steps are: ->1. Setup up inetd (or xinetd) with /etc/inetd.conf to start saned on a request ->2. Check /etc/services (should be default ok) ->3. Set inetd to start at boot (Webmin..system..bootup and shutdown.. tick the inetd entry and press button to start on boot)

To access from a Windows box use sanetwain (its great!):

http://sanetwain.ozuzo.net/

It will allow Twain integration easily into any windows programs including work etc as though it were directly connected (NB check your firewalls to allow access). You may have to delete the Devices line in the C:\Windows\sanetwain.ini file before connecting. I don't know a good solution yet, but it is caused by sanetwain recording the last good libusb connection number, but it changes the next time the scanner is turned on. You could also use XSane (for Win or Linux) and other Linux derivatives -Kooka etc.

Scanner Sharing
Here's how to provide scanning services to the local subnet 191.168.11.*. The router's IP address is 192.168.11.1 here. The scanner in this example is an, already running, HP-PSC 1100 All-In-One device, using HP's hpaio driver (hplip) on Debian etch. saned is started via inetd and protected via TCP wrappers (/etc/hosts.{allow,deny}). The first line hints to the file you are supposed to add the code in the respective second line to. If the files don't exist, create them. Complete all steps, reboot.

sane-port stream  tcp  nowait  saned.saned  /usr/sbin/tcpd /usr/sbin/saned
 * 1) cat /etc/inetd.conf |grep sane

The above suggests to add the line "sane-port stream  tcp  nowait  saned.saned  /usr/sbin/tcpd /usr/sbin/saned" to the file "etc/inetd.conf" with an *X compatible editor such as vi (onboard).

sane-port      6566/tcp        # SANE network scanner daemon
 * 1) cat /etc/services |grep sane

sane-port:ALL
 * 1) cat /etc/hosts.deny |grep sane

sane-port: 192.168.11.
 * 1) cat /etc/hosts.allow |grep sane

localhost 192.168.11.1/24
 * 1) cat /etc/sane.d/net.conf

192.168.11.1/24
 * 1) cat /etc/sane.d/saned.conf

hpaio
 * 1) cat /etc/sane.d/dll.d/hplip

hpaio net
 * 1) cat /etc/sane.d/dll.conf

Kernel 2.4 (MIPSel)
apt-get install hotplug autofs usb-utils usbview

Note: If usb-utils doesn't work, try usbutils.

autofs is for file system recognising and hotplug for usb detection is necessary. Usb-utils gives us the lsusb tool for detecting connections and usbview is a gui showing connected devices. Create a mount directory in preparation: I did /mnt/UsbDrive but one can make one in /home/username/. A symlink to the directory you chose as mount point from a directory that you already share through samba should allow it to share (unless you've modified samba to prevent this).

'''Note: This is for brief usb disk mounting. For repetitive use go straight to the Automount section since this work very well especially with kernel 2.6. All usb devices can need reboots with 2.4.17, but this is due to the kernel only.

mkdir /mnt/UsbDrive

Might be worth a chmod permissions modification if you want to share it with samba or use for backups (haven't used it too much yet).

mount -t vfat /dev/sda /mnt/UsbDrive

Of course, replace vfat for whatever your partition type is.

USB Removable Media: Automount
Note to kernel 2.4.17_mvl21-sandpoint #997 users (ships with Freelink 1.1.1): You need to move a few modules out of the way before you can continue:

mv /lib/modules/2.4.17_mvl21-sandpoint/kernel/drivers/scsi/scsi_mod.o /root/

mv /lib/modules/2.4.17_mvl21-sandpoint/kernel/drivers/scsi/sd_mod.o /root/

mv /lib/modules/2.4.17_mvl21-sandpoint/kernel/drivers/usb/storage/usb-storage.o /root/

Reboot when done.

Note to Linkstation HG users: You may also need to do this; adjust the paths to your needs.

I found this to be the easiest way to automount removable USB devices:

apt-get install autofs gawk wget bzip2 make wget http://myy.helia.fi/~karte/linux/doc/automatic-mounting-autofs-files/mounttero-0.5.tar.bz tar -xjf mounttero-0.5.tar.bz cd mounttero-0.5 make /etc/init.d/autofs restart apt-get remove gawk # this step is optional The devices will be mounted automagically in /mnt/auto/, for example, /mnt/auto/usb/ in case of a typical USB thumb drive, and unmounted automagically after four seconds when unplugged.

Edit /etc/auto.tero and comment out all /dev/hda? entries:


 * 1) hda1 -fstype=auto,nosuid,nodev,user :/dev/hda1


 * 1) hda2 -fstype=auto,nosuid,nodev,user :/dev/hda2


 * 1) hda3 -fstype=auto,nosuid,nodev,user :/dev/hda3


 * 1) hda4 -fstype=auto,nosuid,nodev,user :/dev/hda4

Kernel 2.6 (Power PC)
This will add USB Drive automounting and mount USB drives to /media/usb0,1,2,3 etc. symbolic links in /mnt/share will also be created usb0,usb1,usb2,usb3 so that they will be accessable via your samba share apt-get remove hotplug apt-get install usbmount You should change the lines in /etc/usbmount/usbmount.conf to give you more universal access
 * Line that starts FILESYSTEMS change to FILESYSTEMS="ext3 ext2 vfat"
 * Line that starts MOUNTOPTIONS change to MOUNTOPTIONS="noexec,nodev,noatime"
 * Line that starts FS_MOUNTOPTIONS change to FS_MOUNTOPTIONS="-fstype=vfat,umask=000"

These commands will create symbolic links will be into the shared filespace ( /mnt/share ) ln -s /media/usb0/ /mnt/share ln -s /media/usb1/ /mnt/share ln -s /media/usb2/ /mnt/share ln -s /media/usb3/ /mnt/share

USB Webcam
'''Update June 2006: Please note the availability of modules and the /dev/ entries depends on quite a few factors -e.g. this was originally written based on the 2.4.17 #990 LS1 kernel which had the modules but no /dev/video entries. The 2.4.17 freelink 1.1.1 has /dev/video entries and kernel modules ov511.o, so may work straight off (but I haven't tried! It may still be flakey with 2.4.17..) As of June 2006, freelink 1.1.1 upgraded to 2.6.16.16 (andre's v28?) has the /dev/video since its freelink 1.1.1 again but has no webcam modules -check by drilling down in /lib/modules/2.6.xx/kernel/drivers/ to see if videodev.ko, ov511.ko or ovcamchip.ko are present. '''Update July 06: Andre fixed the lost modules in v41pre2 and newer 2.6 upgrades -it should now have most video drivers in the kernel you could wish for and could be plug and play (not sure about /dev/video). Check if the camera has auto-loaded modules using lsmod (mainly), lsusb and/or usbview.

'''Webcam drivers There are a few types of webcam chip -you may have an ov511 but others may have pre-compiled modules sometime. Find out by plugging into the LS and with lsusb it should tell you in the list of devices. Creative webcams are often ov511, but others: logitech quickcams or Philips could need another driver. See http://webcam-osx.sourceforge.net/cameras/index.php?orderBy=controller for a full list. NB. Many (practically all?) will now be in the new 2.6 kernel (upgrade v41 & on).

Using udev in future, instead of hotplug, can also be possible -this may mean the /dev/video links are automagically assigned, but I have not attempted this on a Linkstation.

'''Original instructions (sometimes still be valid): With 2.4.17 webcams were flakey at times to be discovered if not pulled out/plugged in at the 'right time'. Not clear what the 'right' time is. There may not be any USB entries for dev/video depending on freelink package used so I did a:

cd /dev; ./MAKEDEV -v video

This made some. Loading a gui to see something:

apt-get install gqcam

Now when the webcam didn't discover correctly and when typing command gqcam from a terminal it will complain about no /dev/video present or similar. A reboot with camera plugged in usually solves it but the right solution si to upgrade to 2.6 kernel. I also get reversed RG colour with gqcam and changing it back (there's conf file) messes up the brightness. Other apps that might be tried are: 'xcam' -another alternative viewer, and 'motion' - a command line webcam app to be used as a security motion detector (tried on a PC briefly -seems ok). Should be very simple to make a motion detecting security camera with your debian LS.

Enjoy and please carefully comment if it doesn't work or changes needed.

Originally by downlalaway and edited by frontalot, Myno, andre, mindbender, downlalaway, Thorongil and TcT from linkstationwiki.org