Linux – How to copy files *to* a camera

arch linuxcamerafile-copyfilesgvfs

I'd like to copy a firmware update file to my Canon 7D camera, connected via USB.

After it was auto-mounted by thunar + thunar-volman + gvfs-gphoto2 I tried the following:

$ cp eos7d-v205-win/7D000205.FIR /run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A001%2C012%5D/
$ echo $?
0
$ ls /run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A001%2C012%5D/
DCIM  MISC

So that went into a black hole.


The first time I try to copy it with Ctrlc and Ctrlv prints the following error message when pasting the file:

Error writing file.

-108: No such file or directory.

Do you want to skip it?

If I try again after that it simply crashes:

$ thunar
Segmentation fault (core dumped)
$ echo $?
139

The Gphoto 2 shell has an undocumented put function which I also tried:

$ sudo umount /run/user/1000/gvfs
$ gphoto2 --shell
gphoto2: {.../eos7d-v205-win} /> help put
Help on "put":

Usage: put [directory/]filename
Description:
        Upload a file

* Arguments in brackets [] are optional

So this function takes a single argument with an optional directory. Weird, but should be doable. Some attempts at making it work:

$ gphoto2 --shell
gphoto2: {.../eos7d-v205-win} /> ls
store_00010001/     
gphoto2: {.../eos7d-v205-win} /> put 7D000205.FIR                       

*** Error ***              
You need to specify a folder starting with /store_xxxxxxxxx/
*** Error (-1: 'Unspecified error') ***
gphoto2: {.../eos7d-v205-win} /> put /store_00010001/7D000205.FIR

*** Error ***              
PTP Access Denied
*** Error (-1: 'Unspecified error') ***
gphoto2: {.../eos7d-v205-win} /> put /store_00010001/MISC/7D000205.FIR

*** Error ***              
PTP Access Denied
*** Error (-1: 'Unspecified error') ***

Maybe it's not supported?


Digikam has an upload feature, but that just reported 'Failed to upload file "7D000205.FIR".' Running it from the shell produced no more information.


man gvfs-copy doesn't explicitly say it can't copy to a camera, but I can't figure out how:

$ gvfs-copy "file://${HOME}/7D000203.FIR" /run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A004%2C006%5D/
Error copying file file:///[...]/7D000203.FIR: Error writing file: -1: Unspecified error
$ gvfs-copy "file://${HOME}/7D000203.FIR" file:///run/user/1000/gvfs/gphoto2\:host\=%5Busb%3A004%2C006%5D/
Error copying file file:///[...]/7D000203.FIR: Error opening file '/run/user/1000/gvfs/gphoto2:host=[usb:004,006]': No such file or directory
$ gvfs-copy "file://${HOME}/7D000203.FIR" gphoto2://host\=%5Busb%3A004%2C006%5D/
Error copying file file:///[...]/7D000203.FIR: The specified location is not mounted

gphoto2 says it should be possible to upload files to the camera:

$ gphoto2 --port usb: --abilities
Abilities for camera             : Canon EOS 7D                                
Serial port support              : no
USB support                      : yes
Capture choices                  :
                                 : Image
                                 : Preview
Configuration support            : yes
Delete selected files on camera  : yes
Delete all files on camera       : no
File preview (thumbnail) support : yes
File upload support              : yes

The gphoto2 manual says it supports "uploading" files. It doesn't work. Trying a command reported as working elsewhere:

$ gphoto2 --upload-file 7D000203.FIR --folder /store_00010001
*** Error ***              
PTP Access Denied
*** Error (-1: 'Unspecified error') ***       

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel@lists.sourceforge.net>, please run
gphoto2 as follows:

    env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --upload-file 7D000203.FIR --folder /store_00010001

Please make sure there is sufficient quoting around the arguments.

After trying the debug command I get the following relevant log lines:

ptp_usb_getresp [usb.c:434] (0): PTP_OC 0x100c receiving resp failed: PTP Access Denied (0x200f)
put_file_func [library.c:5940](0): 'ptp_sendobjectinfo (params, &storage, &parent, &handle, &oi)' failed: 'PTP Access Denied' (0x200f)
gp_context_error            (0): PTP Access Denied
gp_camera_folder_put_file [gphoto2-camera.c:1248](0): 'gp_filesystem_put_file (camera->fs, folder, filename, type, file, context)' failed: -1
gp_camera_free              (2): Freeing camera...
gp_camera_exit              (2): Exiting camera ('Canon EOS 7D')...
ptp_usb_sendreq             (2): Sending PTP_OC 0x1003 / Close session request...
gp_port_write               (3): Writing 12 = 0xc bytes to port...
gp_port_write               (3): Wrote   12 = 0xc bytes to port: (hexdump of 12 bytes)
 0c 00 00 00 01 00 03 10-0c 00 00 00              ............    

Too many WTFs per minute. What do I need to do to copy a file to my camera in Arch Linux?

In case it's relevant: I tried copying the file on Windows 7, and it also fails:

You do not have permission to create this item.

Best Answer

I'm not sure you will like this answer, but, in my experience too, using PTP has always caused a high WTF/min. Presumably the camera itself restricts writing in the root folder, or something equally sensical.

I would suggest getting your hands on a CompactFlash reader, mounting the filesystem directly, and using that type of access to copy your firmware file to the card's root folder (e.g., mount /dev/sdc1 /mnt/camera and then cp eos7d-v205-win/7D000205.FIR /mnt/camera/).

I've found card readers to feel a whole lot faster than PTP, presumably because the former can benefit from your computer's filesystem read-ahead capabilities, while PTP doesn't, so I consider them a worthy (and small) expense.

Related Question