Linux, Compact Flash Readers, and the HP PhotoSmart 215


Warning: Do not buy an HP215. Instead, use your standard film-based camera. Every time you get a roll of film developed, buy and throw away 12 AA batteries. The effect will be the same as if you had an HP215, and you'll save yourself the $120 or so you would have spent on the camera. The low price (for a digital camera) of the HP215 makes it tempting. Do not succumb to temptation; save until you can spend a bit more on (say) a Canon A10.

That being said, if you've got one, or another Compact Flash based camera, here's some hints on getting it working.

Note that although this page is all about the HP215 digital camera, it will be useful for somebody with any digital camera that uses Compact Flash cards, since the way I ended up interfacing was with a standalone Compact Flash reader.

About the Camera

[Family Photo]
Me, my folks, and my wife

Overview

The HP PhotoSmart 215 is a good 1.3 megapixel digital camera. It is (as of this writing) HP's low-end model, although at 1.3Mpix, it's a pretty nice low end. It typically retails for around $120 new.

A lot of people complain about the image quality of this camera. As the most casual of camera users, I haven't had too many complaints myself; the quality is fine for what I want to do. The complaint that I do have is that this camera is murder on batteries. Four AA batteries don't last very long; with no use of the memory review feature of the camera, I don't think I've been able to take more than about 30 pictures on one set of batteries. This gets expensive. What's worse, the switch is weak, and sometimes slips to the "on" position in my camera case, thereby draining the batteries before I take a single picture. According to the documentation, the camera cannot use rechargable batteries, since it requires higher voltage than rechargeable AA batteries would take. Also, since I've had the camera the LCD display has gone intermittent on me; not only are previews gone, but sometimes it's hard to configure the camera!

Simply because of the battery issue, I would not recommend this camera to anybody; worries about consistency of quality are another issue. However, if you've got one, here's some more blather about it.

The camera has a minimum of configuartion options, best for those of us who aren't expert photographers. It looks like a typical low end camera: a rectangular box, with a viewfinder lens above a single small photographic lens, a built in flash, and a single button (push here to take a picture). On the bottom, there is a threaded 1/4-20 hole, for mounting the camera on a standard tripod. The camera takes four AA batteries; according to the documentation, it will not work with rechargable batteries. Inside a small opening panel, there is a slot for a CompactFlash Type I memory card, a connector for the included USB cable, and a connector for the not-included $50 AC adapter. (The documentation warns that under pain of warranty violation, you shouldn't use any but the HP-approved and overpriced AC adapter with the camera.) Finally, there is a wrist strap, on which there is a little plastic doohickey, ostentatiously called the "Memory Extractor Tool."

On the back, there is a small LCD status display, a larger square LCD preview screen, and three more controls. The power switch lets you switch between camera mode (for taking pictures) and preview mode (for reviewing pictures already in the camera). The LCD framing switch lets you use the LCD screen as a viewfinder; about every half-second, it updates the screen with what is currently visible through the lens. Finally, a dial/button to the left of the LCD screen lets you page through previews and select configuration options for the camera.

Other Camera Features

  • Auto Focus and "Macro Focus" (there is no manual focus)
  • Built in flash may be set to auto, enabled, disabled, or "red-eye reduction".
  • 10-second timer
  • Date and time stamping of images (not on the image, just on the saved file)
  • The camera goes through batteries like you wouldn't believe. It's also very sensitive to battery voltage; even batteries which are still towards the low side of "good" on most battery checkers are too weak for the camera to fully function.

[Ringing example]
Ringing at sharp edges
[Smoothing example]
Smoothing of faint features

Resolution

The camera only has two resolutions, although it claims to have three. "Basic" resolution is 640x480. "Fine" and "SuperFine" resolution are both 1280x960. All resolutions save images as compressed JPEG images. JPEG is a lossy compression format; the difference between "Fine" and "SuperFine" is that "Fine" uses greater compression, resulting in lower quality images. Each Basic image is about 100KB in size (check this). Each Fine image is about 200KB in size. Each SuperFine image is about 400-500KB in size.

The quality of SuperFine images is, to untrained visual inspection, quite good. Even Fine images look good, although if you know where to look, you can easily find the artifacts of JPEG compression. Large blank areas in the background will sometimes look blotchy. In some cases subtle features such as pleats or strips will get smoothed out. Most clasically, you sometimes see faint "ringing" around sharp edges. With less JPEG compression, the effect of these artifacts is decreased.



Interfaces Which Won't Work

I purchased this camera under the impression that it would work with gphoto2. After I got it, I discovered that the HP 215 and 315 had been mistakenly listed in the list of supported cameras, and that in fact it is not supported by gphoto2.

Oops.

Digging through the Linux USB resources, I found some people who claimed that the HP PhotoSmart 315 worked with the usb-storage module. I had no luck trying that route with the 215.

In other words, for the time being, this camera is not directly supported by Linux.

Fortunatly, the camera uses CompactFlash cards, and there are ways to read and write those cards with Linux.


CompactFlash Cards

CompactFlash cards are standard memory cards for embedded devices such as, say, digital cameras. The HP PhotoSmart 215 uses Type I cards, which are (approximately) 44mm x 37mm x 4mm in size. The memory in the card maintains its contents even when the card is not powered. With the HP Photosmart 215 (and, I believe, most devices), the card is configured to have a vfat filesystem. Images are saved to the card as normal files in JPEG format.

The HP PhotoSmart 215 comes with a 4MB CompactFlash card. This is enough to store about 36 images at Basic (640x480) resolution, about 10 images at Fine (1280x960) resolution, or about 5 images at SuperFine (1280x960) resoluition. Because the exact compression you get in a JPEG image depends on its contents, these numbers are approximate. In my (very limited) experience, the estimates are conservative ones.

You can use any standard CompactFlash card with the camera, if you want to be able to store more pictures at once. As of this writing, 16MB cards typically cost about $30, 32MB cards about $40, and 64MB cards about $50.

It is very difficult to get the CompactFlash card out of the HP 215 with your fingers. It is very easy with the supplied plastic "memory extractor tool".


Reading/Writing CompactFlash on Linux

Since no Linux tool seems to directly support the HP PhotoSmart 215, using the camera with Linux is reduced to the problem of reading and writing Compcat Flash cards. Fortunately, this turns out not to be very difficult. There are at least two possible solutions.

USB CompactFlash Readers

[USB Flash Reader]

You can buy USB CompactFlash adapters. These typically have a cord which plugs into the USB port, and a slot for inserting a CompactFlash card. The only one I have tried is the SanDisk ImageMate (model SDDR-31) (which sells for $30 or $40). Whichever one you get, make sure that it is supported by the usb-storage kernel module, since not all of them are! In order to use this device, you have to configure your kernel appropriately. It needs the usb-storage driver, which only works with Linux >2.4. The documentation for usb-storage states that it will not work with Linux 2.2. However, I have been told that it does in fact work with Linux 2.2.19. USB and usb-storage are standard in the Linux 2.4 kernel, so you don't have to download any additional drivers. If your kernel doesn't already include support for these drivers (they may be if you use a distribution's kernel), then build a kernel which includes the following drivers (built-in, or as modules):

  • scsi-mod
  • usbcore
  • uhci
  • usb-storage

When you reboot, use modprobe to load any of these drivers which you built as modules. (If you are clever, you can figure out how to do this with modules.conf; or, if you are less clever like me, you can do it in your startup script.) NOTE: I found that with Linux 2.4.19 and the SDDR-31, access to the memory on a card in the device was much slower when the usb-storage module was compiled as a module than when the usb-storage module was compiled directly into the kernel. Why this would be, I have no idea, but once I figured this out I started compiling usb-storage into the kernel. This is probably only an issue if you use a custom kernel (as I do). The stock 2.4.9 kernel that comes with RedHat 7.2 seemed to have reasonably speedy access to the memory on a card in the reader.

To get USB working, you should add the following line to your /etc/fstab file:
none             /proc/bus/usb      usbdevfs noauto      0 0
Then issue the command "mount /proc/bus/usb". At this point, you ought to be able to do "cat /proc/bus/usb/devices" and see a listing for your USB reader- assuming it's plugged in! For example, this is an excerpt from my system:
T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0781 ProdID=0002 Rev= 0.09
S:  Manufacturer=SanDisk Corporation
S:  Product=ImageMate CompactFlash USB
S:  SerialNumber=000000000004
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=  0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=  0ms

Notice that the Driver is listed as usb-storage for this device. If the driver is listed as none, then you have a problem.

Finally, we get to actually reading the card. Insert the card into the USB CompactFlash adapter. Assuming you have no other SCSI disks on your system, issue these commands as root:

mkdir /mnt/flash
mount -tmsdos -ofat=12 /dev/sda1 /mnt/flash

If everything is working, then at this point you should have a filesystem at /mnt/flash which is the contents of your card. For the HP PhotoSmart 215, the images show up in subdirctories underneath the /mnt/flash/dcim directory. (Which subdirectories are there seems to have to do with whether or not the camera has felt the need to shut itself off due to weak batteries.)

Note that you may or may not want the "fat=12" argument. I am not sure if all CompactFlash cards come formatted with a FAT12 filesystem. You can find out by inserting the card in the reader, and then running (as root) "fdisk /dev/sda" (or /dev/sdb if you have a single real SCSI disk). Type "p" and hit return to see what filesystem is on the CompactFlash card. Type "q" and hit return to exit fdisk (leaving the memory on the card unchanged).

If you use any actual real SCSI disks on your system, then the Flash partition may show up at sdb1, sdc1, or whatever is the first unused SCSI device. You may be able to figure this out by poking around in /proc/scsi.

If you want to be able to mount and unmount this partition as a normal user, then add the following line to /etc/fstab:

/dev/sda1      /mnt/flash     vfat    noauto,user,fat=12  0 0

Then, any user should be able to "mount /mnt/flash". Remember to "umount /mnt/flash" before removing the card from the USB reader!!

PCMCIA CompactFlash Readers

[PCMCIA Flash Reader]

This is an option for laptop owners, and also works well. I got a SanDisk reader from eLinux.com a while back, for something like $10. With the PCMCIA card utilities, it looks to the computer just like a standard PCMCIA IDE hard drive. To do it, make sure you've got a kernel with the PCMCIA modules compiled in, and make sure to compile the PCMCIA IDE module. (Kernels for laptops that come with distributions will almost certinaly have these in them.)

Make yourself a directory /mnt/pcflash and then add the following line to /etc/fstab:

/dev/hdc1      /mnt/pcflash   vfat    noauto,user,fat=12  0 0
[PCMCIA Flash Reader]

Replace /dev/hdc1 with whatever device the PCMCIA IDE module places the card at. You can figure this out by looking at your system messages file (/var/log/messages on a RedHat system) right after the card is inserted, or by looking at /var/lib/pcmcia/stab. If you have both a hard drive and an IDE CD-ROM drive on your system, it may well be that the PCMCIA Compact Flash card won't show up at /dev/hdc.

At this point, after inserting the card, any user can issue the command

mount /mnt/pcflash

and get to the images on the card just like files on any other filesystem.

Remember to unmount the filesystem before physically removing the PCMCIA card reader!

(The reason I made the mount point /mnt/pcflash rather than /mnt/flash is that the laptop I've used has a USB port. Sometimes I plug my USB flash reader into the laptop, and that gets mounted at /mnt/flash.)


Accessing Images

Once you've figured out how to Read and Write the CompactFlash card, it's pretty easy: they're just normal files. Use your favorite image viewer to look at them, the Gimp or netpbm to process them, and standard Linux tools to copy the files out to your hard drive and rename them to something more descriptive than im000101.jpg.

With gphoto 0.4 (which I got bundled with Helix Gnome), you can look at thumbnails of the images as a form of "quick menu", and you can do some very basic processing of the images. Don't worry about the camera support in gphoto 0.4; just get your CompactFlash card mounted as a normal partition, and then point gphoto 0.4 at the directory where the images are. More recently, I've found that the Nautilus file manager (standard with Gnome 1.4) is a great image browser. It's probably not best for use on the compact flash card istelf, since it will create a hidden "dot" directory in which it stores its thumbnails (thereby using up space on the compact flash card, which won't be restored unless you think to delete that "dot" directory). However, if you copy the images off to somewhere else on your hard drive, Nautilus is a great way to see what you've got.


Last modified: 2002-February-10, by Rob Knop