Compiling CHDK under Linux

This is the procedure I used to compile CHDK (April 2007).
Look for the shorter alternative procedure at the end of this page.

June 2007. I have modified the procedure to use gcc-3.4.6 and
Vitaly's patch in place of gcc-4.1.2. The reason for the
change is that there is an issue with 'endianness' and
floating point numbers that is addressed by Vitaly's patch.

I compiled the CHDK with gcc-4.1.2, both 'trunk' and 'grand'
branches, with success
since April until I met a problem using the 'pow' function
under 'trunk'. The 'grand' branch addresses the issue differently
and the floating point code worked fine under the 'grand' branch when compiled
with gcc-4.1.2.

There is a 'minor' difference of behavior between the
two compilers. With gcc-4.1.2, the variable __arm__ is defined
even when the compiler is called with option -mtumb;
with gcc-3.4.6 and the patch and option -mthumb, the variable
__arm__ is not defined but variable __thumb__ is. The CHDK
file 'include/lowlevel.h' is sensitive to that difference of behavior.

The reason I used gcc-4.1.2 in the first place is that I was not
aware of Vitaly's patch.

Compiling the CHDK.

Go to either 'trunk' or 'grand'.

> cd ~/chdk/grand

Manually edit file <makefile.inc> to select PLATFORM and PLATFORMSUB for your camera: just remove the "#" comment characters. Also, add the following line at the beginning of file <makefile.inc> to tell CHDK where the arm cross compiler is,

PATH := ${HOME}/arm-elf/bin:${PATH}

You should be ready to compile everything.

> make fir

The results are left in the "bin" directory.

If you want to compile firmware for an another camera, just execute make with PLATFORM and PLATFORMSUB arguments. For example:

You may need to adjust the platform variable in last line to the model of your camera.
The ./bin/DISKBOOT.BIN need to be copied to your SD card.
If you want a PS.FI2 for auto booting, you need to follow ./platform/fi2.inc.txt to get ./bin/PS.FI2
after building CHDK.

The Gentoo way

Gentoo Linux contains a nice utility to automate this process. Emerge sys-devel/crossdev and run

crossdev -t arm-elf -s1 --without-headers --binutils 2.18-r4

This commands should compile and merge the latest gcc and binutils 2.18 (the latest binutils-2.19.1 doesn't work with chdk). Look at the versions at $PORTDIR_OVERLAY/cross-arm-elf/binutils/The first line in makefile.inc should look then like this:

GCC 4.x

A gcc 4.3.1-binutils 2.18 environment kit for Linux was available from here: chdhdev drop but the link is deadThis is the environment running on the CHDK autobuild server (19-Jan-2009), it's compiled under debian etch

Well, this works fine on Ubuntu 8.04.2.
About using the latest Gcc-4.3.3 take a look at this article.