This post includes methods to cross compile gcc source against ARM-Cortex-M3 target and use it to compile a program to blink LED in an LPC1343 board. The environment I used is Ubuntu 10. It may work with other platforms also. I tested this in Ubuntu lucid lynx and BOSS-2.6.22-3-486 ( Bharat Operating System Solutions ). This I tried referring this blog post.
- First login as root (to avoid permission headaches)
- Download the following packages and put it in a folder arm-tmp ( Google the package name to download )
- binutils-2.20.1.tar.bz2
- gmp-2.3.2.tar.bz2 (required by gcc)
- mpfr-2.3.2.tar.bz2 (required by gcc)
- gcc-4.4.5.tar.bz2
- First compile and install binutils.
- First make a directory in home folder ( /home/arun/arm-cortex-m3 in my case ) to install the binaries.
- arm-tmp$ tar -xjvf binutils-2.20.1.tar.bz2
- cd binutils-2.20.1
- ./configure --prefix=/home/arun/arm-cortex-m3 --target=arm-elf
- make -j4
- make install
- Then compile and install gmp (skip if it is installed /usr/local/lib/libgmp)
- arm-tmp$ tar -xjvf gmp-2.3.2.tar.bz2
- cd gmp-2.3.2
- ./configure
- make
- make check
- make install
- note : sometimes you may have to install m4 ( sudo apt-get install m4 )
- Then compile and install mpfr (skip if it is installed /usr/local/lib/libmpfr)
- arm-tmp$ tar -xjvf mpfr-2.3.2.tar.bz2
- cd mpfr-2.3.2
- ./configure
- make
- make install
- Then compile gcc-4.4.5.tar.bz2
- Before compiling gcc, export the following
- export LD_LIBRARY_PATH=/usr/local/lib
- export SHLIB_PATH=/usr/local/lib
- tar -xjvf gcc-4.4.5.tar.bz2
- mkdir build; cd build
- ../gcc-4.4.5/configure --prefix=/root/arm-cortex-m3 --target=arm-elf --with-cpu=cortex-m3 --with-tune=cortex-m3 --with-mode=thumb --with-float=soft --enable-languages=c --disable-libssp
- make /j4
- make install
- add this line to ~/.bashrc since the arm-elf- binaries will be in the following folder
- PATH=$PATH:/home/arun/arm-cortex-m3/bin
- restart the terminal and check if arm-elf- press TAB TAB ;) gives the toolchain ?