Using the Camedia C220 with Linux

en francais
My latest camera is the Olympus Camedia C220. There had been some smaller problems to use it with Linux. Here I describe a possible solution.
With newer kernels (2.6 or 2.4.21) there is no need for the patch below. But with older kernels you might have to apply the patch.

A note sent by Thomas M. from Berlin: Bei meiner Olympus D-100 (manchmal auch "C-1" oder "c-you" gennant) funktionierte es auch wie beschrieben. For all non-Germans: This patch should also work for the Olympus D-100 also known as C-1 or c-you.
As I hear now, the C220 seems to be sold in other coutries also as D520.

The camera has an USB-connection and should act like an USB storage device. So plug in the USB cable into the computer and the camera and ... BOOM . After 5 seconds the computer hangs. You have to press the reset button. Clever guys analyzed the problem and found out, that the camera is not sending the USBS identification string, but an USBU string. This USBU confuses the USB-storage kernel module, that the whole computer hangs.

If the camera is your only USB-storage device, then there is an easy way to get the camera running: let the kernel module react to the USBU ID instead of the USBS. Then you can access the camera, but no other USB storage device.
How to do it: a clean solution is to change the definition in the kernel module source, and recompile it. But then you need the sources, and headers. You must know, what file to patch. And you must know how to compile and install the kernel sources. If you are not experienced, then you may spend a weekend on it.
There are betters things to do on a weekend. So here a more pragmatic (and brutal) solution: patch the exisiting kernel module. Ok, you also have to compile for it, but it is only an 30-liner.

Do all the following on your own risk. It works on my machine, but it might not work on your machine. Make a backup of your data before!

Step 1 - Load the Patch program

Load this small patch program
#include "stdio.h"

// buffer, must be large enough
#define BUFFER_SIZE 0x100000
char buffer[BUFFER_SIZE];

int main(int argc , char *argv[])
   int i;
   int i_Read ;
   int i_Written ;
   FILE *in,*out;

   in = fopen("usb-storage.o","rb");
   i_Read = fread(buffer,1,BUFFER_SIZE,in);

   fprintf(stderr,"Read %d Bytes\n",i_Read);

   for(i=0; i< (i_Read -3); i++)
              buffer[i  ] == 'U'
          &&  buffer[i+1] == 'S'
          &&  buffer[i+2] == 'B'
          &&  buffer[i+3] == 'S'
         fprintf(stderr,"found at %d\n",i);
         buffer[i+3] = 'U';

   out = fopen("usb-storagex.o","wb");
   i_Written = fwrite(buffer,1,i_Read,out);

   fprintf(stderr,"Wrote %d Bytes\n",i_Written);

Compile it with
make usbp
and you get the program usbp. That is all you need.

Step 2 - Find out the location of the modules

insmod usb-storage
And the old module is loaded. a side effect is, that it shows the location of the modules. On my machine it says /lib/modules/2.4.18-64GB-SMP/kernel/drivers/usb/storage/usb-storage.o . So the location is /lib/modules/2.4.18-64GB-SMP/kernel/drivers/usb/storage/ . Copy the usbp program into that directory and cd into it.
cp usbp /lib/modules/2.4.18-64GB-SMP/kernel/drivers/usb/storage/
cd /lib/modules/2.4.18-64GB-SMP/kernel/drivers/usb/storage/

Step 3 - Patch the module

Start the patch program with
The program creates the a modified copy of the original module. A typical output is
Read 61670 Bytes
found at 7775
found at 26381
Wrote 61670 Bytes
At this point the system is still using the old module. Rename the old and the modified module, that the system uses the desired one. Enter
rmmod usb-storage
mv usb-storage.o usb-storage-original.o
mv sub-storagex.o usb-storage.o
You saved the original module, and activated the new module. If you have Windows installed, then you have to reboot the machine.

Step 4 - Use the camera

Now connect the camera with the USB-cable at to the computer. In the system console you should have a message like this
Jul 14 12:31:03 hawaii kernel: usb.c: USB device 2 (vend/prod 0x7b4/0x102) is not claimed by any active driver.
Jul 14 12:31:04 hawaii kernel: usb-uhci.c: interrupt, status 3, frame# 107
Jul 14 12:31:04 hawaii kernel:   Vendor: OLYMPUS   Model: C2Z,D520Z,C220Z   Rev: 1054
Jul 14 12:31:04 hawaii kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jul 14 12:31:04 hawaii kernel: Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0
Jul 14 12:31:04 hawaii kernel: SCSI device sda: 256000 512-byte hdwr sectors (131 MB)
Jul 14 12:31:04 hawaii kernel: sda: Write Protect is off
Now you only have to mount the directory and the you can access the pictures. I created a directory called /olympus .
mkdir /olympus
Then I mount the camera with the command
mount /dev/sda1 /olympus
Enter the directory
cd /olympus
Then enter the Olympus-specific path
cd dcim/100olymp
and you are in the directory with all the images. Now you can look at them, copy them, do whatever you want to do with them.
At the end leave the directory and unmount it.
cd ; umount /olympus

If it does not work

What I described is the way I did, and how it worked on my machine. Because you have to do all as root, there is the possibility, that you might damage your system. On other systems these steps might also not work. If it does not work, I can not help you, because I don't know your system, or what might be different to my system. So everything you do is on your own risk!

Another thing I found out is: the USB-storage and the DSL with pppoe do not work together on my system. I can either go into the internet, or access the camera. But not both at the same time.