Jul 7, 2011

Cross compile gcc source for arm-cortex-m3 (I am using LPC1343) in Ubuntu/BOSS

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.
  1. First login as root (to avoid permission headaches)
  2. 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
  3. 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
  4. Then compile and install gmp (skip if it is installed /usr/local/lib/libgmp)
    1. arm-tmp$ tar -xjvf gmp-2.3.2.tar.bz2 
    2. cd gmp-2.3.2
    3. ./configure
    4. make 
    5. make check
    6. make install
    7. note : sometimes you may have to install m4 ( sudo apt-get install m4 )
  5. Then compile and install mpfr (skip if it is installed /usr/local/lib/libmpfr)
    1. arm-tmp$ tar -xjvf mpfr-2.3.2.tar.bz2 
    2. cd mpfr-2.3.2
    3. ./configure
    4. make 
    5. make install
  6. Then compile gcc-4.4.5.tar.bz2
    1. Before compiling gcc, export the following
      1. export LD_LIBRARY_PATH=/usr/local/lib
      2. export SHLIB_PATH=/usr/local/lib
    2. tar -xjvf gcc-4.4.5.tar.bz2
    3. mkdir build; cd build
    4. ../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
    5. make /j4
    6. make install
    7. add this line to ~/.bashrc since the arm-elf- binaries will be in the following folder
        1. PATH=$PATH:/home/arun/arm-cortex-m3/bin
    8. restart the terminal and check if arm-elf- press TAB TAB ;) gives the toolchain ?
So we have the tool chain. See the next post ( under construction ) for how to use this compiler to compile the 'HelloWorld' for LPC1343.

For Web Developer

  open -a "Google Chrome" --args --disable-web-security