Connecting with gphoto2

Introduction

This tutorial is written with the steps I take to get my Canon PowerShot G2 working on Linux. Getting your photos off your Canon could not actually be easier ;-) It is basically a question of doing the correct stuff too.

Notes:

  • There are several HOWTO's floating around on the internet, but they all resort in using hotplug (deamon and configs) to get the system configured. I do not, as I have on my workstation little use for such a daemon, and it's just an extra thing that can go wrong.
  • This tutorial is based on the 2.6.10 Linux kernel. If you are looking for ways to get it working with 2.4.x kernels, check google.
  • This short tutorial is based on Gentoo-Linux, although it should work fine on all Linux systems.

Installation

Kernel

To get the kernel to be able to connect to the camera, you firstly need USB support enabled (built in or modules). What you are looking for is:

Device Drivers -> USB support ->

UHCI HCD (most Intel and VIA) support
USB Mass Storage support
USB Human Interface Device (full HID) support
  HID input layer support

Note: You may require OHCI HCD support instead of UHCI HCD support depending on your hardware. You can check simply by doing:

lspci -v | grep "USB Controller"

which here returns:

0000:00:1f.2 USB Controller: Intel Corp. 82801BA/BAM USB (Hub #1) (rev 01) (prog-if 00 [UHCI])
0000:00:1f.4 USB Controller: Intel Corp. 82801BA/BAM USB (Hub #2) (rev 01) (prog-if 00 [UHCI])

Lastly you (probably?) need hot-pluggable devices enabled. It does no harm to turn it on ;-) This is not directly related to the hotplug daemon (which I already stated we are not going to use):

General setup ->
  Support for hot-pluggable devices

gphoto2

Gphoto2 comes in 2 parts, libgphoto2 and gphoto2. On Gentoo a simple

emerge gphoto2

will do the trick. Either way you do it, you will need both.

fstab

If you don't already have it, you will need to add a line in your /etc/fstab which will state how (and where) the usbfs will get mounted on your system. This is the part that got me initially though, as with recent kernels the name usbfs was changed from usbdevfs. In my /etc/fstab I have the line:

none     /proc/bus/usb     usbfs     user,auto,devmode=0660,devgid=85     0 0

This is a little neat trick to avoid using hotplug to set the default permissions of connected USB devices. What it basically does it state that new USB devices (which are of course detected) get mounted into /proc/bus/usb with -rw-rw---- permissions (devmode=0660). The devgid=85 assigns the group #85 (in my /etc/group this is the USB group, to which I manually add users who are allowed to use USB) to these devices, giving me mounted devices with root:usb ownership.

Reboot

If you did reinstall your kernel, or have to change your /etc/fstab, then you had better reboot. Fstab entries will need to be refreshed totally, and the chances are you are running other USB devices already (mouse?), so it cannot be remounted. A new kernel speaks for itself ;-)

Testing

Right, we are basically ready to test. Open a console, log in as root: we are going to check if your computer recognises your camera when we turn it on in a few secs.

tail -f /var/log/messages

Plug in your camera via the USB cable, and turn it on. In your console where we are following changes to your system messages, you should get something like this appearing:

Dec 31 16:49:12 localhost kernel: usb 2-1: new full speed USB device using uhci_hcd and address 5

If it's not the same, don't worry. What we are looking for is recognition that something was connected.

Via the command lsusb we should get output directly relating to your camera:

Bus 002 Device 005: ID 04a9:3055 Canon, Inc. PowerShot G2
Bus 002 Device 002: ID 046d:c00b Logitech, Inc. MouseMan Wheel
Bus 002 Device 001: ID 0000:0000  
Bus 001 Device 001: ID 0000:0000

Ok, we seem set (I hope), and now we can test.

First, as root (you can cancell the tail of the log now if all went well ~ CTRL-c), we will run gphoto2 -l* to see if:

  • the camera is auto-detected
  • it has read/write functions (needed) from the USB device
  • if it works ;-)
# gphoto2 -l
Detected a 'Canon:PowerShot G2'.                                               
There is one folder in folder '/':
 - DCIM
There are 3 folders in folder '/DCIM':
 - 109CANON
 - 110CANON
 - CANONMSC
There are no folders in folder '/DCIM/109CANON'.
There are no folders in folder '/DCIM/110CANON'.
There are no folders in folder '/DCIM/CANONMSC'.

If this has all worked out fine, then you can try as a normal user (who of course has already been added into the USB group like I mentioned earlier before logging in, right?). The user should have no problems either with this. If he does, please check the tutorial again, and check permissions in /proc/usb/*/*

Gtkam (GTK frontend)

With all of the above working, we can install gtkam for a user-friendly graphical interface for our camera. Gtkam is the official GTK2 GUI for libgphoto2.

It is easy to use, and provides more than enough features for what we need it for. It is not KDE or Gnome dependent either, which is why I use it in preference to other software.

Links


User Comments