CHDK Wiki
Register
Advertisement

A guide to installing and using CHDK with your Mac.

Installing CHDK onto an SD card can be frustrating for Mac users. Copying scripts correctly, to avoid parse and UNK errors with every one, can also be tricky. Below are some tips and hints for Mac users.

Manual vs. Auto booting

There are two possible ways to use the CHDK on the camera. One way is autoboot, where it will boot up automatically whenever you turn on the camera. The other way is manual boot (also known as firm update) where your camera will start up with only the original Canon menus. Then you should get an extra menu option at the bottom of your menu (in Play mode only) that says Firm Update, and when you select that the CHDK should boot up. The autoboot method is more convenient for most people to use, but the manual boot method has an easier installation process. Most of the directions below are concerned with making autoboot work. If you just want to use manual boot, all you have to do is download the right build and copy all of the files into the root directory of your card (make sure your card is properly formatted first - easy way is to format it in the camera). If you find that you don't have the Firm Update menu after doing that, its probably because the Mac adds extra hidden stuff to files that are downloaded from the internet (as a security feature). To fix this, follow the directions at the bottom of this page under "Remove the Flags Using the Terminal"

Note that for some cameras (including the SD1100/Ixus 80) if you have a card that's larger than 4 gigs, you have to use the manual boot method.


How to Install CHDK on a SD Card Using a Macintosh

Note: These methods were tested on OS X 10.5.6 "Leopard". They should work on all Macs running OSX. If you discover otherwise, please note it in the Discussion.

Scripted Installation of CHDK

I wrote an applescript to automate formatting SD cards and installing a CHDK autobuild on the formatted card. Download it here. Be warned, misuse of this script can cause data loss!

The script supports single partition installations on cards smaller than 4GB and two partition installations on larger cards.

Also, I wrote and tested this script using OS X 10.5.6 , so there may be incompatibilities with other systems. If there are, leave a note in the Discussion, so that we can fix the script.

To use it:

  1. Download the appropriate autobuild.
  2. Download the applescript.
  3. Mount your unlocked SD card using a card reader.
  4. Run Script
  5. Eject and lock card.
  6. Run CHDK.


Alternate scripted method

Here is a completely different script to automate just the preparation of a card for CHDK installation. I leave dragging the actual CHDK files to the card up to you, since those will vary with your camera. Maybe I'll improve that in the future. The script it takes care of all the formatting, partitioning, hex editing, ver.req and vers.req file creation, etc. If you have trouble with the above AppleScript method, give this a try. Download it here. Inside the disk image double-click "CHDK_prep.command"

I've tested my script (CHDK_prep.command) on Leopard (10.5.7) and the Snow Leopard (10.6). If you have trouble, report back on the discussion page and I'll see what I can do.


Manually Installing CHDK

In Brief

  1. Download the appropriate autobuild.
  2. Download additional software (if necessary).
  3. Mount your SD card using a card reader.
  4. Format your SD card, or the first partition as FAT16.
  5. Make bootable.
  6. Copy CHDK to SD card.
  7. Eject and lock card.
  8. Run CHDK.


Software needed:

  • Disk Utility (comes standard on every Mac)
  • Terminal (comes standard with OSX)
  • 0xED (or another hex editor)
Either 0xED (free), or Hex Fiend (free), will work.

OR

Hardware needed:

  • Canon camera
  • memory card
  • card reader

Find the Right Autobuild

The first requirement is to identify the exact firmware revision of the destination camera.

  • Insert an SD card into a card reader attached to your Mac.
  • Using a basic text editor (TextEdit), make an empty file called ver.req in the root of the SD card.
  1. File -> Save As...
  2. Name the file ver.req (Note: may give different information than vers.req)
  3. For Plain Text Encoding, select "Unicode (UTF-8)"
  4. Unclick 'If no extension is provided, use ".txt".'
  5. Copy the saved script to the root of the SD card.
  • Insert the card into the camera.
  • With the camera switched to playback mode, turn on the camera.
  • While holding the Function/Set button, press Display.
The camera's firmware version is the last four digits 1.01B of the line reading "Firmware Ver GM1.01B" for example.

For more detailed instructions, go here.

Build names include references to camera models and firmware versions. For example, a build name that includes the text "...A610 fw v1.00e" is designed for the A610 camera with firmware version v1.00e. (Note that cameras sold outside the United States often have different model designations. See the table at "For Developers" for cross-reference.)

Autobuilds usually include the vers.req file needed for determining your firmware version. (Of course, without knowing your firmware version, you won't know which autobuild to have selected in the first place.) In lieu of determining your camera's firmware version, you can try installing every build available for your camera's model. Some have only one to try. If this is unsuccessful and you seek help, please determine your camera's firmware version before posting a request for assistance.

You'll actually see two versions of CHDK for each camera model. The "Complete" build includes files such as fonts, grids, scripts and languages. The "Small" build contains only the binary source code. Complete builds change less frequently than small builds, so please don't overuse our bandwidth by downloading complete builds multiple times a day.

What if nothing is available for my camera?

Head to the "For Developers" page to see what progress is being made in porting CHDK to additional cameras and firmware versions. And perhaps you can help!

Install CHDK

Two methods are presented. The first is for installation on memory cards that are 4GB or smaller. The second method is for installation on cards that are larger than 4GB.

Please keep in mind that these methods will erase all files from the card. Backup your photos (and CCHDK.CFG if this is not a fresh installation and you want to save your CHDK preferences).

Note: B.Mann's Blog has an account of his efforts to install CHDK using a mac. It might be useful for some people.

SD Card ≤4GB

CHDK requires a card formatted with the FAT16 file system, which is limited to a maximum of 4 GB, to load properly on camera startup.


  • Insert an unlocked memory card into a card reader connected to your Mac.
Get the card device name
  • Open Disk Utility.
  • Select the card reader from the list of devices on the left.
  • Get Info ( Apple+I ), and note the Disk Identifier, ie.( /dev/disk2s1 ). This identifier is very important; it will be used to address the proper disk for all subsequent steps. NOTE under some versions of OSX, the /dev/ part may not be shown in the Get Info window. You will still need to include it in the commands.
We will refer to the disk identifier as /dev/diskXsX from now on. Just replace /dev/diskXsX with the identifier of your disk in all subsequent instructions.
  • Be sure that the disk is currently formatted as FAT32 or another MSDOS format. If it is already formatted as FAT16, skip the next steps.NOTE If the card is 2gb or smaller, and has already been formatted in the camera, it is almost certainly FAT16.
  • Unmount the partition. Do not eject.
Formatting the card
  • Open the Terminal
  • Type: sudo newfs_msdos -F 16 -v Canon_DC -b 4096 -c 128 /dev/diskXsX This will reformat a FAT32 disk as FAT16, thus making it compatible with CHDK.
  • Enter your password when prompted
For mor information on using newfs_msdos see ManPages/newfs_msdos
Make the card bootable

NOTE If your card supports the "firm update" starting method, you skip this step, and make the card bootable in the camera after starting CHDK using the firm update method. This is done using the 'make card bootable..." option under the "miscellaneous" menu in CHDK.

  • Type: dd if=/dev/diskXsX of=BootSector.bin bs=512 count=1 This copies a sector of the SD card to your Mac's hard disk.
  • Make a backup of the BootSector.bin file, that has been created in your Home directory, in case anything goes wrong. The BootSector.bin file contains your SD card's boot sector.
  • Open BootSector.bin with 0xED.
Keep in mind that, if you do not see FAT12 or FAT16 around 0x36 (decimal 54) in the hex editor, you probably picked the wrong drive. Do not overwrite anything in that case.
  • If the file is correct, select the Overwrite writing method (Command+Shift+O).
  • Go to offset hex 40 (decimal 64) and press Tab.
  • Type BOOTDISK.
  • Save and quit.
  • In your Terminal window, type: dd if=BootSector.bin of=/dev/diskXsX bs=512 count=1 This copies the modified file to the boot sector of your SD card.
For more information on using dd see ManPages/dd
Copy the files
  • Using Disk Utility, mount the card.
  • Copy the file DISKBOOT.BIN to your SD card. Make sure to use the correct version for your model of Canon camera.
  • If PS.FIR (or PS.FI2) is included in the autobuild, copy it to the card.
  • Copy ver.req to the card. (This is optional, but guarantees full CHDK functionality.)
  • Copy the CHDK folder to the card.
  • Eject the SD card.
  • Slide the tab to the LOCK position.
It is necessary to LOCK the SD card to load the CHDK software. With the card locked and the camera running CHDK, you are still able to record pictures on the card.

You now have a Bootable SD card with CHDK properly installed. The camera will now attempt to load the DISKBOOT.BIN file whenever the camera is started with this SD card (when it is locked).

SD Card >4GB

If you have a card larger than 4 GB, the solution is to create two partitions on your card: a small FAT16 partition, and a larger FAT32 partition. (The FAT16 partition can be very small, like 2 MB, and must be the first partition on the card.) You would then install the CHDK boot files (DISKBOOT.BIN and possibly PS.FIR) on the FAT16 partition, and everything else on the FAT32 one.

When using this system, CHDK will start from the FAT16 part of the card. It will then automatically detect the larger FAT32 partition, and "switch over" to use that one. All images, movies, etc. will be stored on the large partition, and all CHDK scripts and data files will be read from there. (The smaller partition cannot be accessed once CHDK is loaded, so don't put any scripts or other files on it that you want to use!)


  • Insert an unlocked memory card into a card reader connected to your Mac.
Partition the card
  • Open Disk Utility.
  • Select the card reader from the list of devices on the left.
  • Click the "Partition" tab in the right pane.
  • Select "2 Partitions" from the drop down list under "Volume Scheme"
  • Select and resize the first partition to 4 MB. Format it as MS-DOS.
  • Select the second partition and format it as MS-DOS. The size will be set automatically.
  • Click "Apply", then click "Partition" if prompted.
  • Select the first partition from the list on the left.
  • Get Info ( Apple+I ), and note the Disk Identifier, i.e. ( /dev/disk2s1 ). This identifier is very important; it will be used to address the proper disk for all subsequent steps.
We will refer to the disk identifier as /dev/diskX and /dev/diskXsX from now on. /dev/diskX refers to /dev/disk2 and dev/diskXsX refers to /dev/disk2s1 in the example. In all subsequent instructions, replace these identifiers with the identifier of your disk, as shown in the information window of Disk Utility.
  • Unmount the first partition. Do not eject.


  • Open the Terminal
  • Type: fdisk -e /dev/diskX ie.( fdisk -e /dev/disk2 )
Ignore the error "fdisk: could not open MBR file ..."
  • Type: setpid 1
  • Enter 1 when prompted for new partition id.
  • Type: write
  • Enter y when prompted
  • Type: exit
For more information on using fdisk see, ManPages/fdisk
Make the card bootable
  • Type: dd if=/dev/diskXsX of=BootSector.bin bs=512 count=1 ie. (dd if=/dev/disk2s1 of=BootSector.bin bs=512 count=1) This copies a sector of the SD card to your Mac's hard disk.
  • Make a backup of the BootSector.bin file, that has been created in your Home directory, in case anything goes wrong.
The BootSector.bin file contains your SD card's boot sector.
  • Open BootSector.bin with 0xED.
Keep in mind that, if you do not see FAT12 or FAT16 around 0x36 (decimal 54) in the hex editor, you probably picked the wrong drive. Do not overwrite anything in that case.
  • If the file is correct, select the Overwrite writing method (Command+Shift+O).
  • Go to offset hex 40 (decimal 64) and press Tab.
  • Type BOOTDISK.
  • Save and quit.
  • In your Terminal window, type: dd if=BootSector.bin of=/dev/diskXsX bs=512 count=1 This copies the modified file to the boot sector of your SD card.
For more information on using dd see ManPages/dd
Copy the files
  • Using Disk Utility, mount the card.
  • Copy the file DISKBOOT.BIN to the first partition of your SD card. Make sure to use the correct version for your model of Canon camera.
  • If PS.FIR is included in the autobuild, copy PS.FIR to the first partition of your SD card.
  • Copy ver.req to the second partition. (This is optional, but guarantees full CHDK functionality.)
  • Copy the CHDK folder to the second partition.
  • Eject the SD card.
  • Slide the tab to the LOCK position.
It is necessary to LOCK the SD card to load the CHDK software. With the card locked and the camera running CHDK, you are still able to record pictures on the card.


You now have a bootable SD card with two partitions with CHDK properly installed. The camera will now attempt to load the DISKBOOT.BIN file whenever the camera is started with that SD card (when it is locked). Note: unlocking the SD card will disable CHDK, and subsequently give the camera access to only the first partition. Thus you will be unable to record any images.

Using CHDK

Now that CHDK is properly installed on your Canon camera. It is time to learn how to use it at: CHDK Usage

Converting RAW Files

There are many software packages available to convert .CWR files into more portable formats like .TIFF and .DNG

Here are some examples:

  • DNG4PS2 FREE Mac version. Coupled with Adobe Camera RAW, this solution gave the best off the shelf results.
The pre-release binary package is a little difficult to locate on the page. Download it directly here. Note: it is a beta, and is not entirely stable.

CHDK Related Software

There are lots of related programs that may be useful here.



CHDK Scripts

CHDK/UBASIC is a good place to start when looking for CHDK scripts.

Script downloads

UBasic/Scripts Lots of useful scripts.
assemblia.com Some sample scripts.

See below for proper implementation instructions.


How to Copy Script Files Without Errors

This method uses the system text editor, TextEdit. The file has to be plain text and encoded as UTF-8 to work. Technically any editor can do it as long as it produces a plain text file with UTF-8 encoding, but the steps below use TextEdit.

NOTE: a sure fire way to know you have errant characters in your file is that the camera will give you a "parse error" immediately when you try to run the script. Like if you forgot to format the file as "plain text" on a mac. Or used Linux and forgot that Linux uses a linefeed as an end of line character instead of a carriage return.

Easy GUI Method

  1. Open TextEdit
  2. Format -> Make Plain Text
  3. Copy in code / Write your own code
  4. File -> Save As...
  5. Enter a name for the script with the ".bas" extension
  6. For Plain Text Encoding, select "Unicode (UTF-8)"
  7. Unclick If no extension is provided, use ".txt".
  8. Copy the saved script to the SD card
  9. Done!*

Alternative Terminal Method

  1. Open terminal and navigate to /Canon_DC/CHDK/SCRIPTS
  2. create a file with pico - type: pico [filename]
  3. type: print "hello world"
  4. hit control-x to exit
  5. hit y to save

Now you should be able to edit the file with TextEdit or BBEdit without trouble.

Terminal Method using Leopard

  1. Open terminal located in Applications > Utilities > Terminal
  2. Copy the version of allbest you wish to run onto your memory card cp ~/Downloads/allbest-ixus70_sd1000-101b-50.zip /Volumes/CANON_DC

Note: change CANON_DC to whatever your memory card shows as on your desktop

  1. Change to the card directory cd /Volumes/CANON_DC
  2. Unzip the file unzip allbest-ixus70_sd1000-101b-50.zip
  3. Exit the terminal exit

  • Note: If you see files entitled "._[Script Name].bas", be warned, they are NOT scripts! They are invisible files placed there by OS X, and nothing will happen if you try to run them as scripts. You might be able to delete them without adverse effects in the camera's file browser. The script you're looking for is below these files, in alphabetical order.
  • NOTE2: Those are called resource forks and have existed on the Mac forever. They contain information that associates the file with applications, creator info, etc. On the mac they don't normally even show up, but beware since the camera has no idea what to do with them and you should ONLY copy the original file name, but leave the _(Script Name).bas there so that you can edit the file(s) later again on your mac.

Still Having Trouble?

You may have issues with permissions.

Short Answer

The system Archive Utility by default does not make downloadable files executable as a security feature.

In order to get the CHDK firmware files on to an SD card from a Mac, either the files need to be decompressed with an application called The Unarchiver or Untar or StuffIt (commercial app with free unarchiver) and not the system Archive Utility, or you can make the files executable using the command line.

Long Answer

Files decompressed from Archive Utility, the embedded system utility, have an "@" at the end of the permissions string when viewed in Terminal via the command "ls -la".

The "com.apple.quarantine" attribute indicates that Apples quarantine system is flagging this file as downloaded from the internet, which normally means it won't be executed unless the user explicitely allows it. This is a security feature added in Mac OS X 10.5. As the ancient FAT file system does not naturally support extended attributes, like HFS+ does, this feature, like the famous resource forks, is emulated using hidden (i.e. with the "H"idden attribute set) files, whose names also start with a dot ".", for example "._~1". It's unclear why these files influence the camera's behaviour, but it appears to be the problem.

Note: @ means there's an extended attribute resp. there are metadata associated with that file. Removing the extended attribute via the command line (see below) should be fine. That would appear to be the only real "problem", and as of 10.5.4 it doesn't appear to add an extended attribute to it anymore anyway.

Note: These flags were not a problem with an A590is v1.01B.

Note: Extended attribute are not necessarily ACLs (access control lists), but ACLs are always extended attributes. So please do not mix these up!


Here are the results I got, once I copied the files to the SD card:

From Archive Utility:

-rwxrwxrwx@ 1 <username> <username> 127664 10 Dec 02:17 DISKBOOT.BIN -rwxrwxrwx@ 1 <username> <username> 128412 10 Dec 02:17 PS.FIR

The @ indicates an extended attribute. Using ls -la@ will show

   -rwxrwxrwx@  1 <username>  <username>   127664 10 Dec 02:17 DISKBOOT.BIN
 com.apple.quarantine        38 
  -rwxrwxrwx@  1 <username>  <username>   128412 10 Dec 02:17 PS.FIR
com.apple.quarantine        38 


Remove the Flags Using the Terminal
  • Open the Terminal. (It is found in your Applications > Utilities folder)
  • Enter these commands: (Assuming you have already installed CHDK on your SD Card)

cd /Volumes/CANON_DC

xattr -d com.apple.quarantine DISKBOOT.BIN PS.FIR


Note: if you have renamed your card from 'CANON_DC' you should make the obvious change above.

Note: Sometimes the filename PS.FI2 instead of PS.FIR is used. Please check the filename on your SD card.

Alternative Method
  • Use an unarchiver, that does not flag the files as quarantined, to decompress the original Autobuild.
Some appropriate unarchivers are The Unarchiver or Untar or StuffIt.
  • Copy the newly decompressed files to your SD card, replacing the old ones.

From The Unarchiver: -rwxrwxrwx 1 <username> <username> 127664 10 Dec 02:17 DISKBOOT.BIN -rwxrwxrwx 1 <username> <username> 128412 10 Dec 02:17 PS.FIR

Hypothetically any zip decompressing application that doesn't add the "@" flag, should allow the unziped files to work fine when copied to the SD card. Note: Windows XP doesn't add the "@" flag either.


My card does not mount as a Volume

Q. "I attached my 'supported' SD800IS via the cable to my Leopard/MacBook with the provided cable. Photo Download APP boots, but no reference to /Volumes/Canon of any kind."

What steps are missing in the instructions? With a BS in Comp Sci I can't figure it out. These instructions are simply broken. Don't bother.


A. Most Canon cameras don't mount themselves as USB mass storage devices, therefore when you connect the camera to a computer it will not show up as a drive. You need to connect the SD card to your computer using a card reader; the card will appear in your /Volumes and on the Desktop.



Thankyou: VeryGreen, and the folks at InsanelyMac, and of course, everyone at CHDK. --Oooh 11:34, 26 January 2009 (UTC)

Advertisement