September 10, 2007

How to give your low-end Canon digital camera RAW support

Author: Nathan Willis

If you have a point-and-click digital camera made by Canon, you may be able to turn on all sorts of features usually reserved for more expensive SLRs. That includes live histograms, depth-of-field calculation, under and overexposure highlighting, and -- best of all -- shooting your pictures in RAW. The secret is CHDK, an enhanced, free software replacement firmware.

It is not clear what CHDK developer Andre Gratchev intends the initials CHDK to stand for, but the user community has speculated that it means Canon Hacker's Development Kit. In any event, you don't have to be a hacker to use CHDK; it is as close to a plug-and-play camera enhancement as you will find.

CHDK works because many of Canon's recent digital cameras are based on the same DIGIC II chip. To see if your camera is supported, review the list in the CHDK FAQ. If you have a supported model, the FAQ provides step-by-step instructions for getting the correct firmware and loading it onto the camera. Although all of the supported cameras use the DIGIC II processor, each model is different, which required the CHDK developers to dump the factory firmware and do some reverse-engineering.

Let's walk through the steps required to get CHDK rolling on the PowerShot S2 IS. And don't worry -- unlike replacement firmware customization on Wi-Fi routers and some other hardware devices, this is all non-destructive and highly unlikely to damage your camera. Nevertheless, if you are under warranty or are prone to accidents, proceed at your own risk.

Prep and load

The first step is to determine exactly which firmware is already on your camera. Canon makes minor adjustments to its cameras' firmware over the course their production life, but except in rare cases it does not issue firmware updates that you can download and apply at home. That means if your camera uses firmware numbered 1.00C, you probably cannot upgrade it to firmware 1.00D yourself, and you must be sure your download the 1.00C version of CHDK.

To discover your camera's firmware version, first create an empty file named ver.req on the camera's flash memory card. On Linux you can do this with the touch command. Put the memory card into your PC's card reader, mount it as you would any removable storage, and type the touch command from the shell. In my case, GNOME detected and automounted the card as /media/CANON_DC, so I typed touch /media/CANON_DC/ver.req.

Unmount the card and put it back into the camera. Turn the camera on in Play mode (i.e., not camera or Rec mode). Hold down the Set button on your camera and press the Display button. The firmware version will appear on the LCD viewfinder, along with some other fun facts like your camera's build date.

Now that you know which firmware your camera has, you can download the appropriate CHDK replacement. The latest builds should be at Gratchev's site, but check the CHDK Web site to make sure.

My S2 IS uses 1.00E firmware, so I downloaded, the newest version for my camera and firmware combo. If you're really adventurous, you can also grab the source code and compile it yourself, but I wouldn't recommend starting out that way.

The .zip archive contains two binaries, Diskboot.bin and PS.fir. Put the memory card from your camera back into your computer's card reader, then copy both of these files onto the card. Put the memory card back into the camera, turn it on in Play mode, and press the Menu button. Down at the bottom of the first menu you'll see a new entry labeled Firm Update. Click on it, click OK to confirm, and the camera will reboot into the new CHDK firmware. When it does, the display will pop up a splash screen indicating the version of CHDK loaded.

If the camera doesn't boot (which can happen if you accidentally download the wrong CHDK firmware), all you have to do is turn it off and turn it back on again. It will restart using the original firmware.

Fun with firmware

Now you are ready to explore CHDK's features. To access the new features, press the <ALT> button. There is no physical button labelled <ALT> on any of these cameras; it is a "virtual" label used in the CHDK documentation because the physical button used varies between camera models. For A-series cameras, the Direct Print button serves as <ALT>. For the S2 IS and S3 IS, the Shortcut button serves as <ALT> by default, but you can change this in the CHDK settings. In both cases, the button chosen as <ALT> is one that is normally unused during picture-taking, so remapping it to this new function does not rob you of any of your camera's original features.

To explore the possibilities, press <ALT> and then press the Menu button. This will bring up CHDK's well-organized feature menu. You navigate through it with the camera's direction arrows, just like in the factory firmware. Once you have made changes, press Menu again and CHDK will save them to a preferences file on the memory card.

When you are shooting, <ALT> mode gives you quick access to toggle special features on or off. Normally you will want to leave <ALT> mode before shooting, so after making changes in the CHDK menu, be sure you press <ALT> again. While you are in <ALT> mode, the word <ALT> will appear on the viewfinder, so it is not difficult to tell which mode you are in, it's just easy to forget.

The project's wiki has one (very long) page outlining all of CHDK's additions and enhancements. It is worth reading in its entirety, but for brevity's sake I'll describe the more prominent ones.

An important usability enhancement is all of the additional info CHDK can display in the viewfinder. You can turn on a histogram that displays live brightness data for the scene, updated continuously as long as you hold down the shutter button halfway (to the auto-focus position). You can also activate what CHDK calls Zebra mode -- areas in the scene that are outside the exposure range will blink black or white: black for areas that are underexposed, and white for areas that are overexposed.

You can also add to the viewfinder numeric displays such as the auto-focus distance and the depth of field. On the non-photographic side, you can add a battery charge meter and clock. If all of that sounds a little crowded, you can rearrange the positioning of all of these elements to your liking.

Working with RAW

The aforementioned shooting aids all fall into the "tools" category. A far more substantial feature of CHDK is the ability to save your images to the camera's memory card in RAW format, instead of as JPEG files.

Enabling RAW shooting mode is as simple as checking the Save RAW option in CDHK's menus. Additionally, you can toggle noise reduction, select a special filename prefix for your RAW images, and choose whether to save them in the same directory as JPEGs, or on their own. You can even enable a special shooting mode in which shooting continuous shots will save the first shot as RAW and the subsequent frames as JPEG, thereby shortening the lag between successive frames.

As any RAW shooter knows, though, not all RAW files are created equal. Camera manufacturers keep the specifics of their formats secret and proprietary, and change the details between different camera models. So even if my S2 IS and an A610 both produce a RAW file with the .CRW extension, they will be different on the inside.

Fortunately, developer Dave Coffin has added support for most in not all of the CHDK-compatible cameras to his ubiquitous dcraw RAW converter. Linux users can process their RAW photos by grabbing the latest builds of UFRaw, RawTherapee, or LightZone.

Alternately, you can use a recent version of dcraw and convert the files to another format. The CHDK wiki recommends the Adobe Digital Negative (DNG) format for this, since unlike converting to an output format like TIFF, converting to DNG will preserve the RAW data as-is, readable by almost any image editing application.

Even though smaller cameras like the S2 IS can't compete with SLRs in terms of image quality, shooting RAW is still to your advantage. The sensors in these cameras are capable of capturing greater color depth than their default 8-bit JPEG file output preserves. And as one CHDK user discovered, the factory firmware crops margins off the sensor borders when saving to JPEG, so the RAW file is actually bigger, too.

Intermediate and advanced fun with firmware

There is even more to CHDK. It includes some non-photography-related utilities such as a file browser to examine the contents of your memory card, a text file reader (which I suppose could be photography-related if you were to include notes or shot lists), a perpetual calendar, and some simple games.

If you decide that you like CHDK enough that you prefer shooting with it to shooting with the factory firmware, there is a procedure that allows you to autoload CHDK every time, instead of following the Firm Update / reboot process. There are two minor caveats with the procedure, however..

First, the auto-load feature may not work with memory cards larger than 2GB in size. Second, you have to start the camera in Play mode first, then switch to Rec mode to begin shooting. That's not difficult to do, but it could cost you a few seconds of precious shooting time while someone else snaps that million-dollar UFO pic.

When you get comfortable with CHDK, you can check out user-supplied scripts. CHDK's scripting environment uses a simple BASIC-like language that lets you write your own scripts to automate camera functions -- but not to create whole new features for the camera. User-contributed scripts are available on the CHDK wiki, and implement interesting functions like HDR stacking, focus bracketing, time-lapse movies, and lightning photography.

Final shot

I picked up my S2 IS to use as a lightweight, carry-anywhere camera -- useful for when I needed a shot but didn't have my SLR handy. Even though I'm happy with its optics and portability, its lack of RAW power and manual control always made it a second-class citizen. Consequently, I found myself leaving it at home more and more frequently.

Loading CHDK onto it almost makes the S2 IS feel like a different camera. It's still not an SLR, but the extra heads-up features help me compose better shots. And my perfectionist side likes knowing that the image sensor is taking 10-bit-per-channel pictures and the camera is not truncating them to 8-bit JPEGs before it lets me have them.

Now if only CHDK could do something to keep that flimsy lens cap from falling off....


  • Tools & Utilities
Click Here!