CHDK Wiki
Advertisement

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.



How to Install CHDK on a SD Card using a Macintosh OS X 10.5 "Leopard"

In Brief

  1. Download the appropriate autobuild.
  2. Format your SD card, or partition as FAT16.
  3. Install CHDK.
  4. Lock card.
  5. 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.

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.
  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 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).

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.


  • 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.
We will refer to the disk identifier as /dev/diskX from now on.
  • 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.
  • Unmount the partition. Do not eject.


  • Open the Terminal
  • Type: sudo newfs_msdos -F 16 -v Canon_DC -b 4096 -c 128 /dev/diskX This will reformat a FAT32 disk as FAT16, thus making it compatible with CHDK.
  • Enter your password when prompted


  • Type: dd if=/dev/diskX of=BootSector_G9.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_G9.bin file, that has been created in your Home directory, in case anything goes wrong. The BootSector_G9.bin file contains your SD card's boot sector.
  • Open BootSector_G9.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_G9.bin of=/dev/diskX bs=512 count=1 This copies the modified file to the boot sector of your SD card.


  • 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.
  • Copy ver.req to the card. (This is optional, but guarantees full CHDK functionality.)
  • Copy the CHDK folder to the card. (This is optional, but guarantees full CHDK functionality.)
  • 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.

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.


  • Open Disk Utility.
  • Select the card reader from the list of devices on the left.
  • Click the "Partition" tab in the right pane.
  • Select and resize the first partition to 5MB. Format it as MS-DOS.
  • Select the second partition and format it as MS-DOS. The size will be set automatically.
  • Click "Apply".
  • Select the first partition from the list 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.
We will refer to the disk identifier as /dev/diskX from now on.
  • Unmount the partition. Do not eject.


  • Open the Terminal
  • Type: fdisk -e /dev/diskX ie.( fdisk -e /dev/disk2s1 )
Ignore the error "fdisk: could not open MBR file ..."
  • Type: setpid 1
  • Enter 1 when prompted for new partition id.
  • Type: write
  • Type: exit
For more information on using fdisk see, ManPages/fdisk


  • Type: dd if=/dev/diskX of=BootSector_G9.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_G9.bin file, that has been created in your Home directory, in case anything goes wrong.
The BootSector_G9.bin file contains your SD card's boot sector.
  • Open BootSector_G9.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_G9.bin of=/dev/diskX bs=512 count=1 This copies the modified file to the boot sector of your SD card.
  • 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.
  • Copy ver.req to the second partition. (This is optional, but guarantees full CHDK functionality.)
  • Copy the CHDK folder to the second partition. (This is optional, but guarantees full CHDK functionality.)
  • 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's 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:



CHDK Related Software

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



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 flag 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 specifically allows it. This is a security feature added in Mac OS X 10.5. I'm not quite sure how this is implemented, or why the camera respects this flag, but it appears to be the problem.

Note: @ means there's an ACL associated with that file. Removing the ACL through whatever means (the later method included) 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 ACL to it anymore anyway.

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


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.

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 left side of the Desktop.



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

Advertisement