---
layout: post
title: "GPhoto2 fails to connect to Canon EOS 20D"
date: 2015-03-12 18:43:21 +0100
comments: true
categories: 
---

For the past few months, [Digikam](https://www.digikam.org/)
(and the underlying [GPhoto2](http://gphoto.sourceforge.net/) library)
failed to connect to my Canon EOS 20D camera:

```
canon/canon/usb.c           (2): Initializing the (USB) camera.
canon/canon/usb.c           (2): canon_usb_camera_init()
canon/canon/usb.c           (2): canon_usb_identify: USB ID match 0x04a9:0x30eb (model name "Canon:EOS 20D (normal mode)")
gp_context_status           (2): Detected a 'Canon:EOS 20D (normal mode)'.
Detected a 'Canon:EOS 20D (normal mode)'.
gp_port_usb_msg_read        (3): Reading message (request=0xc value=0x55 index=0x0 size=1=0x1)...
gp_port_usb_msg_read        (3): Read 0 = 0x0 out of 1 bytes USB message (request=0xc value=0x55 index=0x0 size=1=0x1) (empty hexdump of empty buffer)
gp_context_error            (0): Could not establish initial contact with camera

*** Error ***              
Could not establish initial contact with camera
gp_port_close               (2): Closing port...
gp_context_error            (0): An error occurred in the io-library ('Unknown error'): No error description available
```

Upgrading various components of my system did not help, so I ended up
suspecting a possible issue with the USB stack, which prompted a
[major OS upgrade]({% post_url 2015-02-18-upgrading-to-freebsd-10-1-release %})
from which I am still slowly recovering.

It turned out that the upgrade did not help. Further investigation and
debugging finally allowed me to zero in on the cause of the problem,
which turned out to be a bug in libgphoto2... which coincidentally
got  [fixed](http://sourceforge.net/p/gphoto/code/15384/)
hours before I identified it on my own.

