I have an Epson Stylus CX3200 USB printer/scanner combo. Am using 2.6.6-rc3 kernel, Slackware 9.1 with SANE, CUPS, and libusb. The scanning and printing is fine. What isn't fine is the USB. Users need write permission on the scanner, but the default is read only (wonder if I can do a dirty kernel hack and just make all USB devices be 0666?), and after following the instructions in SANE's tools/hotplug/README, I haven't been able to get the hotplug scripts to set the permissions.
Worse tho is that each time I turn the printer/scanner off and back on, the scanner appears as the next number up in /proc/bus/usb/001. If the scanner was /proc/bus/usb/001/002 and then I turn the printer/scanner off and on, the scanner will be /proc/bus/usb/001/003. That breaks the SANE configuration and the hotplug scripts (well, I haven't got them working anyway and don't know why), so, what to do? Uncommented the DEBUG lines in the hotplug scripts, but am not seeing anything from /etc/hotplug/usb.agent. Seems like 2 problems. First, don't think the file names in /proc should change. 2nd, what is wrong with hotplug?
ls -l /proc/bus/usb/001
-rw-r--r-- 1 root root 43 May 4 23:55 001
-rw-r--r-- 1 root root 73 May 5 00:51 005
May 4 23:55:57 concrete kernel: uhci_hcd 0000:00:04.2: Intel Corp. 82371AB/EB/MB PIIX4 USB
May 4 23:55:57 concrete kernel: uhci_hcd 0000:00:04.2: irq 9, io base 0000d400
May 4 23:55:57 concrete kernel: uhci_hcd 0000:00:04.2: new USB bus registered, assigned bus number 1
May 4 23:55:57 concrete kernel: hub 1-0:1.0: USB hub found
May 4 23:55:57 concrete kernel: hub 1-0:1.0: 2 ports detected
May 4 23:55:57 concrete kernel: usb 1-2: new full speed USB device using address 2
May 4 23:56:07 concrete kernel: PCI: Found IRQ 9 for device 0000:00:09.0
May 4 23:56:07 concrete kernel: PCI: Sharing IRQ 9 with 0000:00:04.2
May 4 23:56:07 concrete kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 2 if 1 alt 0 proto 2 vid 0x04B8 pid 0x0802
May 4 23:56:07 concrete kernel: usbcore: registered new driver usblp
May 4 23:56:07 concrete kernel: drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
May 5 00:04:33 concrete kernel: usb 1-2: USB disconnect, address 2
May 5 00:04:33 concrete kernel: drivers/usb/class/usblp.c: usblp0: removed
May 5 00:04:33 concrete default.hotplug[1129]: arguments (usb) env (OLDPWD=/ DEVPATH=/class/usb/lp0 PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=remove PWD=/etc/hotplug HOME=/ SHLVL=2 DEBUG=yes SEQNUM=183 _=/usr/bin/env)
May 5 00:04:33 concrete default.hotplug[1129]: invoke /etc/hotplug/usb.agent ()
May 5 00:06:19 concrete kernel: usb 1-2: new full speed USB device using address 3
May 5 00:06:19 concrete kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 3 if 1 alt 0 proto 2 vid 0x04B8 pid 0x0802
May 5 00:06:19 concrete default.hotplug[1145]: arguments (usb) env (OLDPWD=/ DEVPATH=/class/usb/lp0 PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=add PWD=/etc/hotplug HOME=/ SHLVL=2 DEBUG=yes SEQNUM=189 _=/usr/bin/env)
May 5 00:06:19 concrete default.hotplug[1145]: invoke /etc/hotplug/usb.agent ()
RE: USB scanner/printer hotplug annoyance
I'm trying to figure this stuff out, too. I believe the problem is with the transition to UDEV from DEVFS. The incrementing /proc entries may be due to an attempt to eliminate possible security issues with race conditions created by putting the code into userland.
UDEV isn't ready for prime time. Downgrade to 2.6.3 or below. That's my best advice. BTW I don't really know what I'm talking about, but look into it. I suspect that this is the issue.
UDEV doesn't create modprobe events when devices are accessed either, BTW.
-Cheers
kernel hack for read-only USB scanner
I tried the dirty kernel hack I mentioned. It worked. No more messing around with hotplug.
linux-2.6.6-rc3/drivers/usb/host/uhci-hcd.c line 2062:
change S_IWUSR to S_IWUGO
Security can't be allowed to stand in the way of functionality.
Now, the incrementing /proc entry problem workaround I have is (sigh) reboot, just like you'd have to do in Windows.
my bad, and another USB scanner prob
The permissions changed but not because of that kernel hack. The hotplug script started working. Believe hotplug didn't work the first time because I did not do a "make modules_install". Then hotplug started working after I did "make modules_install" for my kernel hack (since uhci is a module in my configuration) and I thought the permissions were set right because my hack worked. Nope. Well, at least in 2.6 you don't have to do "make dep;make bzImage" just "make".
Have another USB scanner problem. Sometimes scanimage hangs and the printer/scanner displays a message on its LCD "warming up". Along with the warm up message is a little animation which has been different each time, once the text characters "-\|/" tumbling underneath, once a wave of different hieght blocks, and so on. Once scanimage came back with some kind of timeout error. Mostly I got tired of waiting for something to happen, and reset the scanner and kill -9 the scanimage process. Not sure how to get more useful error messages. SANE problem? Or uhci problem? Or something else?
any luck on solving the scanning problem above?
Hi - I'm running into the same scanning problem with the warmup message. Have you had any luck in solving it?
Thanks,
Ryan
maybe this will help you
First I'm sorry by my english.
That's I do and It works fine or I think so. Maybe it will be able to help you.
I have a Canon N650U, 0x04a9 Vendor and 0x2206 ProductID so first I've installed sane and edit /etc/sane.d/plustek.conf:
[usb] 0x04a9 0x2206
device auto
If you have another scanner you can see if USB is working fine with a cat /proc/bus/usb/devices where you can see vendor and productID as the Bus Number and Dev# number so scanner is in /proc/bus/usb/BUS/DEV#
The most important thing that you have to do is create or edit next two files in /etc/hotplug/usb:
libsane.usermap:
# Canon Inc.|CanoScan N650U
libusbscanner 0x0003 0x04a9 0x2206 0x0000 0x0000
0x00 0x00 0x00 0x00 0x00
0x00 0x00000000
this line have to be pressent
libusbscanner:
#!/bin/sh
# This file is 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 users in the scanner group.
#
# Ownership is set to root:scanner, permissions are set to 0660.
#
# Arguments :
# -----------
# ACTION=[add|remove]
# DEVICE=/proc/bus/usb/BBB/DDD
# TYPE=usb
# latest hotplug doesn't set DEVICE on 2.6.x kernels
if [ -z "$DEVICE" ] ; then
IF=`echo $DEVPATH | sed 's/\(bus\/usb\/devices\/\)\(.*\)-\(.*\)/\2/'`
DEV=`echo $DEVPATH | sed 's/\(bus\/usb\/devices\/\)\(.*\)-\(.*\)/\3/'`
DEV=`expr $DEV + 1`
DEVICE=`printf '/proc/bus/usb/%.03d/%.03d' $IF $DEV`
fi
if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then
chown root:scanner "$DEVICE"
chmod 0660 "$DEVICE"
fi
# That's an insecure but simple alternative
# Everyone has access to the scanner
# if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then
# chmod 0666 "$DEVICE"
# fi
with this two files when you attach a scanner to usb port hotplug give access to it to root and scanner group throught /proc/bus/usb/bus/dev# file so you only have to add users that you wish use scanner to scanner group with the below command:
adduser user scanner
when reboot machine user will be able to use scanner
don't forget to install hotplug !!!
that could be the source of many usb scanner permissions problems when using it through libusb.
for example i'm using sane/xsane, as my linus distribution is gentoo, i have "emerged" sane and xsane but it was working as root only.
i've tried everything (/proc/bus/usb permissions, groups, libusbscanner script modification) but nothing saves me until i "emerge" hotplug !!!
cause libusbscanner script is in /etc/hotplug/usb/ and accessed only if u have hotplug....
Possible fix
I had a similar problem with a Canon Pixma MP160 scanner/printer. After some trouble, I got it to work with TurboPrint and a patch to SANE, but it would only scan while logged in as root. Changing the permissions on /dev/usb/lp0, which was used for the printer, had no effect on the scanner. I have a /proc/bus/usb directory, but it is empty. Adding write permission by hand to /dev/bus/usb/001/002 let me scan as a normal user. Looking in /etc/udev/rules.d/50-udev.rules I found the line responsible for setting this permission:
SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", NAME="%c", MODE="0644"
and changed it to:
SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev}; printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'", NAME="%c", GROUP="usb", MODE="0664"
Then I added a couple users to the "usb" group and everything works fine, even after the printer/scanner gets a new device number.