Difference between revisions of "ARM Cross Compiler"

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
These instructions worked on both Mac OS X 10.5 and Red Hat Linux 5.3
 
These instructions worked on both Mac OS X 10.5 and Red Hat Linux 5.3
 +
 +
== Warnings and Hints for EABI==
 +
 +
I also build a gcc-4.3.4, however, when using this to compile the Qt/embedded 4.6, it gave an internal compiler error (segfault), when using the options: -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp.  Without these options the code generated will report "illegal instruction".  One solution is to use the option -mfloat-abi=soft instead, but then you don't get to use the FPU at all!
 +
 +
The proper solution is to get a patched gcc-4.3.4 and a patched binutils. For info on speedups, see: [http://martinwguy.co.uk/martin/crunch/] and [http://martinwguy.co.uk/martin/ts7250/FPU/]<br>
 +
I wrote my procedure for doing this at [[EABI on Maverick Crunch]] <br>
 +
Note that the commercial [http://www.codesourcery.com/sgpp/release1109?%40action=check_compatibility&%40template=datasheet&device=277 "CodeSourcery" cross compiler does "soft-float"], i.e. IT DOES NOT USE THE FPU!
  
 
=== Get the sources ===
 
=== Get the sources ===
  
Sources obtained from:
+
Sources obtained <font color="green">for gcc 4.2.2 (Etch):</font>
 
  curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
 
  curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
 
  curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-core-4.2.2.tar.bz2
 
  curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-core-4.2.2.tar.bz2
 
  curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-g++-4.2.2.tar.bz2
 
  curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-g++-4.2.2.tar.bz2
 
  curl -O ftp://sourceware.org/pub/gdb/releases/gdb-6.7.1.tar.bz2
 
  curl -O ftp://sourceware.org/pub/gdb/releases/gdb-6.7.1.tar.bz2
 +
 +
Sources obtained <font color="green">for gcc 4.3.2 (Lenny):</font>
 +
curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
 +
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-4.3.2.tar.bz2
 +
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-core-4.3.2.tar.bz2
 +
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-fortran-4.3.2.tar.bz2
 +
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-g++-4.3.2.tar.bz2
 +
  
 
GNU Build instructions at: http://gcc.gnu.org/install/build.html  
 
GNU Build instructions at: http://gcc.gnu.org/install/build.html  

Latest revision as of 01:02, 22 January 2010

Cross Compile Chain for ARM system TS-7390

Some hints were taken from: http://www.ethernut.de/en/documents/cross-toolchain-osx.html However, this does not work right for the TS arm platforms. These instructions worked for me with a TS-7390 board.

These instructions worked on both Mac OS X 10.5 and Red Hat Linux 5.3

Warnings and Hints for EABI

I also build a gcc-4.3.4, however, when using this to compile the Qt/embedded 4.6, it gave an internal compiler error (segfault), when using the options: -mcpu=ep9312 -mfpu=maverick -mfloat-abi=softfp. Without these options the code generated will report "illegal instruction". One solution is to use the option -mfloat-abi=soft instead, but then you don't get to use the FPU at all!

The proper solution is to get a patched gcc-4.3.4 and a patched binutils. For info on speedups, see: [1] and [2]
I wrote my procedure for doing this at EABI on Maverick Crunch
Note that the commercial "CodeSourcery" cross compiler does "soft-float", i.e. IT DOES NOT USE THE FPU!

Get the sources

Sources obtained for gcc 4.2.2 (Etch):

curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-core-4.2.2.tar.bz2
curl -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.2.2/gcc-g++-4.2.2.tar.bz2
curl -O ftp://sourceware.org/pub/gdb/releases/gdb-6.7.1.tar.bz2

Sources obtained for gcc 4.3.2 (Lenny):

curl -O ftp://gcc.gnu.org/pub/binutils/releases/binutils-2.18.tar.bz2
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-4.3.2.tar.bz2
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-core-4.3.2.tar.bz2
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-fortran-4.3.2.tar.bz2
curl -O ftp://aeneas.mit.edu/pub/gnu/gcc/gcc-4.3.2/gcc-g++-4.3.2.tar.bz2


GNU Build instructions at: http://gcc.gnu.org/install/build.html

Untar in the ~/crosscompile/ directory or some other location of choice.

Prepare the sysroot

Presumably you want to compile code on your host system for some target system. If this target system runs Linux, you'd want to be able to access all the libraries and header files from the target system on your host system. Otherwise, why bother with a cross compiler.

On the target system, create a includes.tgz from /usr/includes and libs.tgz from /usr/libs and liblibs.tgz from /lib:

 tar czvf /tmp/includes.tgz /usr/include
 tar czvf /tmp/libs.tgz         /usr/lib  /lib

On the host, expand these in the new sysroot for the target.

mkdir /usr/local/arm-linux-gnu/
cd /usr/local/arm-linux-gnu/
tar xzvf ~/include.tgz 
tar xzvf ~/libs.tgz

You should now have a copy of the relevant libraries in your /usr/local/arm-linux-gnu directory.

FIRST MAKE THE BINUTILS

On the host, go to binutils directory (where you untarred the binutils tar file, then cd into binutils-2-18), create a build-arm-linux subdirectory (mkdir build-arm-linux), and run:

For a gnu distro (Etch)

 cd build-arm-linux-gnu
 ../configure --target=arm-linux-gnu  --prefix=/usr/local/arm-linux-gnu --with-sysroot=/usr/local/arm-linux-gnu --with-local-prefix=/usr/local/arm-linux-gnu/arm-linux-gnu --disable-nls --with-gcc --with-gnu-as --with-gnu-ld 

For a gnueabi distro (Lenny)

 cd build-arm-linux-gnueabi
 ../configure --target=arm-linux-gnueabi  --prefix=/usr/local/arm-linux-gnueabi --with-sysroot=/usr/local/arm-linux-gnueabi --with-local-prefix=/usr/local/arm-linux-gnueabi/arm-linux-gnueabi --disable-nls --with-gcc --with-gnu-as --with-gnu-ld 

(Note for Mac: Check that makeinfo points to makeinfo or /usr/bin/makeinfo and not the Tex version!)

Compile and install:

make
make install

Compile GCC

On the host, go to gcc-4.2.2 directory (where you untarred gcc-4.2.2, then cd into gcc-4.2.2 directory) and configure with:

mkdir build-arm-linux-gnu

For a gnu distro (Etch)

cd build-arm-linux
../configure --target=arm-linux-gnu --prefix=/usr/local/arm-linux-gnu --with-sysroot=/usr/local/arm-linux-gnu --with-local-prefix=/usr/local/arm-linux-gnu/arm-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long 

For a gnueabi distro (Lenny)

cd build-arm-linux-gnueabi
../configure --target=arm-linux-gnueabi --prefix=/usr/local/arm-linux-gnueabi --with-sysroot=/usr/local/arm-linux-gnueabi --with-local-prefix=/usr/local/arm-linux-gnueabi/arm-linux-gnueabi --enable-nls  --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++,fortran --enable-shared --enable-c99 --enable-long-long  --with-system-zlib  --enable-mpfr --disable-libssp --disable-sjlj-exceptions 
(Some of the options were taken from the crosstool chain configuration provided by embeddedarm.com, they can also be found on the compiler of the target system, ask it with "gcc -v" on the ts7200 we get:
ts7000:~# gcc -v
Using built-in specs.
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --disable-libssp --disable-sjlj-exceptions --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1) 
)

Make sure you DO NOT have . in your PATH, this will at some point pick the wrong tools when compiling. If you get a funny "as: unrecognized option `-Qy'" error, you are using the wrong assembler. Check your PATH, try again.

Compile and install:

make 
make install

The compiler and everything needed should now be installed in /usr/local/arm-linux-gnu/bin. Add this to your path and run these versions as "arm-linux-gnu-gcc" etc.