Rockbox Technical Forums

Rockbox Development => New Ports => Topic started by: BenBrown on October 27, 2013, 09:36:42 AM

Title: Build tools for Cortex-M4
Post by: BenBrown on October 27, 2013, 09:36:42 AM
A very simple script for building gcc-4.6.2 tool chain for cortex-m4 processors.  Preserving it here for perhaps future use.

Code: [Select]
echo "A simple script for building cortex toolchain mostly taken from http://cu.rious.org/make/compiling-the-arm-cortex-m4-toolchain-yourself/"
echo "Install dependancies flex bison libgmp3-dev libmpfr-dev libncurses5-dev libmpc-dev autoconf texinfo build-essential libftdi-dev libexpat1 libexpat1-dev"
echo "If you are running a 64 bit kernel installing libc6-dev-i386 maybe necessary.  I'm not sure it is, since I already had it installed"
echo "This script needs to be ran as root"
echo WARNING THIS SCRIPT DOES NOT DO ANY ERROR CHECKING
echo USE THIS SCRIPT AT YOUR OWN RISK
echo EDIT THIS SCRIPT TO CONTINUE
exit 1

echo "***Do our work in /tmp"
cd /tmp
mkdir src
cd src

echo ***Retreving and extracting sources
wget http://ftp.gnu.org/gnu/binutils/binutils-2.21.1a.tar.bz2
tar jxvf binutils-2.21.1a.tar.bz2
wget ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz
tar zxvf newlib-1.19.0.tar.gz
wget ftp://mirrors.kernel.org/gnu/gcc/gcc-4.6.2/gcc-4.6.2.tar.bz2
tar jxvf gcc-4.6.2.tar.bz2
wget http://ftp.gnu.org/gnu/gdb/gdb-7.3.1.tar.bz2
tar jxvf gdb-7.3.1.tar.bz2

echo ***Building Binary Utilities
cd binutils-2.21.1/
./configure  --target=arm-none-eabi --prefix=/usr/local/cortex --enable-interwork --enable-multilib --disable-nls --disable-libssp
make all
echo ***Installing Binary Utilities
make install
cd ..

echo ***Bootstrapping GCC
cd gcc-4.6.2/
mkdir objdir
cd objdir/
../configure --target=arm-none-eabi --prefix=/usr/local/cortex --enable-interwork --enable-multilib --enable-languages="c" --with-newlib --with-headers=../../newlib-1.19.0/newlib/libc/include/ --disable-libssp --disable-nls --with-system-zlib --with-fpu=vfp
make all-gcc
make install-gcc

echo ***linking /usr/local/cortex/bin/arm-none-eabi-* to /usr/local/bin/arm-none-eabi-*
cd /usr/local/bin/
ln -s ../cortex/bin/arm-none-eabi-addr2line
ln -s ../cortex/bin/arm-none-eabi-ar
ln -s ../cortex/bin/arm-none-eabi-as
ln -s ../cortex/bin/arm-none-eabi-c++filt
ln -s ../cortex/bin/arm-none-eabi-cpp
ln -s ../cortex/bin/arm-none-eabi-elfedit
ln -s ../cortex/bin/arm-none-eabi-gcc
ln -s ../cortex/bin/arm-none-eabi-gcc arm-none-eabi-cc
ln -s ../cortex/bin/arm-none-eabi-gcc-4.6.2
ln -s ../cortex/bin/arm-none-eabi-gcov
ln -s ../cortex/bin/arm-none-eabi-gprof
ln -s ../cortex/bin/arm-none-eabi-ld
ln -s ../cortex/bin/arm-none-eabi-ld.bfd
ln -s ../cortex/bin/arm-none-eabi-nm
ln -s ../cortex/bin/arm-none-eabi-objcopy
ln -s ../cortex/bin/arm-none-eabi-objdump
ln -s ../cortex/bin/arm-none-eabi-ranlib
ln -s ../cortex/bin/arm-none-eabi-readelf
ln -s ../cortex/bin/arm-none-eabi-size
ln -s ../cortex/bin/arm-none-eabi-strings
ln -s ../cortex/bin/arm-none-eabi-strip
cd /tmp/src/


echo ***Building NewLIB
cd newlib-1.19.0/
./configure --target=arm-none-eabi --prefix=/usr/local/cortex --enable-interwork --enable-multilib --disable-libssp --disable-nls
make all
echo ***Installing NewLIB
make install
cd ..

echo ***Building GCC
cd gcc-4.6.2/objdir/
make all
echo ***Installing GCC
make install
cd ../..

echo ***Building GDB
cd gdb-7.3.1/
./configure --target=arm-none-eabi --prefix=/usr/local/cortex --enable-interwork --enable-multilib --disable-libssp --disable-nls
make all
echo ***Installing GDB
make install

echo ***FINISHED
exit 0