Using a Sony DSC-P50 Cybershot Digital Camera with Linux

[Linux]

23rd April 2003

I bought my Sony DSC-P50 digital camera in September 2001. It was pretty good at the time. 2.1 megapixels. Built in flash. Lens cap. Viewing panel on the back. I was really excited.

[Front of the Sony
DSC-P50 digital camera] [Back of the Sony
DSC-P50 digital camera]

Reality set in when I got the camera home and attempted to use it. I had a whopping great 4 megabyte Sony memory stick included with the camera. Cor, fantastic, I thought. And it took two AA batteries, so that was pretty good too. Easy to get replacements no matter where I travel. I set the camera to take best quality images, with minimal compression. The display told me that I could fit four photos on my memory stick. Suddenly that 4 megabyte memory stick didn't look so exciting. I took two test photos. The batteries died. Hmm. Okay, so maybe they were el cheapo batteries that had been sitting around too long in the camera box. I put in two brand new Duracell batteries. And only got to take two more photos before they died. I got irritated. I thought there must have been something wrong with the camera. I decided to take it back the next day and exchange it for a non-broken one. I packed it all up, and then turned to Google and started searching.

Oh boy, did I get pissed off. I read many tales of woe with this camera. And nearly all other digital cameras. It wasn't just limited to the Sony cameras. After enough reading, I reached three conclusions.

  • never believe the packaging on a digital camera and never trust a salesperson
  • buy as many of the largest size memory sticks/cards that you can afford
  • buy plenty of high-quality rechargeable nickel metal hydride (NiMH) batteries of at least 1600 mAh, and a good recharger

The price of the camera was going to blow out by at least another $150. Next day, I headed back to the store and bought a 128 meg memory stick, and a battery charger that handles the NiMH batteries, and 6 of the NiMH batteries. $150. I was pissed off. Sony provided a nice little camera, but shafted their customers by completely under-supplying the memory stick and batteries. Over the next year and half, I bought another two 128 meg memory sticks, and a small international battery charger and some more batteries, and a case. The camera works really really well. It's only 2.1 megapixels, but I am getting great photos and I'm really, really happy with the camera. Today, it's a bit bulky, and there's others with more megapixels, but I'm not yet inclined to buy a replacement. When the time comes, I will look around. I like the Sony camera a lot, but I have no loyalty to Sony because of their weasel ways with the memory stick and the batteries when I first purchased this one. Then again, from what I've read, the other camera manufacturers are much the same. I will look at the Sony offerings, but I'll keep an open mind.

[Sony memory sticks]

Here's one of my favourite photos taken with the camera, using close up mode. That frog is Anne's pet and in real life it's about half an inch long.

[One of my favourite photos taken
with the Sony DSC-P50 camera]

The only real gripe I ever had with the technical setup was getting the photos out of the camera and on to the computer. The USB cable that Sony supplied was about 2 foot long. You stick one end of the cable in the back of the computer, and the damned cable doesn't even reach around to the front. Another case of Sony being cheap. Or else being incredibly stupid and assuming that everyone has their computer mounted on the desk in front of their face, with USB ports on the front of the computer. So I bought a USB cable extender and that lets me bring the end of the USB cable around to the front where I can plug it in.

I got the photo download working under Windows. They want you to install all sorts of software crap. The only thing it turned out that I needed was one device driver. The rest of the software was of no use to me, so I ditched it. I would attach the camera to the USB cable, turn the camera on, the device driver recognised that something was happening, and made the Sony memory stick look like a 128 meg hard drive. The directory structure was interesting.

  • dcim
    • 100msdcf (normal photos, text mode photos)
  • mssony
    • imcif100 (email and TIFF mode photos)
    • moml0001 (movies)

I have recently discovered that not all these directories will exist. A brand new memory stick contains no directories. The camera will create them automatically as it needs them. So if you've never taken anything but normal photos, then you'll only have /dcim/100msdcf. I have removed the memory sticks, deleted all directories, and then put them back in the camera, and had the needed directories created. I used to worry about accidentally deleting directories, but I don't have to worry any more.

Sometimes there is a file in the root directory of the memory stick called memstick.ind. It's zero bytes, and isn't always on the memory sticks, and I don't know why it's there or how it gets created. I've deleted it and tried the memory stick again, and it still works.

To get the photos out of the camera, I would boot to Windows, attach the camera to the USB port, and then fire up Windows Explorer, copy the photos off the memory stick and stick them in a holding directory, then delete them off the memory stick. Then reboot back to Linux and grab the photos and use them. Getting the photos off the camera was one of the very few things I had to go back to Windows for, and it really irritated me.

I tried several times in 2002 to get Linux to recognise the memory stick through the USB port, but never had any luck. I kept reading that USB support in Linux was getting better and better but didn't get a chance to try it out until April 2003 when Slackware 9.0 was released and I got my cdroms in the mail and tried it out. I had high hopes that the latest version of the USB device drivers would let me see the memory sticks under Linux.

While I was installing Slackware, I made sure that all the USB support was included. I set it all up as modules. So I included

  • Support for USB
  • Preliminary USB device filesystem
  • all the USB host controller drivers
  • USB Mass Storage Support
  • all the options under the mass storage support

There are probably other things needed in the kernel, like hotplug support, but I already had included them and didn't make any special notes about them.

I attached the camera to the USB cable and turned it on. I was watching /var/log/messages and saw this:

Apr 16 21:49:43 cerebus kernel: hub.c: new USB device 00:1f.2-2, assigned address 3
Apr 16 21:49:47 cerebus /etc/hotplug/usb.agent: Setup usb-storage for USB product \
 54c/10/322
Apr 16 21:49:47 cerebus kernel: Initializing USB Mass Storage driver...
Apr 16 21:49:47 cerebus kernel: usb.c: registered new driver usb-storage
Apr 16 21:49:47 cerebus kernel: scsi2 : SCSI emulation for USB Mass Storage devices
Apr 16 21:49:47 cerebus kernel:  sda: sda1
Apr 16 21:49:47 cerebus kernel: USB Mass Storage support registered.

Fantastic. It saw the camera. I quickly went to /mnt and created /mnt/camera. As I now knew from the logs that it was attached to /dev/sda1, I went to /etc and edited fstab and added the line:

/dev/sda1   /mnt/camera   vfat   noauto,users   0   0

Then I mounted the camera with

mount /mnt/camera

and used Midnight Commander to copy the photos off the camera to my hard disk. It was perfect. It worked beautifully. I had zero problems. Perfect. Absolutely amazing.

Then I unmounted the camera with

umount /mnt/camera

and turned the camera off and /var/log/messages showed:

Apr 16 21:55:39 cerebus kernel: usb.c: USB disconnect on device 00:1f.2-2 address 3

I experimented with the fstab settings. It works the same with filesystem types of msdos and vfat. All the filenames and directories follow the old DOS 8.3 filename pattern, so I suppose you could set the fstab entry to msdos and leave it. I tried that for a while and had no problems. I switched it back to vfat and left it like that and had no problems, and that's where it remains today. I also tried "auto" for the filesystem type. That gave me this error:

/dev/sda1: Input/output error

but it still mounted the camera as filesystem type "msdos". Curious. I didn't like the error, so I went back to vfat.

I have been using the camera consistently under Linux ever since. The directory structure is the same as under Windows, and it all works as expected. I only ever had one glitch with it. I had copied the photos off the camera, and then removed them. I then turned the camera off and removed it without umounting it. The photos were still on the memory stick. Probably I had turned the camera off too quickly and the file system hadn't had a chance to sync. Now, I always remember to umount the camera before turning it off, and that works fine.

I don't know the names of the programmers who worked on the USB support for Linux, but guys, I salute you and I thank you. You've done a great job on it, and made me really happy.