The CHDK source is available from the official subversion repository. To get the current development source into a directory called chdk in your home directory use
svn co http://subversion.assembla.com/svn/chdk/trunk ~/chdk
Stable releases are available in branches named like /svn/chdk/branches/release-N_M
To update your source tree with changes added by the CHDK developers after your initial checkout, use
svn up ~/chdk
Subversion is generally available from your distro package manager. For more information about subversion usage, see the documentation.
As of late 2020, the CHDK development branch requires gcc-arm-none-eabi version 4, 5, 8, 9 or (experimentally) 10. The 1.5 stable branch requires gcc 3, 4 or 5, either none-eabi or elf (for digic 5 and below ports only). Note that CHDK is sensitive to toolchain version and configuration, and that an incorrect toolchain may result in builds that compile but do not run.
If your distro provides a supported gcc cross compiler version, simply install it using the package manager. On Debian based distros, the package is typically called gcc-arm-none-eabi, but beware that some distro versions may only offer a non-supported gcc version like 6 or 7.
If no suitable package is available, pre-compiled toolchains are available from . gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 is known to work for both the development and stable branches. Note this toolchain is 32 bit, meaning 32 bit application support may need to be enabled in your distro (see [https://chdk.setepontos.com/index.php?topic=12133.msg125084#msg125084 here). Pre-compiled toolchains are also available from https://releases.linaro.org/components/toolchain/binaries/
If you install a 3rd party toolchain, you may need to add it to your path.
You will also need to install gcc for your host platform to build various CHDK tools. Distro package managers generally include a group / meta package like build-essentials or similar. At a minimum, you need gcc, make and libc development files. Building CHDK packages also requires zip.
To build stubs (automatically identified firmware functions and variables) for Digic 6 and later, you also need the capstone libriary configured as described on Digic_6-7_Porting#Configuring_CHDK_capstone_tools. This is generally required for porting new models, but not for building existing ports or adding non-camera specific features.
To configure compile time options, copy buildconf.inc to localbuildconf.inc and edit to taste. In particular, you may want to set the default PLATFORM and PLATFORMSUB, and the paths to capstone libraries, and the OPT_GEN_STUBS settings. For the stable branch, you may also need to set OPT_USE_GCC_EABI to match your compiler.
To do a full build of a port (a2200 firmware 100b, in this example), use the following in the root of your CHDK source tree
make PLATFORM=a2200 PLATFORMSUB=100b clean fir
The compiled CHDK core binary files DISKBOOT.BIN and PS.FIR/FI2 (if enabled) are output to bin in the source directory. Modules are output in the CHDK/modules directory.
You can do an incremental build (recompiling only changed files) by omitting clean, but beware that some changes may not be correctly detected, especially in header files and makefiles.
To build a full zip package of CHDK files suitable for installing on an SD card, use
make PLATFORM=... PLATFORMSUB=... firzipsubcomplete
To build packages for all ports, use