CHDK Wiki
(unfinnished changes to use binutils 1.18)
No edit summary
 
(33 intermediate revisions by 13 users not shown)
Line 1: Line 1:
This page is about installing a buildenvironment with the gcc 4.3.3 compiler (newest at the time of this page creation). Originally this page used a (slightly modified or fixed) version 1.19.1 of binutils, but since it didn't work, the page is being modified to use version 1.18.
 
   
 
Here is the whole process for the impatient, just copy + paste in a console (emulator):
It hasn't been tested yet if the environment can actually work, in fact, chances are it doesn't.
 
   
 
<pre>
'''WARNING!''' ''This may '''''not''''' work - use the ordinary build method unless you want to test this!''
 
 
export ARMELF=$HOME/arm-elf
  +
export WORKAREA=$HOME/wa
   
  +
mkdir $ARMELF
Here is the original: [[Compiling_CHDK_under_Linux]]
 
  +
mkdir $WORKAREA
  +
 
export PATH=$ARMELF/bin:$PATH
  +
  +
cd $WORKAREA
 
mkdir down
 
cd down
 
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2
 
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.bz2
 
wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2
 
wget http://ftp.download-by.net/gnu/gnu/binutils/binutils-2.18.tar.bz2
   
 
cd ..
Below is how I do it with Ubuntu GNU/Linux 8.10:
 
 
for zipped in down/* ; do tar xjf $zipped ; done # Note: This may take a while.
 
ln -s $(pwd)/gmp-4.2.4 gcc-4.3.3/gmp
 
ln -s $(pwd)/mpfr-2.4.2 gcc-4.3.3/mpfr
   
 
cd binutils-2.18/
Some steps are common, so instead of reproducing it here, I just refer you to the relavant section on the page [[Compiling_CHDK_under_Linux]].
 
 
./configure --srcdir=`pwd` --target=arm-elf --prefix=${ARMELF} --disable-werror
 
make -j 3
 
make install
 
cd ..
   
 
ed gcc-4.3.3/gcc/config/arm/t-arm-elf << EOF
However, some of it I have copied.
 
 
/MULTILIB_OPTIONS/s/^M/# M/
 
/MULTILIB_DIRNAMES/s/^M/# M/
 
/mno-thumb-interwork/s/^# //
 
/normal interwork/s/^# //
 
wq
  +
EOF
   
 
mkdir gcc-4.3.3-arm-elf && cd gcc-4.3.3-arm-elf
Follow the steps for [http://chdk.wikia.com/wiki/Compiling_CHDK_under_Linux#Getting_the_source getting the source].
 
 
../gcc-4.3.3/configure --srcdir=../gcc-4.3.3 --target=arm-elf \
 
--enable-multilib --enable-languages=c --enable-clocale=gnu \
 
--disable-libm --disable-libc --disable-threads \
 
--disable-nls --disable-libssp --disable-intl \
 
--with-cpu=arm9 --with-newlib --prefix=${ARMELF}
 
(unset LIBRARY_PATH; unset CFLAGS; make -j 3 && make install) # Change "3" to "your systems number of cores" + 1
   
 
</pre>
Get the sources of gcc and binutils from a GNU repository. Decide where the cross compiler will be on your computer.
 
   
:Create some directories, and modify your path to use the cross compiler and binutils
 
   
 
This page is about installing a buildenvironment with the gcc 4.3.3 compiler (newest at the time of this page creation). Originally this page used a (slightly modified or fixed) version 2.19.1 of binutils, but since it didn't work, the page is being modified to use version 2.18.
> mkdir ~/arm-elf
 
> export PATH=${HOME}/arm-elf/bin:$PATH
 
> mkdir ~/wa
 
> cd ~/wa
 
   
  +
It has been tested and it seems to be able to build working images!
:Create a place for downloads, and download some stuff you will need. I have chosen some random mirrors here, you are free to choose whatever mirror is closer to you.
 
   
  +
A problem seems to be analysing firmware dumps with binutils 2.18 though. arm-elf-objdump raises the flag "segmentation violation", when trying to dump the firmware following the [[GPL_Disassembling|instructions]] on this wiki. Binutils 2.19.1 is able to do this, however, it doesn't seem to be able to compile working chdk images. Further investigation is going on. For now, I guess the solution is to have two version of binutils, one to analyse firmware, and one to build chdk images. This page only covers installing binutils 2.18, but you can install binutils 2.19.1 by replacing "2.18" with "2.19.1" in the instructions below.
Here are some mirrors: [http://gcc.gnu.org/mirrors.html gcc mirrors], [http://gmplib.org/#DOWNLOAD gmplib mirrors], [http://www.mpfr.org/mpfr-current/#download mpfr mirrors] (There appears to be only one mirror for mpfr at this time).
 
   
> mkdir down
 
> cd down
 
> wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2
 
> wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.bz2
 
> wget http://www.mpfr.org/mpfr-current/mpfr-2.4.0.tar.bz2
 
> wget http://ftp.download-by.net/gnu/gnu/binutils/binutils-2.18.tar.bz2
 
   
 
Here is the original for older gcc: [[Compiling_CHDK_under_Linux]]
:Unpack and prepare sources.
 
   
 
Below is how I do it with Ubuntu GNU/Linux 8.10:
> cd ..
 
> for zipped in down/* ; do tar xjf $zipped ; done # Note: This may take a while.
 
> ln -s $(pwd)/gmp-4.2.4 gcc-4.3.3/gmp
 
> ln -s $(pwd)/mpfr-2.4.0 gcc-4.3.3/mpfr
 
   
  +
N.B. You don't need to '''wget''' and '''ln -s''' for GMP and MPFR sources if they are already installed on your computer. E.g. use the the following on Ubuntu:
:Fix errors in binutils:
 
  +
: libgmp3-dev - Multiprecision arithmetic library developers tools
  +
: libmpfr-dev - multiple precision floating-point computation developers tools
   
  +
If you prefer to use the ubuntuversion of those libraries, you can use the followring command instead:
> ed binutils-2.18/gas/config/tc-arm.c
 
  +
: &gt; sudo apt-get install libgmp3-dev libmpfr-dev
> /as_bad (_([^"]/s/(_(/("%s", _(/
 
> /as_bad (_([^"]/s/(_(/("%s", _(/
 
> /as_bad (_([^"]/s/(_(/("%s", _(/
 
> /as_bad (_([^"]/s/(_(/("%s", _(/
 
> /as_bad (_([^"]/s/(_(/("%s", _(/
 
> wq
 
   
  +
The following assume that you're getting the newer sources for those libraries.
It is nessesary to repeat the command to ed 5 times, as there are 5 similar errors in version 2.18 (and 2.19.1) of binutils. According to a post on the mailinglist, the developers do have a patch to fix this in the next version.
 
   
 
Some steps are common, so instead of reproducing it here, I just refer you to the relavant section on the page [[Compiling_CHDK_under_Linux]].
:Now we're ready to build binutils
 
   
 
However, some of it I have copied.
> cd binutils-2.18/
 
> ./configure --srcdir=../binutils-2.18 --target=arm-elf --prefix=${HOME}/arm-elf
 
> make -j
 
> make install
 
> cd ..
 
   
 
Follow the steps for [http://chdk.wikia.com/wiki/Compiling_CHDK_under_Linux#Getting_the_source getting the source].
:Configure gcc (Thanks to Geekmug [[User:Geekmug/Compiling_CHDK_under_Windows#Building_gcc]])
 
   
 
Get the sources of gcc and binutils from a GNU repository. Decide where the cross compiler will be on your computer.
> ed gcc-4.3.3/gcc/config/arm/t-arm-elf
 
> /MULTILIB_OPTIONS/s/^M/# M/
 
> /MULTILIB_DIRNAMES/s/^M/# M/
 
> /mno-thumb-interwork/s/^# //
 
> /normal interwork/s/^# //
 
> wq
 
   
 
:Create some directories, and modify your path to use the cross compiler and binutils
:Compile gcc
 
  +
# Choose path destination for ARM cc and working area
  +
export ARMELF=$HOME/arm-elf
  +
export WORKAREA=$HOME/wa
  +
  +
mkdir $ARMELF
  +
mkdir $WORKAREA
  +
  +
export PATH=$ARMELF/bin:$PATH
  +
  +
cd $WORKAREA
   
 
:Create a place for downloads, and download some stuff you will need. I have chosen some random mirrors here, you are free to choose whatever mirror is closer to you.
> mkdir gcc-4.3.3-arm-elf && cd gcc-4.3.3-arm-elf
 
> ../gcc-4.3.3/configure --srcdir=../gcc-4.3.3 --target=arm-elf \
 
--enable-multilib --enable-languages=c --enable-clocale=gnu \
 
--disable-libm --disable-libc --disable-threads \
 
--disable-nls --disable-libssp --disable-intl \
 
--with-cpu=arm9 --with-newlib --prefix=${HOME}/arm-elf
 
> (unset LIBRARY_PATH; unset CFLAGS; make -j2 && make install) # Change "-j2" if you don't have two cores
 
   
 
Here are some mirrors: [http://gcc.gnu.org/mirrors.html gcc mirrors], [http://gmplib.org/#DOWNLOAD gmplib mirrors], [http://www.mpfr.org/mpfr-current/#download mpfr mirrors] (There appears to be only one mirror for mpfr at this time). It should be noted that mpfr is now
Thats it! You should now have a working buildenvironment, and you can continue from "Compiling the CHDK." at [[Compiling_CHDK_under_Linux]].
 
  +
at version 2.4.1, and 2.4.1 has been substituted for 2.4.0 in all that follows. if you cannot use 2.4.1 find mpfr-2.4.0, but check the [http://www.mpfr.org/mpfr-current/#changes security problem] this version has first.
 
mkdir down
  +
cd down
 
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2
 
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.bz2
 
wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2
 
wget http://ftp.download-by.net/gnu/gnu/binutils/binutils-2.18.tar.bz2
   
 
:Unpack and prepare sources.
'''WARNING: chdk will build with this version of binutils - but the images build wont work!'''
 
 
cd ..
 
for zipped in down/*&nbsp;; do tar xjf $zipped&nbsp;; done # Note: This may take a while.
 
ln -s $(pwd)/gmp-4.2.4 gcc-4.3.3/gmp
 
ln -s $(pwd)/mpfr-2.4.2 gcc-4.3.3/mpfr
   
 
:Now we're ready to build binutils
Here is the whole process for the impatient:
 
 
cd binutils-2.18/
 
./configure --srcdir=`pwd` --target=arm-elf --prefix=${ARMELF} --disable-werror
 
make -j 3
  +
make install
 
cd ..
   
  +
''Its nessesary for me to pass the "--disable-werror" flag to configure, since I use gcc version 4.3.3. Somewhere between version 4.1.2 and 4.3.3 gcc started producing some new warnings, and the binutils code doesn't avoid those yet. Since I doubt it will harm I included the flag above to enable gcc 4.3.3 users to compile binutils without errors.''
<pre>
 
mkdir ~/arm-elf
 
export PATH=${HOME}/arm-elf/bin:$PATH
 
mkdir ~/wa
 
cd ~/wa
 
   
  +
''Note: I received an error when executing the ./configure line. It was solved by changing the --prefix option to /home/{username}/arm-elf instead of ~/arm-elf.''
mkdir down
 
cd down
 
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2
 
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.bz2
 
wget http://www.mpfr.org/mpfr-current/mpfr-2.4.0.tar.bz2
 
wget http://ftp.download-by.net/gnu/gnu/binutils/binutils-2.19.1.tar.bz2
 
   
 
:Configure gcc (Thanks to Geekmug [[User:Geekmug/Compiling_CHDK_under_Windows#Building_gcc]])
cd ..
 
 
ed gcc-4.3.3/gcc/config/arm/t-arm-elf &lt;&lt; EOF
for zipped in down/* ; do tar xjf $zipped ; done # Note: This may take a while.
 
 
/MULTILIB_OPTIONS/s/^M/# M/
ln -s $(pwd)/gmp-4.2.4 gcc-4.3.3/gmp
 
 
/MULTILIB_DIRNAMES/s/^M/# M/
ln -s $(pwd)/mpfr-2.4.0 gcc-4.3.3/mpfr
 
 
/mno-thumb-interwork/s/^# //
 
/normal interwork/s/^# //
 
wq
  +
EOF
   
 
:Compile gcc
ed binutils-2.19.1/gas/config/tc-arm.c
 
 
mkdir gcc-4.3.3-arm-elf && cd gcc-4.3.3-arm-elf
/as_bad (_([^"]/s/(_(/("%s", _(/
 
 
../gcc-4.3.3/configure --srcdir=../gcc-4.3.3 --target=arm-elf \
/as_bad (_([^"]/s/(_(/("%s", _(/
 
/as_bad (_([^"]/s/(_(/("%s", _(/
 
/as_bad (_([^"]/s/(_(/("%s", _(/
 
/as_bad (_([^"]/s/(_(/("%s", _(/
 
wq
 
 
cd binutils-2.19.1/
 
./configure --srcdir=../binutils-2.19.1 --target=arm-elf --prefix=${HOME}/arm-elf
 
make -j
 
make install
 
cd ..
 
 
ed gcc-4.3.3/gcc/config/arm/t-arm-elf
 
/MULTILIB_OPTIONS/s/^M/# M/
 
/MULTILIB_DIRNAMES/s/^M/# M/
 
/mno-thumb-interwork/s/^# //
 
/normal interwork/s/^# //
 
wq
 
 
mkdir gcc-4.3.3-arm-elf && cd gcc-4.3.3-arm-elf
 
../gcc-4.3.3/configure --srcdir=../gcc-4.3.3 --target=arm-elf \
 
 
--enable-multilib --enable-languages=c --enable-clocale=gnu \
 
--enable-multilib --enable-languages=c --enable-clocale=gnu \
 
--disable-libm --disable-libc --disable-threads \
 
--disable-libm --disable-libc --disable-threads \
 
--disable-nls --disable-libssp --disable-intl \
 
--disable-nls --disable-libssp --disable-intl \
--with-cpu=arm9 --with-newlib --prefix=${HOME}/arm-elf
+
--with-cpu=arm9 --with-newlib --prefix=${ARMELF}
 
(unset LIBRARY_PATH; unset CFLAGS; make -j2 && make install) # Change "-j2" if you don't have two cores
 
 
(unset LIBRARY_PATH; unset CFLAGS; make -j 3 && make install) # Change "3" to "your systems number of cores" + 1
</pre>
 
  +
  +
  +
  +
N.B.: To compile the SX10 image (and possibly others; e.g. the SX1 image, SD1200) you might have to remove the <tt>--with-cpu=arm9</tt> flag (as noted [http://chdk.setepontos.com/index.php/topic,845.msg32025.html#msg32025 here]). If not you will receive
  +
Error: selected processor does not support `blx r12'
 
Thats it! You should now have a working buildenvironment, and you can continue from "Compiling the CHDK." at [[Compiling_CHDK_under_Linux]].
  +
[[Category:Development]]
  +
[[Category:GNU/Linux]]

Latest revision as of 15:26, 3 March 2012

Here is the whole process for the impatient, just copy + paste in a console (emulator):

export ARMELF=$HOME/arm-elf
export WORKAREA=$HOME/wa

mkdir $ARMELF  
mkdir $WORKAREA
 
export PATH=$ARMELF/bin:$PATH  
 
cd $WORKAREA
mkdir down
cd down
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.bz2
wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2
wget http://ftp.download-by.net/gnu/gnu/binutils/binutils-2.18.tar.bz2

cd ..
for zipped in down/* ; do tar xjf $zipped ; done # Note: This may take a while.
ln -s $(pwd)/gmp-4.2.4 gcc-4.3.3/gmp
ln -s $(pwd)/mpfr-2.4.2 gcc-4.3.3/mpfr

cd binutils-2.18/
./configure --srcdir=`pwd` --target=arm-elf --prefix=${ARMELF} --disable-werror
make -j 3
make install
cd ..

ed gcc-4.3.3/gcc/config/arm/t-arm-elf << EOF
/MULTILIB_OPTIONS/s/^M/# M/
/MULTILIB_DIRNAMES/s/^M/# M/
/mno-thumb-interwork/s/^# //
/normal interwork/s/^# //
wq
EOF

mkdir gcc-4.3.3-arm-elf && cd gcc-4.3.3-arm-elf
../gcc-4.3.3/configure --srcdir=../gcc-4.3.3 --target=arm-elf \
 --enable-multilib --enable-languages=c --enable-clocale=gnu \
 --disable-libm --disable-libc --disable-threads \
 --disable-nls --disable-libssp --disable-intl \
 --with-cpu=arm9 --with-newlib --prefix=${ARMELF}
(unset LIBRARY_PATH; unset CFLAGS; make -j 3 && make install) # Change "3" to "your systems number of cores" + 1


This page is about installing a buildenvironment with the gcc 4.3.3 compiler (newest at the time of this page creation). Originally this page used a (slightly modified or fixed) version 2.19.1 of binutils, but since it didn't work, the page is being modified to use version 2.18.

It has been tested and it seems to be able to build working images!

A problem seems to be analysing firmware dumps with binutils 2.18 though. arm-elf-objdump raises the flag "segmentation violation", when trying to dump the firmware following the instructions on this wiki. Binutils 2.19.1 is able to do this, however, it doesn't seem to be able to compile working chdk images. Further investigation is going on. For now, I guess the solution is to have two version of binutils, one to analyse firmware, and one to build chdk images. This page only covers installing binutils 2.18, but you can install binutils 2.19.1 by replacing "2.18" with "2.19.1" in the instructions below.


Here is the original for older gcc: Compiling_CHDK_under_Linux

Below is how I do it with Ubuntu GNU/Linux 8.10:

N.B. You don't need to wget and ln -s for GMP and MPFR sources if they are already installed on your computer. E.g. use the the following on Ubuntu:

libgmp3-dev - Multiprecision arithmetic library developers tools
libmpfr-dev - multiple precision floating-point computation developers tools

If you prefer to use the ubuntuversion of those libraries, you can use the followring command instead:

> sudo apt-get install libgmp3-dev libmpfr-dev

The following assume that you're getting the newer sources for those libraries.

Some steps are common, so instead of reproducing it here, I just refer you to the relavant section on the page Compiling_CHDK_under_Linux.

However, some of it I have copied.

Follow the steps for getting the source.

Get the sources of gcc and binutils from a GNU repository. Decide where the cross compiler will be on your computer.

Create some directories, and modify your path to use the cross compiler and binutils
# Choose path destination for ARM cc and working area
export ARMELF=$HOME/arm-elf
export WORKAREA=$HOME/wa 

mkdir $ARMELF  
mkdir $WORKAREA

export PATH=$ARMELF/bin:$PATH  

cd $WORKAREA
Create a place for downloads, and download some stuff you will need. I have chosen some random mirrors here, you are free to choose whatever mirror is closer to you.

Here are some mirrors: gcc mirrors, gmplib mirrors, mpfr mirrors (There appears to be only one mirror for mpfr at this time). It should be noted that mpfr is now at version 2.4.1, and 2.4.1 has been substituted for 2.4.0 in all that follows. if you cannot use 2.4.1 find mpfr-2.4.0, but check the security problem this version has first.

mkdir down 
cd down  
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-4.3.3/gcc-4.3.3.tar.bz2 
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.bz2 
wget http://www.mpfr.org/mpfr-2.4.2/mpfr-2.4.2.tar.bz2  
wget http://ftp.download-by.net/gnu/gnu/binutils/binutils-2.18.tar.bz2
Unpack and prepare sources.
cd ..  
for zipped in down/* ; do tar xjf $zipped ; done # Note: This may take a while.  
ln -s $(pwd)/gmp-4.2.4 gcc-4.3.3/gmp 
ln -s $(pwd)/mpfr-2.4.2 gcc-4.3.3/mpfr
Now we're ready to build binutils
cd binutils-2.18/ 
./configure --srcdir=`pwd` --target=arm-elf --prefix=${ARMELF} --disable-werror 
make -j 3 
make install  
cd ..

Its nessesary for me to pass the "--disable-werror" flag to configure, since I use gcc version 4.3.3. Somewhere between version 4.1.2 and 4.3.3 gcc started producing some new warnings, and the binutils code doesn't avoid those yet. Since I doubt it will harm I included the flag above to enable gcc 4.3.3 users to compile binutils without errors.

Note: I received an error when executing the ./configure line. It was solved by changing the --prefix option to /home/{username}/arm-elf instead of ~/arm-elf.

Configure gcc (Thanks to Geekmug User:Geekmug/Compiling_CHDK_under_Windows#Building_gcc)
ed gcc-4.3.3/gcc/config/arm/t-arm-elf << EOF 
/MULTILIB_OPTIONS/s/^M/# M/  
/MULTILIB_DIRNAMES/s/^M/# M/  
/mno-thumb-interwork/s/^# // 
/normal interwork/s/^# // 
wq 
EOF
Compile gcc
mkdir gcc-4.3.3-arm-elf && cd gcc-4.3.3-arm-elf  
../gcc-4.3.3/configure --srcdir=../gcc-4.3.3 --target=arm-elf \
--enable-multilib --enable-languages=c --enable-clocale=gnu \
--disable-libm --disable-libc --disable-threads \
--disable-nls --disable-libssp --disable-intl \
--with-cpu=arm9 --with-newlib --prefix=${ARMELF}
  
(unset LIBRARY_PATH; unset CFLAGS; make -j 3 && make install) # Change "3" to "your systems number of cores" + 1


N.B.: To compile the SX10 image (and possibly others; e.g. the SX1 image, SD1200) you might have to remove the --with-cpu=arm9 flag (as noted here). If not you will receive

Error: selected processor does not support `blx r12'

Thats it! You should now have a working buildenvironment, and you can continue from "Compiling the CHDK." at Compiling_CHDK_under_Linux.