by rupe

How do I get my USB digital camera to work under Linux?

You'll need a kernel that includes USB support. The original kernel USB stack was introduced in kernel v2.2.7, however current USB development is being done in the 2.4 kernel tree. I just grabbed the latest stable kernel (2.4.13 at time of writing) from http://www.kernel.org.

Check the Linux-USB guide for detailed kernel configuration steps.
Once you have the kernel compiled to your liking, reboot, and look for USB-related messages during initialization. Make sure that you compile in the USB Development Filesystem (usbdevfs)! You can check to make sure that the USB support is working correctly by doing:

tail -f /var/log/messages,

and plugging in, then powering up your USB device. You should get output that looks something like:

ct 29 15:39:57 ucbvax kernel: hub.c: USB new device connect on bus1/1, assigned device number 2
Oct 29 15:39:57 ucbvax kernel: usb.c: USB device 2 (vend/prod 0x84e/0x1) is not claimed by any active driver.


USB device and driver information is contained within a usbdevfs format filesystem, similar to the /proc fs. It's customarily mounted at /proc/bus/usb. Mount it manually by doing mount -t usbdevfs /proc/bus/usb, or add the following line to your /etc/fstab file:

none	/proc/bus/usb	usbdevfs	defaults	0	0


Once it's mounted, you'll see two files (devices, drivers) and a directory, usually named 001. 001 is the device number for the 'virtual root hub', to which all other devices (including hardware USB hubs), attach. If you have a powered on USB device attached, try doing a cat /proc/bus/usb/devices, and you should see an entry for both your virtual root hub, and the device that you have plugged in, in this case a KBGear JamCam digital camera:

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Product=USB UHCI-alt Root Hub
S:  SerialNumber=dce0
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=ff(vend.) Sub=01 Prot=ff MxPS= 8 #Cfgs=  1
P:  Vendor=084e ProdID=0001 Rev= 1.00
S:  Manufacturer=KBGear Interactive
S:  Product=JamCam    
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=01 Prot=00 Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS=   8 Ivl=255ms


The device entry will disappear when you unplug the device.

Now that devices are being detected, it's time to grab some additional software in order to retrieve pictures from the camera. gPhoto supports 114+ cameras, with some exceptions, and I recommend it. Get the beta2 version (gphoto-2.0beta2.tar.gz)In order to get it to compile, you'll need to compile and install libusb first. You need this even though USB support is in your kernel already.

Once libusb is installed, compile and install gPhoto following the instructions provided (./configure, make, make install). One problem I found was that USB support didn't make it into the installation the first time through. In order to rectify the problem, I did a (make distclean, ./configure, make all, make install), and that seemed to fix things.

gPhoto2 is a command line tool, and the documentation leaves a lot to be desired. After installation, check for USB support by doing gphoto2 --list-ports. The output should be along the lines of:

Devices found: 5
Path                             Description
--------------------------------------------------------------
serial:/dev/ttyS0                Serial Port 0                   
serial:/dev/ttyS1                Serial Port 1                   
serial:/dev/ttyS2                Serial Port 2                   
serial:/dev/ttyS3                Serial Port 3                   
usb:                             Universal Serial Bus 


You can do gphoto2 --list-cameras to see the list of supported cameras. Find the name of your camera, according to gphoto2. Now comes the exciting part, retrieving images. Go into the directory that you wish to download images to, and type gphoto2 --camera "camera name" --port usb: -P, where "camera name" represents the name of your camera. E.g, for the KBGear JamCam, you'd do gphoto2 --camera "KBGear JamCam v3.0" --port usb: -P. At this point the camera should begin downloading images into the directory.

Common problems

If you see a message like 'Unknown port' from gphoto2, it either means that you typed the port argument (--port usb: ) incorrectly, or that gphoto2's USB support didn't make it into a compile somehow (if there's no mention of USB when doing gphoto2 --list-ports, above, this is your problem). Try the alternate installation steps for gphoto2 above, and give it another go.

The error message gPhoto2 reported the error 'Could not find the requested device on the USB port' typically means that the USB camera isn't turned on, or plugged in.

If you see the following errors:

gp_port_usb_open: could not claim intf 0: Operation not permitted
gp_port_usb_update: could not set config 0/1: Operation not permitted
gp_port_usb_close: could not release interface 0: Operation not permitted
gPhoto2 reported the error 'Error updating the port settings'


It generally means that you need to alter the permissions of your USB device entry. Try su -c 'chmod a+w /proc/bus/usb/001/002', where 002 is the device number of your USB camera. This number is easy to find out, just ls /proc/bus/usb/001, and look for the non-001 entry! An even easier way to do this is to grab the USB permissions daemon, install it, and let it do the dirty work for you...

Everything should be working at this point :-). Good luck!

 


 
Read more of   The Yak's Frequently Questioned Answers   (mod.2010-02-10)

431.   What is meant when someone says that something was "Steved?"   [jake/2006-05-21]
413.   How can I solve Cisco Catalyst 3550 series issues where a port seems to have died?   [jake/2004-08-23]
401.   What is the Fly Over Zone?   [jake/2004-01-28]
384.   Where can I find good undergraduate summer research/internships?   [virgil/2003-10-03]
328.   What the hell is zen nihlism (how can I sign up my neighbor)?   [jake/2002-10-05]
321.   what is jesse's first rule of backpacking?   [jesse/2002-08-13]
276.   What is the recipe for Soylent Green yak drink?   [blink/2001-10-02] ( macki/2001-11-05 )
252.   How can I turn an Indigo into an apache based webcam?   [vonguard/2001-06-29]
247.   what must be done to make javax.comm work with devFS?   [jesse/2001-06-09]
242.   What bugs exist in the Nokia 7190 firmware?   [rupe/2001-07-17]
146.   What commands do UNIX system administrators commonly use?   [rupe/2000-11-09] ( strick/2001-01-04 )
134.   What are some useful commands for using the SGI VINO video option?   [rupe/2000-10-08]
131.   What does Jesse do to anything after a fresh linux install?   [jesse/2000-10-08]
129.   What do all the diferent colors of manic panic hair dye look like?   [jesse/2000-10-07]
119.   What is a clitoris?   [n0b0dy/2000-09-14] ( strick/2003-04-02 )
114.   Where's a good place to find advice about 401(k) plans?   [rupe/2000-08-07]
108.   How can i get custom ring tones onto my cell phone?   [jesse/2000-07-09]
103.   Where can I find information on how much I'm worth?   [rupe/2000-06-17]
91.   Should the answer to an FQA consist entirely of an external link?   [macki/2000-05-06] ( strick/2002-01-23 )
89.   What is the connecton between Karl Marx, Cinco de Mayo, and salsa?   [strick/2000-05-05]
87.   How do i OPT OUT of doubleclick's user-tracking cookies?   [strick/2000-05-11]
75.   Where can I get an Isreali standard issue military gas mask for under $30.00 US?   [simon/2000-04-05]
69.   What is the origin of The Yak?   [strick/2000-02-28]
34.   What are some good World Wide Web facts I can impress my friends with?   [simon/2000-01-28]
33.   What is 'netpbm' ?   [strick/2000-01-26]