Prepare your SD card

This wiki page describes many ways to install CHDK on your camera's SD memory card. However a simple Java based program for Windows, Linux or Apple computers that does everything for you is available at this web site :
Simple Tool for Installing CHDK

Contents

Overview

CHDK loads from a camera's SD card into the camera's RAM memory. It extends the functionality of the camera without changing (flashing) the camera's firmware. Two methods are available to load CHDK into camera memory: the Firmware Update Method and the Bootable SD Card Method. Read the descriptions below to understand the strengths and weaknesses of each method and the step required to configure your SD card for each method.

Firmware Update Method*

Overview

The Firmware Update Method allows you to load CHDK from any SD card formatted to work in your camera. It uses the camera's built-in "Firmware Update..." menu item to load CHDK from a file called either "PS.FIR" or "PS.FI2" (depending on the camera model). It is the easiest way to load CHDK but must be done each time the camera is powered on, because CHDK does not make any permanent changes to the camera when it runs.

Note that this method does not actually update the camera's firmware. It tricks the camera into thinking it is doing a firmware update but actually causes CHDK to be loaded into RAM. No firmware "flashing" takes place.

Firmware Update Method Card Preparation

Steps to use the firmware update method are :

Start with an SD card formatted by your camera. This should happen automatically when you put a new card in the camera. If the camera does not want to format your card, it is probably already formatted.

Remove the card from your camera. Use your PC and SD card reader to unzip the appropriate CHDK distribution file for your camera model and firmware version into the main root directory of your SD card. Make sure that the CHDK folders are also copied to the SD card. Note that for this method to work, there must now be a file called either ps.fi2 or ps.fir in the root directory of the card. Beta release versions of CHDK downloaded from the CHDK forum might not contain this file. If so, then you cannot use the firmware update method for those cameras until the software is released in theCHDK Autobuild Server Also, Mac users should read the hints in FAQ Mac as as you may have issues with permissions when using Apple Archive utiliy.

Put the SD card back into in your camera.

Start your camera directly into Play Mode by pressing the Play button or Play switch. Do not start the camera with the On/Off button - the firmware update method will not work if you do.

Press the Canon Menu key and scroll around until you find a menu item that says "Firm Update...". There are usually three or four tabs in the Menu (varies by camera). You can probably stay on the first tab (typically Playback Settings) but some experimentation might be necessary.

Select "Firm Update..." and press FUNC.SET button.

CHDK splash screen

It should say "Update firmware version?" Press OK. If everything went correctly, the CHDK splash screen will appear briefly on the Camera's screen.

Go back to the camera mode and you should see some new OSD (on screen display) elements.

Activate the CHDK menus with the <ALT> key or key sequence defined for your camera.

Bootable SD Card Method

Overview

CHDK can be configured so that it automatically loads each time your camera starts. This is done via the "Bootable SD Card" method of loading and requires that the SD card be setup specially for this purpose. To use this method, format and load the card using the instructions below, and then set the card's lock switch (the little slider mechanism on the side of the SD card) to the "LOCK" position. Insert the card into your camera and turn it on normally - you should briefly see the CHDK logo, indicating that CHDK has successfully loaded.

Note that your SD card needs to be "bootable" to use the SD Card Lock method. This means that for cameras released prior to January 2011 there needs to be a FAT16 partition with a slightly modified boot block. Cameras released after January 2011 can boot from either a FAT16 or a FAT32 partition, although each format requires a different modifications to the boot block.

Setup of the SD card is somewhat complicated as different cameras have different requirements and limitations. Listed below are various methods of configuring and SD card for the "SD Card Lock" method.

Note : setting up an SD card to be bootable is not the same thing as setting the "boot" flag in the card's MBR. That flag is ignored by Canon cameras.

Bootable SD Card Method Preparation

Bootable SD Card Format Options

There are several possible configurations that can be used to enable the Bootable SD Card method of loading CHDK. The best method to use depends on when your camera was released, the size of your SD card and your tolerance for needing to take extra steps with some configurations. Details of what to do in each situation are given below.

For Cameras Released After 2010 :

With recent cameras a single FAT32 partition configured to be bootable is the preferred SD card configuration for automatically loading CHDK.

Some recent cameras format SD cards as exFAT. This format cannot be used for autobooting - you must reformat these cards as FAT32 on your PC. Note also that newer cameras do not support dual partition CHDK booting.

You can also use a single FAT16 partition if your card is 4G or smaller (or if you are willing to just use 4G of a larger card). You might choose to use a FAT16 partition because you wish to use one of the automated configuration tool (see below) and that tool does not support FAT32 booting.

There are quite a few method of setting up an SD Card for cameras released after 2010. Listed below are two easy ones - alternative methods can be found at the bottom of this wiki page. Note : use the second method if you are using a CHDK version that has no ps.fi2 file available in the distribution zup file ( eg : a camera still under development or a camera like the S100 where its just not available).

Method 1 - Using a CHDK itself to make the SD card bootable.

Start out with the SD Card Lock switch in the unlocked position (there will be a small slide switch on the side of the card - see picture above - make sure it is in the unlocked position to start this process.)

Low level format the card in camera. The card should now contain a single FAT32 partition. If you are using a large SD card, please make sure your camera did not format the card as exFAT - see warning note at start of this section. You may need to use something like FAT32 Format to format the card in your PC if so. (Warning : any images on the card will be erased at this point.)

Remove the card from your camera and put it into the SD card reader of your PC. Unpack the appropriate build of CHDK for your camera and firmware version directly to the card (including all subdirectories).

With the Card Lock switch still in the unlocked position put the card back into your camera.

Turn on your camera by pressing the Play button (or using the Play switch on some cameras). Do not start the camera with the On/Off switch or this process will not work.

Start CHDK manually by selecting the Firmware Update option in the Canon menus.

After the CHDK logo briefly displays, start CHDK by using the <ALT> key sequence for your camera.

Turn your camera off, write protect the SD card by moving the little switch on the side of the card to the locked position, insert the card back into your camera. Note that CHDK will cause the camera to ignore the lock switch so that you can take pictures normally.

​Method 2 - Using EOSCard to make the SD card bootable.

Start out with the SD Card Lock switch in the unlocked position (there will be a small slide switch on the side of the card - see picture above - make sure it is in the unlocked position to start this process.)

Low level format the card in camera. The card will now contain a single FAT32 partition. (Warning : any images on the card will be erased at this point. Also, make sure your camera did not format the card as exFAT - see warning note at start of this section - you may need to use something like FAT32 Format to format the card in your PC is so. ).

Remove the card from your camera and put it into the SD card reader of your PC. Unpack the appropriate build of CHDK for your camera and firmware version directly to the card (including all subdirectories).

Use EOScard to configure your SD card to be bootable in the camera. Read the instructions on this wiki page EOScard1.2 and download the software from there.

Write protect your SD card by moving the little switch on the side of the card to the locked position, insert the card back into your camera.

Now each time that you turn your camera on, the CHDK logo should briefly display automatically, indicating that CHDK has successfully loaded.

EOScard1.2 utility will write a boot string to the correct place on a FAT32 card using Windows computers. Format your SD card as FAT32, use this utility and then unzip the correct CHDK distribution file to the SD card.

FAT32 Format allows you to format SD cards in FAT32 format - useful if you have a newer camera that only supports exFAT format (exFAT does not support CHDK booting).

LICKS the Linux Installer for CHDK and SDM can be used to create FAT32 bootable cards under Linux.

.

.

For Cameras Released Before 2011 :

With older cameras, the best booting method options depends on the size of the SD card. For cards 4G in size or smaller, the card needs to be formatted as FAT16 and configured to be bootable. For cards 8G or larger, you will need to create two partitions - a small 500K FAT16 partition configured to be bootable and a larger partition formatted as FAT32 to take up the rest of the space on the SD card.

Not all cameras support dual partitions. Check the wiki page and forum porting thread for your camera before trying to use dual partitions.

Setup the SD card by creating either a single partition (FAT16) or two partitions (a small FAT16 and a larger FAT32).

Modify the boot block of the first partition on the card by inserting the text string "BOOTDISK" at offset 0x40.

Copy the "Complete" CHDK executable distribution to the correct places on the SD card. For single partition cards, all the files and folders from the CHDK distribution file belong on that partition. For dual partition cards, all the files and folders from the CHDK distribution file belong on the large second partition except for the files DISKBOOT.BIN and either PS.FIR or PS.FI2, which belong on the smaller FAT16 bootable partition.

To simplify the steps listed above for the preparation of a CHDK SD card, several utilities are available. These utilities can partition and format bootable SD cards and download & install CHDK to those cards.

EOScard1.2 utility will write a boot string to the correct place on a single partition FAT16 card. Format your SD card as FAT16, use this utility and then unzip the correct CHDK distribution file to the SD card.

If you do not wish to use the utilities listed above, there are manual methods available for card configuration. Several of these are listed below. For cards 4G or smaller, you can also follow the instructions give above for cameras released after 2010 provided you first format your SD card as FAT16 using the card reader in your PC computer.

A Deep Dive into the Boot Process

During the boot process, a Canon P&S camera powers up and checks to see if the SD card lock switch is in the "Locked" position. If the card is locked, the camera next checks the volume boot sector of the first partition on the SD card for the signature string "BOOTDISK". This signature is stored starting at offset 0x40 (decimal 64) on a FAT16 volume and at offset 0x1E0 on a FAT32 volume. If the signature is found, the camera checks the root directory of the SD card for a file named "DISKBOOT.BIN". If found, this file is loaded into memory and control is passed to that code. Naturally, this file contains the CHDK program

Note : when loaded, CHDK causes the camera to ignore the lock the SD card, so that images may be stored.

For cameras released prior to 2011, booting only works on FAT16 volumes. The maximum size for FAT16 is 4GB so using an SD card larger than 4GB is more complicated. By dividing such cards into two partitions (volumes), one can have a small FAT16 partition (500K) from which to boot, and a much larger FAT32 volume using the rest of the SD card for storing images. When using this method, the FAT16 partition must be the first one in the partition table. When it loads, CHDK will logically swap the partitions after loading, so the camera only sees the larger one. Because of this, only the DISKBOOT.BIN file needs to be located in the smaller partition - all the other CHDK files need to be located on the larger partition. Failing to do this will mean the CHDK logo will not display at boot, menu icons will not appear and things like fonts and test scripts will not be available.

SD cards do not normally contain multiple partitions. Some operating systems, particularly Windows, do not have drivers which can properly handle SD cards with multiple partitions. Windows will only see the first partition on an SD card. Because of this, the partitions need to be "swapped" before using a card in Windows if one wishes to transfer images directly. The CHDK debug menu has an option which will do this. When moving the card back to the camera, you will have to manually start CHDK via the firmware update method (because the camera will only see the FAT32 partition, so it won't boot), and do a swap again. Alternatively, tools like sdminste.exe can be used to swap the partitions on the PC before returning the card to your camera.

It should also be noted that doing a card format in the camera will format the entire card into one volume, removing CHDK in the process.

For FAT16 cards, go to offset 0x40 (decimal 64) and type BOOTDISK in ASCII mode (as explained here). 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 you have a SDHC card that is bigger than 4Gb you have to create two partitions on the card. This can now be done entirely on the camera thanks to Thorwak's great modification and guide. Here is how to do it, more or less copied from his guide:

Low level format card in camera. The card now contains one FAT32 partition.

Unpack the small build of CHDK directly to the card using PC.

Start CHDK manually (Firmware update).

Enter the CHDK menu, and select Miscellaneous stuff -> Debug Parameters -> Create card with two partitions. CHDK now creates the boot partition as before, but also formats it using FAT12 and marks the partition bootable. (not available on all ports)

Put the card back in PC. If necessary, format the newly created 2MB partition. Re-unpack small CHDK to this partition.

Write protect the card (there is usually a switch on the side of the card; move it to the locked position).

Caveats: Windows does not seem to be able to access both partitions at once. See the note below about using Linux to fix that. Otherwise you will have to run Swap partitions before you take the card out of the camera so windows can access your photos, then repeat the last step after you put the card back in to make it boot CHDK automatically. To me, this is much better than having to start CHDK manually every time you turn on the camera!

Apple Mac

Load your SD card in a card reader (unless your camera appears as a disk drive when you connect it)

Open Disk Utility and highlight the volume. Click "Info" and look for "Disk Identifier". For me, it was /dev/disk2s1

close the Info window

With the volume highlighted (not the "drive"), click "Unmount".

From a Terminal command line, run a command like this:

sudo newfs_msdos -F 16 -v MYSDCARD -b 4096 -c 128 /dev/disk2s1

If you get an error on the Mac command line after running this command like "newfs_msdos: warning: /dev/disk2s1 is not a character device" go ahead and re-mount the drive in the Apple Disk Utility. The drive should still show up as a FAT 16 drive, you can then continue

Apple Method #3: Darwin ports installed

The instructions for the Linux direct method also work for the Mac, provided you have darwin ports installed

Open Disk Utility and click on the image for the SD card - click on "Get Info" to determine the location of the partition (such as disk4s1)

Use Disk Utility to unmount the partition

in a terminal window, type sudo hexedit /dev/disk4s1. Press enter (that's fn+return on some keyboards). Type in '40' to go to offset 0x40. Hit enter. Hit "tab" to switch to typing on the ASCII side. Type "BOOTDISK". Hit control-X and type "Y" when prompted to save.

Apple Method #4:

If you don't want to install darwinports and hexedit, you can also use the free 0xED [2], or Hex Fiend, which will work with the indirect way as well. This may be the simplest way for a Mac user to get a bootable SD disk.

Go to the Disk Utility. Select your SD card from the list at the left, and click Informations to get the disk identifier (example: disk4s1). Use this in the steps below

Using Disk Utility, unmount (don't eject!) your SD card.

Open a Terminal window and type: dd if=/dev/disk4s1 of=BootSector_G9.bin bs=512 count=1. This copies a sector of the SD card to your Mac's hard disk.

The BootSector_G9.bin file in your Home directory contains your SD card's boot sector. Make a backup of it in case anything goes wrong.

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

Copy the file DISKBOOT.BIN to the SD card. Make sure to use the correct version for your model of Canon camera.

Eject the SD card. Slide the tab to the LOCK position

Linux

Linux Method #1: Smaller SD Cards

SD card no larger than 4Gb. To start from zero, either format your card with the camera, or use GParted (or fdisk) to create a single partition on the SD card. Make sure the format is FAT16. About gparted: Note that making a single partition doesn't mean dividing the card in two parts, it means creating a single data section called a partition.

If you have a SD card that is bigger than 4Gb you have to create 2 partions on the card. The first has to be formatted with FAT16 and will hold the CHDK files for booting (1MB is enough). The second partition has to be formated with FAT32 and will hold the images.
The simplest way to do this in Linux is to install gparted. With this great GUI based partition manager you can set up the partitions. Within gparted, set the "boot" flag for the first partition. It will not work without this. Note: Windows will not be able to see the second partition holding the pictures unless you do some modification to partition table.

To make the first partition bootable use:

echo -n BOOTDISK | dd bs=1 count=8 seek=64 of=/dev/sdx1

Notes: from gparted you should already know the correct location of your card (/dev/sdb1 or b2 or a1 or a2 ....). Or by looking at dmesg just after you inserted your card it will show you your SD card device name e.g. look for a line sometine like [ 9888.596295] sdb: sdb1 then sdb1 is your device

gparted tips: Insert the card before starting gparted. If you find the 'fat16'menu option greyed out in the 'format to' menu, you may need to install dosfstools in the package manager (in this case you may also have to restart gparted). Remember to hit 'apply all operations' in the edit menu to apply the changes you made to the card before exiting gparted.

Determine the location of your card, it is usually something like /dev/sdx. If the card is mounted, you can determine the location from the mount command. Make sure you pick the right one! Replace the x in /dev/sdx appropriately.

Make sure your card is unmounted (umount /dev/sdx1)

Now, you need to alter the partition's bootsector. There are two ways to do this. This guide assumes hexedit is used, though you can use any hex editor. 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 you see FAT32, you will have to reformat the card in FAT16 - this can be easily done with mkdosfs -F 16 /dev/your_card_partition. Make sure to copy all the needed images off the card before doing this.