Kodak CX4230 and Linux

My first attempts at connecting this camera to the Linux box started by making a lot of searches on the Internet, and not a single search showed up with the Kodak CX series and Linux on the same page. I can only assume that this means not a lot of people has tried that before. Because of this, I decided to write a few lines about how I finally got it all to work, and you are currently reading that short page on how to get it to work.

I recently found out about the http://ptp.sourceforge.net homepage as well. According to this site, all Kodak cameras that runs with EasyShare! should also work with the PTP subsystem. I assume that these instructions may in other words work perfectly well with all of those cameras as well. Do note that there are a lot of bugs and gotcha’s in the current PTP implementations for Linux in my experience, sadly, but we can only hope most of the big problems will be gone in a couple of months. The more people that tests the code, the faster the developers will find the problems..

Unfortunately, the jPhoto package requires a working and recent java (didn’t work with JDK-1.1 in Debian among others) installation. This may become a problem with Debian and Slackware to my knowledge, and I never got it to run under Debian. jPhoto runs like a charm on Red Hat however. For Debian however, gPhoto2 seems to work much better, but gPhoto2 must be in a recent version, as well as the libusb package. Hence, you need to make a source installation of both of these packages as of 2002-11-28, to make gPhoto2 work with Debian to my knowledge.

Compatibility of this document

This document has been reported to work with the following OS’s and Kodak cameras in combination

  • Kodak CX4230
    • Debian 3.0r0
    • Debian 3.0r1
    • Debian 3.1
    • Redhat 7.1
    • Redhat 7.3
    • Redhat 8.0
    • Redhat 9.0
    • Slackware 8.0
    • Slackware 9.0
    • Slackware 9.1
    • SuSE 7.0(?)
  • Kodak CX4330
    • Redhat 8.0
    • Slackware 8.0
  • Kodak CX6330
    • Slackware 9.1
  • Kodak CX7300
    • Slackware 10.0

If you find another camera/distribution combination where this works, please report this to me!

Requirements

The CX4230 camera uses an USB connection to the computer, and uses something called PTP, which is a protocol for transferring image data over USB cables. This also specifies all of the commands that can be used over the PTP connection, etcetera. Hence, what we need to set up the CX4230 camera is the following:

  • USB jack on the computer
  • USB support in Linux kernel
  • Usbdevfs support in Linux kernel (required by jPhoto)
  • Hotplug program suite (most distributions have this per default)
  • PTP program suite (I’ve chosen to go with jPhoto)

As you can see, it doesn’t require too much really. One of the funny things with hotplug is that we have the ability to make the camera automatically sync with your computer, and uploading all of the pictures automatically. This idea was pretty much taken from the jPhoto homepage, but modified a little bit (see the jPhoto page).

Checking the USB installation

Before you do anything else, you may want to check that the USB jack, drivers and usbdevfs are actually working. The simple way of doing the first check, is to do the following:

[blueflux@work1 ]$ ls /proc/bus/usb/
001  002  devices  drivers
[blueflux@work1 ]$

If you get any listing from the /proc/bus/usb directory that contains files, you are most probably set. If you don’t, start out by checking that the usbdevfs is actually mounted properly. Personally, I added the following line to /etc/fstab and “it works”:

none                    /proc/bus/usb           usbdevfs defaults,auto  0 0

Second after this, check to see if all of the USB driver stuff was actually loaded during boot-up. If they are loaded as modules, you can simply lsmod and check that you got all of the appropriate modules loaded, such as this:

[blueflux@work1 ]$ /sbin/lsmod
Module                  Size  Used by    Tainted: P
....
usb-uhci               24452   0 (unused)
usbcore                73216   1 [usb-uhci]
....
[blueflux@work1 ]$

You should in other words first of all see the usbcore module loaded, and except that one you should see something like usb-uhci, usb-ohci, uhci or ohci. The uhci driver is used on all Intel and VIA created machines, while a lot of others uses the ohci standard, hence the difference. If you need to see which module to use, check out the information at the Linux USB project.

If the modules where not properly loaded, I suggest that you either load them manually using modprobe or insmod. You may also in such case consider loading the modules automatically each time the computer is started by adding the appropriate lines to your /etc/rc.d/ system, or /etc/modules.conf.

Note that the above list of possible problems and corrections is just a list of a very very few problems that I ran into, and will most likely not be totally accurate, nor complete in any way. However, you should at least get some help from this.

Install & test jPhoto

To my knowledge, jPhoto only works properly with a proper and recent JDK installation, even though it claims to work with JDK 1.1, that is not what I experienced. I did try this package on red hat, and it work directly out of the box, but not on Debian or Slackware. If you want to get your PTP camera to work on those distributions, I suggest checking further down at the gPhoto2 instructions. If you feel secure enough in the Java-land, you are more than welcome to try this out on Debian and Slackware as well, but you are on your own there. If you do get it to work, and there are no problems, let me know since I really want to know what I did wrong.

If everything seems to work so far, you are probably ready to grab the jPhoto program suite over at the jPhoto homepage. Download the package and go through all of the installation instructions.

Now, you may connect the camera to the USB port via the USB cable, and turn the power on. The second step is to simply run the following command and see if jPhoto program recognizes the camera:

[blueflux@work1 ]$ sudo jphoto cameras
usb-d400-2      KODAK EasyShare CX4230 Zoom Digital Camera
[blueflux@work1 ]$ su

Note that I have chosen to actually add this program to sudo for my local user, otherwise you will have to be logged in as root to get read/write access the /proc/bus/usb files, which is necessary.

The second step if you got this to work, is to actually test and download the pictures on the camera. The simple way of doing this, is to do as follows:

[blueflux@work1 ]$ sudo jphoto images -c usb-d400-2
PTP device at usb-d400-2
STORE: 0
DCIM; GenericFolder
    100K4230; GenericFolder
        images/100_0041.jpg image saved, size 710506
        images/100_0042.jpg image saved, size 754500
        images/100_0043.jpg image saved, size 669638
        images/100_0044.jpg image saved, size 741876
        images/100_0045.jpg image saved, size 697294
        images/100_0046.jpg image saved, size 751124
        images/100_0047.jpg image saved, size 763261
        images/100_0048.jpg image saved, size 733786
        images/100_0049.jpg image saved, size 672478
        images/100_0050.jpg image saved, size 723771
        images/100_0051.jpg image saved, size 765761
MISC; GenericFolder
SYSTEM; GenericFolder
STORE: 1
[blueflux@work1 ]$

This command tells jPhoto to download all images from the camera specified with the -c option. Note that the value provided to the -c variable is listed in the jPhoto cameras command. All images will then be downloaded into the directory called images, in the same directory as you are located.

Install & test gPhoto2

If you are running Debian or Slackware, or any other distribution without a good JDK installation, I suggest that you look at this section. If you are running Red hat on the other hand, you should check the jPhoto installation instructions firstly instead.

Debian has both gPhoto2 and libusb (required by gPhoto2 to work with USB) available as deb-packages. However, both of these packages are unfortunately too old to run properly with the PTP camera that I have tested. Note, this is only my experience and your mileage may vary. Because of this, I suggest that you remove both packages, and grab the latest sources from the libusb homepage as well as from the gPhoto2 homepage. Install them, starting with libusb, according to their installation notes.

When finished installing, run gphoto2 –auto-detect to find the cameras attached to all supported connectors. This is the output from when I ran the command, and having my Kodak CX-4230 camera connected.

blueflux@work1:~$ gphoto2 --auto-detect
Model                          Port
----------------------------------------------------------
USB PTP Class Camera           usb:
blueflux@work1:~$

Derived from this information, and the help of the gphoto2 help output, we try to run the following command and download the images:

blueflux@work1:~$ gphoto2 --port "usb:" --camera "USB PTP Class Camera" -P
Downloading 'AUTPRINT.MRK' from folder '/store_00010001/MISC'...
Saving file as AUTPRINT.MRK
Downloading 'AUTXFER.MRK' from folder '/store_00010001/MISC'...
Saving file as AUTXFER.MRK
Downloading 'FAVORITE.MRK' from folder '/store_00010001/MISC'...
Saving file as FAVORITE.MRK
Downloading 'DCEMAIL.ABK' from folder '/store_00020001'...
Saving file as DCEMAIL.ABK
Downloading 'EMAILTAG.MRK' from folder '/store_00020001'...
Saving file as EMAILTAG.MRK
Downloading 'FAVORTAG.MRK' from folder '/store_00020001'...
Saving file as FAVORTAG.MRK
Downloading 'PRINTTAG.MRK' from folder '/store_00020001'...
Saving file as PRINTTAG.MRK
blueflux@work1:~$

All images will then be downloaded from the camera to your current directory. I have also written a small script for doing the downloading to a dated directory structure to keep them in good chronical order. The script can be run from the hotplug system, and it actually works for me. To run it automatically, you need to add the following line to the /etc/hotplug/usb.usermap file:

kodak-cx4230 0x03 0x040a 0x0535 0 0 0 0 0 0 0 0 0

This configuration line is Kodak CX-4230 specific, so you will need to figure out your own specifics. (Tip, check the output from /var/log/messages when you connect the camera). Basically, it says that if a device is connected to one of the USB ports with a specific Product-ID and Vendor-ID (specified by the hex numbers), it should run the script kodak-cx4230 which needs to have execute permissions. The kodak-cx4230 script should be put in the usb directory, directly under the hotplug configuration root (/etc/hotplug/usb in other words).

Final notes & comparisons

I originally tried to write a script for hotplug using jPhoto, but for some reason the jphoto programs throws I/O Exceptions at me the first time I try to connect to the camera, and hence I haven’t gotten the hot syncing function to work with jPhoto so far. I did try to reach the developer of jPhoto, but I didn’t get any reply from him, so I can unfortunately do nothing about it.

The hot syncing does work with gPhoto2, but it is shaky as well, so don’t trust it too much. I have yet to send a bug report on this matter, but will do so after writing this, so it is possible that some problems will be fixed in the near future.

From my experience, both programs did a relatively bad job at everything except downloading the images. I have so far been totally unable to delete the images on the camera using either gPhoto2 or jPhoto, which does work via the EasyShare! programs on the same computer (in other words, no hardware faults to my knowledge). Actually, none of the other commands than downloading seems to work properly. With the Kodak CX4230, the camera connection seems to hang when any of those commands are issued, and the camera must be unplugged and then replugged to respond to any commands at all. This may be child-diseases, but very annoying such. However, there seems to be a lot of action going on within this area right now, so perhaps this will be fixed in a short time anyways.

Updates and thoughts

I’ve gotten quite a few mails from people with different kinds of success stories, and unsuccessful stories. Once again, I would like to state, this page was written simply to give people a starting point, by a novice, for novices. I am in other words no expert on Digital still imaging cameras and Linux, but I do have quite a few opinions. Personally, I don’t think the CX4230 is a very good camera if you are using it with Linux, but your mileage may vary.

However, this is one of the success stories I’ve gotten from Lo’oRiS il Kabukimono. According to him, all of the -P, -L and -D options works together with his camera these days. I wish you the best of luck.

Updates and thoughts2

One more update on this topic, since there seems to be quite a lot of people reading this story the last couple of days, since some news-sites has run it as a story. This is an rather old piece I put together almost 1,5 years ago.

To my knowledge, the gphoto2 homepage now lists this camera as fully functional with gphoto2, and also I got a mail from Daniel Kulp telling me about the ptpfs device drivers he has created on his homepage. I haven’t tried that method, but I can only imagine that your computer will lock dead if you use that driver together with the CX4230 camera, because of the very flaky nature of the CX4230. I may, of course, be wrong, so I am mentioning it here, and it isn’t any kind of grading on the driver, but rather the camera in specific.

Also, as of originally writing this story, card readers has become more and more commonplace. It may be a wise investment for those who has one of these cameras, and still have problem with gphoto2.

Updates and thoughts3

Some more updates on this topic. I have received notice from Fabian Foerg that the instructions in this document will excellently with Slackware 10.0 and the Kodak CX7300 camera. I have also tried the CX4230 together with Debian 3.1 and gphoto2 2.1.4, libgphoto2 2.1.4 and libgphoto2_port 0.5.1, and it works brilliantly. It seems the gphoto2 developers have added support for a long range of Kodak cameras that where previously unlisted, or simply listed as “USB PTP Class Camera”.

Because of this, I have added some new configuration options in the kodak-cx4230 script, so that you can set the camera model, and port. Hopefully things should be better now, at least with the integration into linux for most people. I can still not recommend the CX4230 camera to anyone, but I haven’t tried any of the newer cameras unfortunately, so I can’t speak for those.

If anyone working for Kodak reads this, they are more than welcome to give me a call and a few sample cameras to test with, and possibly improve my verdict of this line of cameras. Yes, I can be bought with a simple freebie camera ;-).

Resources

Kodak-CX4230 hotplug script. Should work with all PTP cameras.

Links