Wikia

CHDK Wiki

Changes: Compiling CHDK under Mac OS X

Edit

Back to page

m (fixed typo)
(Update instructions to match the current software situation as of Summer 2013.)
 
Line 1: Line 1:
Building CHDK requires gcc 4.3.2 and the ARM GCC toolchain.
+
Here are the necessary steps for building CHDK on a current Macintosh system.  You'll need to install Apple's Xcode plus GNU's ARM toolchain.  <span style="font-size:13px;line-height:21px;">Command examples below are all typed in a Terminal window.</span>
   
1. Install MacPorts - http://www.macports.org/install.php
+
1. Install [https://developer.apple.com/xcode/ Xcode] , the Apple development system.  It's free, but you'll need to register.  Xcode installs the compilers needed to build MacPorts and CHDK as well as other vital tools such as Subversion.  If you already have Xcode installed, check the App Store and make sure it's the latest version.
   
2. Before you install gcc you'll need a working compiler, so Apple's dev. tool (from the installation CD) should be installed.
+
2. Install [http://www.macports.org/install.php MacPorts], a package manager for installing open source software on Macs.  If you have previously installed MacPorts, run ''sudo port selfupdate''; but if your installation dates from an earlier version of MacOS, it's advisable to [https://trac.macports.org/wiki/Migration reinstall it].
   
3. Install gcc v4.3.2. from the terminal, type -
+
3. Use MacPorts to install the Gnu cross-compiler with thumb interwork multilib support:
sudo port install gcc43
+
$ sudo port install arm-elf-gcc +interwork
(type the admin password as prompted)
+
<span style="font-size:13px;line-height:21px;">4. If MacPorts has neglected to define an "arm-elf-gcc" command in /opt/local/bin, you'll need to add this manually.  Your version number may differ.</span>
(this took several hours on my macbook pro)
+
$ cd /opt/local/bin
  +
$ ln -s arm-elf-gcc-4.6.1 arm-elf-gcc
  +
5. Download the CHDK source, creating a new directory named ''chdk''.  This example downloads a stable release.  You can change the release number or replace ''branches/xxx'' with ''trunk ''if you want the latest unstable code.
  +
$ cd $HOME
  +
$ svn co https://tools.assembla.com/svn/chdk/branches/release-1_2 chdk
  +
$ cd chdk
  +
<span style="font-size:13px;line-height:21px;">6. In this newly created chdk directory (and not the subdirectory chdk/CHDK), add a new file named '''localbuildconf.inc''' that specifies your camera and its firmware level.  The file should look something like this:</span>
  +
# local configuration
  +
PLATFORM=a710
  +
PLATFORMSUB=100a
  +
7. Make sure /opt/local/bin is in your search path ($PATH).  The way to do this depends on your shell.  One example is
  +
$ export PATH=/opt/local/bin:$PATH
   
4. Install arm-elf-gcc v4.3.2 with thumb interwork multilib support - from the terminal.
+
8. Compile the CHDK firmware.
sudo port deactivate arm-elf-gcc
+
$ make fir
+
That's it!  You've just built CHDK.  The new firmware is in the ''bin'' directory.  If you copy both DISKBOOT.BIN and PS.FIR to you camera card then you're ready for either type of camera boot method.  If you'd modified any of the modules,  you'll also need to update the CHDK/MODULES directory on the camera card from the CHDK/MODULES directory in the build tree.
#&nbsp;the above command may give an ignorable error -
 
# port deactivate failed: Registry error: arm-elf-gcc not registered as installed & active"
 
 
sudo port install arm-elf-gcc +interwork
 
 
# the above command may give the fatal error
 
# "ld: duplicate symbol _init_inline_once in libbackend.a(tree-inline.o) and
 
# tree-inline.ocollect2: ld returned 1 exit status"
 
#&nbsp;still working out how to fix this, but see http://trac.macports.org/ticket/20816 (leads to diff error)
 
   
5. make gcc v4.3.2 the default compiler.
+
I've tried to make this a complete cookbook, but for greater understanding you may find it profitable to also read the [http://chdk.wikia.com/wiki/Compiling_CHDK_under_Linux Linux] installation instructions.
cd /usr/bin
 
rm gcc
 
ln -s /opt/local/bin/gcc-mp-4.3 gcc
 
   
6. make arm-elf-gcc v4.3.2 default.
+
<span style="line-height:21px;font-size:13px;">These directions for building CHDK on Macintosh were current as of summer 2013.  P</span><span style="line-height:21px;font-size:13px;">lease help keep them up to date by noting any changes you find.</span>
cd /usr/local/arm/bin
 
rm arm-elf-gcc
 
ln -s /opt/local/bin/arm-elf-gcc-4.3.2 arm-elf-gcc
 
 
From here, the directions for compiling under linux will work [[Compiling_CHDK_under_Linux]] although the directions for installing the compiler and cross compiler can be skipped.
 
 
==Troubleshooting==
 
If arm-elf-gcc doesn't compile, make sure you are using the latest version of MacPorts. To update it, type:
 
 
sudo port selfupdate
 
 
If that doesn't work, [http://www.macports.org/install.php reinstall it from the website].
 
If it gives you an error about libmpfr or something like that, type:
 
 
sudo port install mpfr
 
 
and try again.
 
==Alternative Method==
 
 
I was unable to get the above instructions working - I could install arm-elf-gcc but it failed to compile CHDK properly. Therefore I played around with the Linux instructions and managed to get something similar working on Mac OS X. I may have missed a step or two, but hopefully this is useful for someone.
 
 
1. Install the dependencies gmp, mpfr, libmpc and gettext (I used macports for this):
 
sudo port install gmp mpfr libmpc gettext
 
2. Download and extract the sources for [ftp://sourceware.org/pub/binutils/snapshots/binutils-2.17.90.tar.bz2 binutils 2.17] and [http://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2 gcc 3.4.6] to a working directory.
 
 
3. Go into the binutils directory and configure and make:
 
cd binutils-2.17.90
 
./configure --srcdir=../binutils-2.17.90 --target=arm-elf --prefix=/install/path \
 
--disable-nls --disable-libssp --disable-intl --disable-werror
 
make
 
make install
 
cd ..
 
Replace /install/path with the path where you want it to be installed. I'm not sure why srcdir is set like that, I just copied it and as it worked I didn't try without, but maybe it is not needed. disable-werror is needed because there are some warnings when building with a recent version of gcc, and by default these are treated as errors and make the build fail.
 
 
4. Make sure /install/path/bin is in your PATH
 
 
5. Do the same with gcc, applying Vitaly's patch from CHDK:
 
cd gcc-3.4.6
 
patch -p0 < /path/to/chdk/tools/patches/gcc-3.4-arm.diff
 
./configure --srcdir=../gcc-3.4.6 --target=arm-elf --enable-multilib --enable-languages=c \
 
--enable-clocale=gnu --disable-libm --disable-libc --disable-threads --disable-nls \
 
--disable-libssp --disable-intl --disable-libiberty --with-cpu=arm9 --with-newlib \
 
--prefix=/install/path
 
make
 
make install
 
cd ..
 
5. The echo command on OS X does not understand the -e flag, so you have to modify chdk/tools/gensigs.sh script and change the last line from:
 
echo -e "\t{ NULL }\n};"
 
to:
 
echo " { NULL }"
 
echo "};"
 
6. Try compiling CHDK, hopefully it now works.
 
 
[[Category:Development]]
 
[[Category:Development]]

Latest revision as of 20:40, August 17, 2013

Here are the necessary steps for building CHDK on a current Macintosh system.  You'll need to install Apple's Xcode plus GNU's ARM toolchain.  Command examples below are all typed in a Terminal window.

1. Install Xcode , the Apple development system.  It's free, but you'll need to register.  Xcode installs the compilers needed to build MacPorts and CHDK as well as other vital tools such as Subversion.  If you already have Xcode installed, check the App Store and make sure it's the latest version.

2. Install MacPorts, a package manager for installing open source software on Macs.  If you have previously installed MacPorts, run sudo port selfupdate; but if your installation dates from an earlier version of MacOS, it's advisable to reinstall it.

3. Use MacPorts to install the Gnu cross-compiler with thumb interwork multilib support:

$ sudo port install arm-elf-gcc +interwork

4. If MacPorts has neglected to define an "arm-elf-gcc" command in /opt/local/bin, you'll need to add this manually.  Your version number may differ.

$ cd /opt/local/bin
$ ln -s arm-elf-gcc-4.6.1 arm-elf-gcc

5. Download the CHDK source, creating a new directory named chdk.  This example downloads a stable release.  You can change the release number or replace branches/xxx with trunk if you want the latest unstable code.

$ cd $HOME
$ svn co https://tools.assembla.com/svn/chdk/branches/release-1_2 chdk
$ cd chdk

6. In this newly created chdk directory (and not the subdirectory chdk/CHDK), add a new file named localbuildconf.inc that specifies your camera and its firmware level.  The file should look something like this:

# local configuration
PLATFORM=a710
PLATFORMSUB=100a

7. Make sure /opt/local/bin is in your search path ($PATH).  The way to do this depends on your shell.  One example is

$ export PATH=/opt/local/bin:$PATH

8. Compile the CHDK firmware.

$ make fir

That's it!  You've just built CHDK.  The new firmware is in the bin directory.  If you copy both DISKBOOT.BIN and PS.FIR to you camera card then you're ready for either type of camera boot method.  If you'd modified any of the modules,  you'll also need to update the CHDK/MODULES directory on the camera card from the CHDK/MODULES directory in the build tree.

I've tried to make this a complete cookbook, but for greater understanding you may find it profitable to also read the Linux installation instructions.

These directions for building CHDK on Macintosh were current as of summer 2013.  Please help keep them up to date by noting any changes you find.

Around Wikia's network

Random Wiki