Xscale Toolchain
From Albatross
The PXA255 is an low-power microcontroller with an XScale-based ARM CPU core. The GNU compiler tools (gcc et al.) can generate binaries for the XScale CPU, with the compiler running on a normal Linux computer; this technique is known as cross-compilation. Unfortunately, putting together a working GNU gcc cross-compilation environment is tricky and prone to error. Dan Kegel has written a set of scripts to automate the process, which, together are known as Crosstool. We used Crosstool 0.35 to build a gcc-3.4.3, glibc-2.3.5, binutils-2.15 toolchain with Soft Float, and it works correctly.
Instructions
Download Crosstool 0.35, and extract to a convienient directory:
cd ~/Projects/toolchain tar -xvzf crosstool-0.35.tar.gz cd crosstool-0.35/
Now download the configuration files for Snapper PXA255 with Soft Float from here, and extract to the crosstool directory:
tar -xvzf snapper-crosstool-softfloat.tar.gz
Now edit snapper-xscale-softfloat.sh, and modify the line:
TARBALLS_DIR=$HOME/Projects/toolchain/downloads
to reflect where you extracted crosstool to. Make sure the downloads directory exists. Now modify the line:
RESULT_TOP=/opt/crosstool
to reflect where you want the toolchain installed to. It doesn't really matter because you can move it later with fix-embedded-paths. Make sure the installation path exists and is writable, with:
sudo mkdir /opt/crosstool sudo chown $USER /opt/crosstool sudo chmod 777 /opt/crosstool
Now start the build process with:
sh snapper-xscale-softfloat.sh
Crosstool will download all the source code for the toolchain, patch it as necessary, set the configuration options, compile everything, then install the toolchain.
When it is finished, set up some sym-links so the toolchain is on the path:
cd /usr/local/bin sudo ln -s /opt/crosstool/gcc-3.4.3-glibc-2.3.5/arm-xscale-linux-gnu/bin/arm-xscale-linux-gnu-gcc arm-linux-gcc sudo ln -s /opt/crosstool/gcc-3.4.3-glibc-2.3.5/arm-xscale-linux-gnu/bin/arm-xscale-linux-gnu-as arm-linux-as ... [Repeat for every program in the bin directory of the crosstool installation]
Now (assuming /usr/local/bin is on the $PATH), you can compile code with:
arm-linux-gcc -o test test.c
If you want to move the installed toolchain around your filesystem, use the fix-embedded-paths tool installed by crosstool.
Optimizations
I normally use:
arm-linux-gcc -O3 -mcpu=xscale -mtune=xscale -o test test.c
If there are any other useful optimizations, please let me know.
More Information
For more details about crosstool, see the HOWTO. See Benchmarks for more information about floating point on the Xscale core.
