Search

Ubuntu 16.04 - Correct GoPro USB access bug

dropcap ubuntu gopro

Under Ubuntu 16.04 Xenial, a nasty bug stops you to mount latest GoPro action cams. 

I discovered this problem while connecting a GoPro Hero Session 4 to my laptop via the USB cable. In Nautilus, the device was showing, but it was showing some weird directories :

  • DCIM_00000001_00000001
  • DCIM_00000001

Both directories were empty.

After some internet search, I realised that this problem seems to occur with few recent models of GoPro action cams.

This short article explains how to solve this problem and to properly mount latest GoPro action cams via USB under Ubuntu 16.04 Xerial. 

It has been tested with a GoPro Hero Session 4 connected on a Ubuntu Gnome 16.04.1 LTS Amd64 laptop.

ubuntu gopro usb bug

The trouble comes from libgphoto2 library version 2.5.9, which is shipped with Ubuntu 16.04.

It is buggy and doesn't handle properly PTP protocol of latest GoPro camera. Bug is referenced in gphoto project as https://github.com/gphoto/libgphoto2/issues/52.  Hopefully, this bug has been corrected in libgphoto2 version 2.5.10.

So, solution to our problem is quite simple : we need to update libgphoto2 to latest version 2.5.10. 

As Ubuntu Xerial is only providing version 2.5.9, we will need to use Yakkety repository where packages are available in version 2.5.10.

Packages can be downloaded from http://packages.ubuntu.com/yakkety/

To respect gphoto dependencies, we need to install 2 packages in this specific order :

  1.  libgphoto2-port12
  2.  libgphoto2-6

To avoid breaking apt database, we won't install the packages, but instead we will unpack then under /opt/libgphoto2 directory and create some symbolic links to these updated libraries.

With this approach, installation process is fully reversible and transparent to apt package management tool.

To install and declare latest libgphoto2 libraries, we just need to download and run this helper script :

Terminal
# wget https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/nautilus/nautilus-xenial-gopro-install.sh
# chmod +x nautilus-xenial-gopro-install.sh
# ./nautilus-xenial-gopro-install.sh --install

nautilus-xenial-gopro-install.sh
#!/usr/bin/env bash
# -------------------------------------------------------------
# Installation of updated gphoto libraries to avoid corrupted DCIM with latest GoPro
#
# Revision history :
#   25/09/2016, V1.0 - Creation by N. Bernaerts
# -------------------------------------------------------------

# -------------------------------------------------------
#   Loop to load arguments
# -------------------------------------------------------

# if no argument, display help
if [ $# -eq 0 ] 
then
  echo "Tool to install libgphoto2 2.5.10 libraries to correct latest GoPro DCIM bug under Xenial."
  echo "Parameters are :"
  echo "  --install       Install and declare the updated library"
  echo "  --remove        Back to original library"
  exit
fi

# loop to retrieve arguments
while test $# -gt 0
do
  case "$1" in
    "--install") MODE="install"; shift; ;;
    "--remove") MODE="remove"; shift; ;;
    *) shift; ;;
   esac
done

# check --install or --remove mode
[ "${MODE}" != "install" -a "${MODE}" != "remove" ] && { echo "Please use --install or --remove"; exit 1; }

# ---------------------------------------------------
#  Cleaning
# ---------------------------------------------------

# remove targeted files and directories 
sudo rm -f /usr/lib/x86_64-linux-gnu/libgphoto2_port.so.12
sudo rm -R /usr/lib/x86_64-linux-gnu/libgphoto2_port/0.12.0
sudo rm -f /usr/lib/x86_64-linux-gnu/libgphoto2.so.6
sudo rm -R /usr/lib/x86_64-linux-gnu/libgphoto2/2.5.10
sudo rm -f /lib/udev/hwdb.d/20-libgphoto2-6.hwdb

# ---------------------------------------------------
#  Installation mode
# ---------------------------------------------------

if [ "${MODE}" = "install" ]
then
  # create /opt/libgphoto2 directory structure
  sudo mkdir --parent /opt/libgphoto2

  # unpack and declare libgphoto2-port12
  wget http://fr.archive.ubuntu.com/ubuntu/pool/main/libg/libgphoto2/libgphoto2-port12_2.5.10-3_amd64.deb
  dpkg --fsys-tarfile libgphoto2-port12_2.5.10-3_amd64.deb | sudo tar xf - -C /opt/libgphoto2
  sudo ln -s /opt/libgphoto2/usr/lib/x86_64-linux-gnu/libgphoto2_port.so.12.0.0 /usr/lib/x86_64-linux-gnu/libgphoto2_port.so.12
  sudo ln -s /opt/libgphoto2/usr/lib/x86_64-linux-gnu/libgphoto2_port/0.12.0 /usr/lib/x86_64-linux-gnu/libgphoto2_port/0.12.0

  # unpack and declare libgphoto2
  wget http://fr.archive.ubuntu.com/ubuntu/pool/main/libg/libgphoto2/libgphoto2-6_2.5.10-3_amd64.deb
  dpkg --fsys-tarfile libgphoto2-6_2.5.10-3_amd64.deb | sudo tar xf - -C /opt/libgphoto2
  sudo ln -s /opt/libgphoto2/usr/lib/x86_64-linux-gnu/libgphoto2.so.6.0.0 /usr/lib/x86_64-linux-gnu/libgphoto2.so.6
  sudo ln -s /opt/libgphoto2/usr/lib/x86_64-linux-gnu/libgphoto2/2.5.10 /usr/lib/x86_64-linux-gnu/libgphoto2/2.5.10
  sudo ln -s /opt/libgphoto2/lib/udev/hwdb.d/20-libgphoto2-6.hwdb /lib/udev/hwdb.d/20-libgphoto2-6.hwdb

  # remove downloaded pacakges
  rm libgphoto2-port12_2.5.10-3_amd64.deb libgphoto2-6_2.5.10-3_amd64.deb

# ---------------------------------------------------
#  Removal mode
# ---------------------------------------------------

elif [ "${MODE}" = "remove" ]
then
  # remove /opt/libgphoto2 directory structure
  sudo rm -R /opt/libgphoto2

  # reinstall original packages
  sudo apt-get install --yes --reinstall libgphoto2-6 libgphoto2-port12
fi

# ---------------------------------------------------
#  Restart services
# ---------------------------------------------------

# update hardware database
sudo udevadm hwdb --update

# restart udev service
sudo service udev restart

Libraries are now updated.

You now need to plug your GoPro or to reboot your computer to get a fully operational USB access to your GoPro action cam.

ubuntu gopro usb ok

 

If, for any reason, you need to reverse to original Xenial libraries, you just need to run :

Terminal
# nautilus-xenial-gopro-install.sh --remove


Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus