I really want to use gphoto2 on a Raspberry Pi to control a DSLR, but unfortunately I’m plagued by this USB issue that everyone is talking about. Here is just one the many posts related to the topic.   I know many people will immediately suspect a power issue, but I assure you my power supply is providing the Pi with 5.02V (TP1/2) and can supply up to 3A.  After much work, I think I’ve figured out a work-around.  The solution is this:  upgrade to the latest 3.6.x kernel, scrap gphoto2, and use libgphoto2 instead.

When you issue a command like “–capture-image-and-download” to gphoto2, it “opens” the camera, takes the picture, then “closes” the camera.  I read somewhere that the USB issue is caused by, “repeated acquisition of the USB device”, or something to that effect.  So, instead of using gphoto2 and doing this:

open/action/close, open/action/close

Use libgphoto2 and your own program to do this:

open/action/action/action/action…./action/close

Update Raspberry Pi

Assuming your Pi is up and running Raspbian Wheezy, run “sudo apt-get update; sudo apt-get upgrade” to update all packages.  While you’re at it you may want to “sudo apt-get install libgphoto2-2”.

Next, download and install the rpi-update tool.  By default it will install the latest kernel from the current/master branch.  To install from the rpi-3.6.y branch, run “sudo rpi-update next”.  Note, this only seems to work for my DSLR – the webcam I’m trying to use as well still crashes (but that’s a problem for another day, and no, it’s not a power issue).

Replace gphoto2

If you’re not too interested in writing your own software, here is an example C program that takes 10 shots in a row using libgphoto2.  If, like me, you prefer Java, then give libgphoto2-jna a try.

Tagged with →  
Share →

3 Responses to How To Work-Around gphoto2 USB Issues on Raspberry Pi

  1. ae:
    Brilliant thinking this! I have been frustrated by the issues and had not dug deep enough to see what was going on under the surface. I still get failures after an unpredictable number of iterations of grabbing a preview and then a full size image but I am hoping that I can insert a USB reset at the point of error and retry with success. In any case a giant leap forward.
    Thanks, Will

  2. […] a Bash script, a C/C++ application, or with Java using the libgphoto2-jna library.  Due to known issues running gphoto2 on the Raspberry Pi, my preferred technique is to use […]

  3. […] is apparently a known issue, and may have to do with Raspberry Pi device support, though it also looks like this gphoto issue. […]

Leave a Reply

Your email address will not be published. Required fields are marked *