views:

373

answers:

5

I am playing around with a PXA270 Xscale development board (similar to the Gumstix), and was provided a cross compiler, but it is GCC 3.3.3. I would like to learn how to build my own cross compiler, so I can customize the setup, but have had trouble getting crosstools and crosstools-ng to successfully build a toolchain. My main needs are using GCC 4.2.X and the ability to use soft float. I am running Ubuntu 9. Does anyone have any recommendations or advice on building a toolchain for such a system?

Thanks in advance,

Ben

+2  A: 

www.gnuarm.com has instructions for building your own ARM cross compiler as well as binaries available for download. They don't have GCC 4.2.x there, but I've built it using steps pretty similar to those instructions without too many problems.

Why do you want software floating point? It's going to be really slow; most applications only really need to use a fixed point implementation (read: integers).

Carl Norum
I am using a 3rd party library where I don't have access to the source so am unable to change the code to fixed point. According to - http://wiki.debian.org/ArmEabiPort - "Since the FPA floating point unit was implemented only in very few ARM cores, these days FPA instructions are emulated in kernel via Illegal instruction faults. This is of course very inefficient: about 10 times slower that -msoft-float for a FIR test program."
If you can't recompile the library, soft floating support in your compiler isn't going to help you. If your core doesn't have hardware for floating point, but your library contains FP instructions, you'll have to do as your link mentions and implement an undefined instruction exception handler to simulate floating point operations.
Carl Norum
+1  A: 

Short answer, very difficult. Longer answer, keep trying, you may stumble upon it but likely not. Xscale with hard float is more likely and just dont use any floating point. I know I tried many combinations and failed. There is a reason why the combination you are looking for normally uses the older gcc, the last one to work. You might look at codesourcery to see what they have, using there tools or learning what they are up to is likely your best bet.

dwelch
+1  A: 

I used Dan Kegel's crosstool for creating my arm cross toolchain. It took a few tries, but I was eventually able to get it right.

I recommend reviewing the matrix of build results for various architectures to help determine a suitable combination of gcc, glibc, binutils, and linux kernel headers.

The following is the script that I used to create my arm cross toolchain. I realize that my requirements are a bit different that yours, but you may be able to modify it to suit your needs.

#!/bin/sh

set -ex

# Extract crosstool
tar zxf crosstool-0.43.tar.gz
ln -sf crosstool-0.43 crosstool

# Create .dat file for toolchain
cat << EOF > $HOME/arm-cross.dat

BINUTILS_DIR=binutils-2.15
GCC_DIR=gcc-3.4.5
GCC_EXTRA_CONFIG=--with-float=soft
GCC_LANGUAGES=c,c++
GLIBC_ADDON_OPTIONS==linuxthreads,
GLIBC_DIR=glibc-2.3.6
GLIBC_EXTRA_CONFIG=--without-fp
GDB_DIR=gdb-6.5
KERNELCONFIG="\$HOME/crosstool/arm.config"
LINUX_DIR=linux-2.6.12.6
LINUX_SANITIZED_HEADER_DIR=
SHARED_MODE=--enable-shared
TARGET=arm-softfloat-linux-gnu
TARGET_CFLAGS=-O

BUILD_DIR="\$HOME/crosstool/build/\$TARGET/\$GCC_DIR-\$GLIBC_DIR"
PREFIX="/usr/crossgnu/\$GCC_DIR-\$GLIBC_DIR/\$TARGET"
SRC_DIR="\$HOME/crosstool/build/\$TARGET/\$GCC_DIR-\$GLIBC_DIR"
TARBALLS_DIR="\$HOME/downloads"
TOP_DIR="\$HOME/crosstool"

EOF

# Create toolchain directory
sudo mkdir -p /usr/crossgnu
sudo chown $USER /usr/crossgnu

# Build toolchain
pushd crosstool
eval `cat $HOME/arm-cross.dat` sh all.sh --gdb --notest
popd

Note: I had the crosstool-0.43.tar.gz tarball in the same directory I ran the script from.

jschmier
+1  A: 

If you can't manage to build a crosscompiler using crosstool*, you're unlikely be able to do so without them. It is not straightforward!

However, you can most easily get recent cross-compilers onto Ubuntu by editing /etc/apt/sources.list to include

deb http://www.emdebian.org/debian/ lenny main

then saying

apt-get update
apt-get install g{cc,++}-4.3-arm-linux-gnueabi

martinwguy
+1  A: 

I too used crosstool, and was able to build an arm-xscale-linux-gcc under Cygwin. The instructions are here: http://sourceforge.net/apps/mediawiki/imote2-linux/index.php?title=ToolsGccArm

turon