The most exciting thing about this world is its ever changing quality.

Wednesday, April 29, 2009

ARM Cross Compiler on Windows

Instead of using commercial suite such as RealView, I decided to set up my own cross compiler and development enviroment. The target ARM device has a > 2.6 linux kernel running, and host as usual is on Windows.
  • Install Cygwin with gcc packages and other make tools selected.
  • Get the source for cross compiler
Dan Kegel's crosstool project provides a fully automated build script covering plenty of different architectures and compiler versions. The latest stable version can be found at http://www.kegel.com/crosstool/ or svn from googlecode:

svn checkout http://crosstool.googlecode.com/svn/trunk crosstool

There is a good reference on wikipage for other options.
  • Build the cross compiler in your enviroment for your target device
After checking out the source code, you will find several shell scripts named demo-*.sh under /src. Open the file for the architecture you require, in this case ARM, thus I chosed the demo-arm.sh file. This script has one line for each known working toolchain for this architecture. An example of the demo-arm.sh looks like this:

RESULT_TOP=/opt/crosstool
[...]
#eval `cat arm.dat gcc-4.1.0-glibc-2.2.2.dat` sh all.sh --notest
eval `cat arm.dat gcc-4.1.0-glibc-2.3.2.dat` sh all.sh --notest

If you require a gdbserver to build, you need to add --gdb to the end of the eval command. Running this shell script will build the cross compiler and gcc binaries for you under /opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-unknown-linux-gnu/bin. You will be likely to get errors as crosstool shell script won't support space in windows style directory in your HOME enviroment setting, however with not so helpful error message "...incorrect number of arguments". To get over this, 

$ printenv HOME
/cygdrive/c/Documents and Settings/
$ HOME=/cygdrive/c/DOCUME~1/
$ ./demo-arm-softfloat.sh
  • It seems a neat idea to install remote file system plugins on Eclipse (+ CDT package as I am using C++). It turned out to be quite a hurdle! I will try to post my tuning on Eclipse (on Windows) to use the cross compiler we just had and transfer binary across to remote Linux OS.

No comments: