If you are lucky you could use a prebuilt toolchain, however since my primary computer is a 64-bit I could not find anything usable. (This will change as 64-bit computer grow more and more popular. So maybe at the time you read this maybe this, there is one that you just can download.) Let's say that your are working on a 32bit system then odds are that you can use something from CodeSourcery, maybe the Sourcery G++ Lite for ARM EABI. Please also note that this guide is quite close to that project so you could probably use a lot of the documentation that exists there and just apply it here, http://www.codesourcery.com/sgpp/lite/arm/portal/release1033.
So I had to build my own gcc, I used these links as a guide for this page.
But I had to improvise and add some patches to get it to work, and I focused on using versions:
And a final note. When you follow the steps below you must be careful and watch so that the different steps really succeeds, because the next step depends on the last step. So do not continue until the current step is ok.
First, let's install some programs on the Ubuntu computer.
sudo apt-get install build-essential flex bison libgmp3-dev libmpfr-dev autoconf sudo apt-get install texinfo libncurses5-dev libexpat1 libexpat1-dev
Then since I kind of like vim, I always makes sure that vim is installed. And I also install some other good dev tools.
sudo apt-get install vim vim-full vim-scripts vim-doc exuberant-ctags
And a graphical diff program is also nice, in Ubuntu 8.04 I use kdiff3 but in Ubuntu 9.04 I use meld instead. Install whatever fits your needs.
Then the last thing is to decide where you would like to install the toolchain? I choosed to create and use /usr/local/cross-cortex-m3, and to make the rest a little easier to document we set a environment variable to point at that place. And I also assumes that your username is stored in $USER ("env | grep USER ; whoami").
So add this to the end of your ~/.bashrc
echo '#Multi process build ' >> ~/.bashrc
echo 'export PARALLEL=-j`getconf _NPROCESSORS_ONLN`' >> ~/.bashrc
echo '' >> ~/.bashrc
echo '#STM32 gcc...' >> ~/.bashrc
echo 'export TOOLPATH_STM32=/usr/local/stm32-cross' >> ~/.bashrc
echo 'export PATH=${TOOLPATH_STM32}/bin:$PATH' >> ~/.bashrc
echo '' >> ~/.bashrc
bash
sudo mkdir $TOOLPATH_STM32
sudo chown $USER.users $TOOLPATH_STM32
The last is so we can build a little bit faster, since there is a -j flag that specify how many jobs that can run simultaneously. So by doing this little trick you will end up with -j4 (if you run a quad cpu).
The first part is to install binutils version 2.19 (since 2.20 caused newlib not to build).
I'm going to do this building in a tmp dir in my home dir, and I'm calling that stm32-tools.
mkdir ~/stm32-tools
cd ~/stm32-tools
wget http://ftp.gnu.org/gnu/binutils/binutils-2.20.tar.bz2
tar -xvjf binutils-2.20.tar.bz2
wget http://fun-tech.se/stm32/gcc/binutils-2.20_tc-arm.c.patch
patch binutils-2.20/gas/config/tc-arm.c binutils-2.20_tc-arm.c.patch
cd binutils-2.20
mkdir build
cd build
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-interwork \
--enable-multilib \
--with-gnu-as \
--with-gnu-ld \
--disable-nls | tee ~/stm32-tools/logg.txt
make $PARALLEL | tee -a ~/stm32-tools/logg.txt
make install | tee -a ~/stm32-tools/logg.txt
cd ~/stm32-tools
wget ftp://ftp.sunet.se/pub/gnu/gcc/releases/gcc-4.4.4/gcc-4.4.4.tar.bz2
tar -xvjf gcc-4.4.4.tar.bz2
cd gcc-4.4.4
mkdir build
cd build
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-interwork \
--enable-multilib \
--enable-languages="c,c++" \
--with-newlib \
--without-headers \
--disable-shared \
--with-gnu-as \
--with-gnu-ld | tee -a ~/stm32-tools/logg.txt
make $PARALLEL all-gcc | tee -a ~/stm32-tools/logg.txt
make install-gcc | tee -a ~/stm32-tools/logg.txt
cd ~/stm32-tools
wget ftp://sources.redhat.com/pub/newlib/newlib-1.18.0.tar.gz
tar -xvzf newlib-1.18.0.tar.gz
cd newlib-1.18.0
mkdir build
cd build
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-interwork \
--disable-newlib-supplied-syscalls \
--with-gnu-ld \
--with-gnu-as \
--disable-shared | tee -a ~/stm32-tools/logg.txt
make $PARALLEL CFLAGS_FOR_TARGET="-ffunction-sections \
-fdata-sections \
-DPREFER_SIZE_OVER_SPEED \
-D__OPTIMIZE_SIZE__ \
-Os \
-fomit-frame-pointer \
-mcpu=cortex-m3 \
-mthumb \
-D__thumb2__ \
-D__BUFSIZ__=256" \
CCASFLAGS="-mcpu=cortex-m3 -mthumb -D__thumb2__" | tee -a ~/stm32-tools/logg.txt
make install | tee -a ~/stm32-tools/logg.txt
cd ~/stm32-tools
cd gcc-4.4.4/build
make $PARALLEL CFLAGS="-mcpu=cortex-m3 -mthumb" \
CXXFLAGS="-mcpu=cortex-m3 -mthumb" \
LIBCXXFLAGS="-mcpu=cortex-m3 -mthumb" \
all | tee -a ~/stm32-tools/logg.txt
make install | tee -a ~/stm32-tools/logg.txt
cd ~/stm32-tools
wget http://ftp.gnu.org/gnu/gdb/gdb-7.1.tar.bz2
tar -xvjf gdb-7.1.tar.bz2
cd gdb-7.1
mkdir build
cd build
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-languages=c,c++ \
--enable-thumb \
--enable-interwork \
--enable-multilib \
--enable-tui \
--with-newlib \
--disable-werror \
--disable-libada \
--disable-libssp | tee -a ~/stm32-tools/logg.txt
make $PARALLEL | tee -a ~/stm32-tools/logg.txt
make install | tee -a ~/stm32-tools/logg.txt
Now since Insight is based on a old gdb version,
let's rename this gdb version.
cd $TOOLPATH_STM32/bin mv arm-none-eabi-gdb arm-none-eabi-gdb-7.1 mv arm-none-eabi-gdbtui arm-none-eabi-gdbtui-7.1 mv arm-none-eabi-run arm-none-eabi-run-7.1 ln -s arm-none-eabi-gdb-7.1 arm-none-eabi-gdb ln -s arm-none-eabi-gdbtui-7.1 arm-none-eabi-gdbtui ln -s arm-none-eabi-run-7.1 arm-none-eabi-run
Then we can build a nice little gdb frontend called Insight, http://sourceware.org/insight/faq.php#q-2.2.
Since Insight is a tk program we must install some extra programs, especially in Ubuntu 9.10.
sudo apt-get install tk tk8.4 tk8.4-dev
Then we download and build it.
cd ~/stm32-tools
wget ftp://sourceware.org/pub/insight/releases/insight-6.8-1.tar.bz2
tar -xvjf insight-6.8-1.tar.bz2
cd insight-6.8-1
mkdir build
cd build
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-languages=c,c++ \
--enable-thumb \
--enable-interwork \
--enable-multilib \
--enable-tui \
--with-newlib \
--disable-werror \
--disable-libada \
--disable-libssp \
--with-expat | tee -a ~/stm32-tools/logg.txt
make $PARALLEL | tee -a ~/stm32-tools/logg.txt
make install | tee -a ~/stm32-tools/logg.txt