[PLUG] USB Camera problem, encountered and resolved (I think)

David Fleck david.fleck at mchsi.com
Sun Dec 26 19:22:20 UTC 2010


System: OpenSUSE 11.3, 2.6.34.7-0.5-default kernel, 32-bit.

After upgrading to 11.3, I could no longer connect to or download images 
from my Canon PowerShot A520.

The camera would be detected by the kernel:

  Dec 26 10:57:00 grond kernel: [183973.604037] usb 2-1: new full speed USB device using uhci_hcd and address 19
  Dec 26 10:57:00 grond kernel: [183973.768988] usb 2-1: New USB device found, idVendor=04a9, idProduct=30c1
  Dec 26 10:57:00 grond kernel: [183973.768997] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
  Dec 26 10:57:00 grond kernel: [183973.769004] usb 2-1: Product: Canon Digital Camera
  Dec 26 10:57:00 grond kernel: [183973.769009] usb 2-1: Manufacturer: Canon Inc.

and both digikam and gphoto2 could auto-detect the camera.  But when I 
tried to connect to download, digikam gave me a very generic "Could not 
connect to camera. Is it turned on?" sort of error message.

I started digikam from the command line, and that at least gave me a 
useful error message:

  $ digikam
  digikam(16200)/kdecore (KSycoca): Trying to open ksycoca from "/home/dcf/.kde4/cache-grond/ksycoca4"
  "Warning: You do not seem to have the package gstreamer0.10-plugins-good installed.
           Some video features have been disabled."
  Time elapsed: 69 ms
  Time elapsed: 11 ms
[...snip...]
  Model: Time elapsed: 36 ms
  libusb couldn't open USB device /dev/bus/usb/002/012: Permission denied.
  libusb requires write access to USB device nodes.

and sure enough, the permissions on /dev/bus/usb/002/012 were 664 
root:root.

I could do several things here, none of which I liked:

* I could run digikam as root.
* I could add my user to the root group.
* I could, as root, change the permissions on the device node. But 
the nodes are generated dynamically by udevd, and I would have to change 
the permissions every time I plugged in the camera.

Thanks to this thread 
(http://forums.opensuse.org/english/get-help-here/hardware/432915-opensuse-11-2-system-locks-up-when-using-usb-mouse.html), 
I began to have some idea of how to configure udevd. After about an hour 
of man page scanning and examination of existing config files, I created 
my own file,
/etc/udev/rules.d/57-gphoto.rules:

  $ cat 57-gphoto.rules
  # Stolen from:
  # HPLIP udev rules file for HP printer and all-in-one products.
  #
  ACTION!="add", GOTO="canon_rules_end"
  SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GOTO="canon_a520_pid_test"
  SUBSYSTEM!="usb_device", GOTO="canon_rules_end"

  LABEL="canon_a520_pid_test"

  # Check for Canon PowerShot A520
  ATTR{idVendor}=="04a9", ATTR{idProduct}=="30c1", OWNER="root",  GROUP="users", MODE="0666"

  LABEL="canon_rules_end"


I still don't fully understand the udev configuration syntax, but after 
creating the above file and restarting udevd, the dynamically generated 
device nodes had the ownership and permissions I wanted:

  grond:/etc/udev/rules.d # find /dev/bus/usb -exec ls -ld {} \;
  drwxrwxrwx 4 root root 80 Dec 24 07:50 /dev/bus/usb
  drwxrwxrwx 2 root root 80 Dec 26 11:06 /dev/bus/usb/002
  crw-rw-rw- 1 root users 189, 148 Dec 26 11:06 /dev/bus/usb/002/021  <-- camera mounted here
  crwxrwxrwx 1 root root 189, 128 Dec 24 07:50 /dev/bus/usb/002/001
  drwxrwxrwx 2 root root 60 Dec 24 07:50 /dev/bus/usb/001
  crwxrwxrwx 1 root root 189, 0 Dec 24 07:50 /dev/bus/usb/001/001

...and digikam works fine again.

My questions now are, (1) is there a better way to do this, and (2) why 
would this have broken, when before it Just Worked?


--
David Fleck
david.fleck at mchsi.com




More information about the PLUG mailing list