Here is a script that will download and compile the gnuarm tool chain. The script by default compiles toolchain version 4.0.0 but you can modify the same by choosing the right options after launching the script.
The script will fail if the "url" for the source changes are gnuarm.com .
The script has been tested on debian 6.0 , gcc version 4.4.5.
It creates the "arm-elf-" executable in a sub directory called toolchain with it directory from whre the script is launched toolchain.sh
The script will fail if the "url" for the source changes are gnuarm.com .
The script has been tested on debian 6.0 , gcc version 4.4.5.
It creates the "arm-elf-" executable in a sub directory called toolchain with it directory from whre the script is launched toolchain.sh
First of all thnx very much for putting this information out there.
ReplyDeleteI did some minor updates due to link changes. Also these packages needs to be installed :
1. sudo apt-get update
2. sudo apt-get install gcc
3. sudo apt-get install make
Here is the latest script :
#!bin/bash
# Script to compile gnuarm tool chain. The deafult version is 4.0.0 for
# but you can chage the same by choosing the appropriate options while
# running the script
binutils_ver=2.33.1
gcc_ver=9.2.0
newlib_ver=3.1.0
binutils_url=https://ftp.gnu.org/gnu/binutils/"binutils-"$binutils_ver".tar.bz2"
gcc_url=https://ftp.gnu.org/gnu/gcc/"gcc-"$gcc_ver"/gcc-"$gcc_ver".tar.gz"
newlib_url=https://sourceware.org/pub/newlib/"newlib-"$newlib_ver".tar.gz"
echo -e "Will be downloading from \n $binutils_url \n $gcc_url \n $newlib_url"
download() {
echo "Downloading $1"
wget -c $1
if [ $? -eq 0 ]
then
echo -e "Finished downloading $1 \n"
else
echo -e "Download FAILED\n"
echo -e "Verify the url \n $1 \n and run the script again"
exit
fi
}
make_binutils() {
cd "binutils-"$binutils_ver
mkdir buildir
cd buildir
../configure --target=arm-elf --prefix=$toolchain_dir --enable-interwork --enable-multilib
if [ $? -ne 0 ]
then
echo -e "configuration failed"
exit
fi
make all install
if [ $? -ne 0 ]
then
echo -e "make failed"
exit
fi
echo -e "binutils compiles \n"
}
make_gcc() {
cd $pwd/"gcc-"$gcc_ver
mkdir buildir
cd buildir
../configure --target=arm-elf --prefix=$toolchain_dir --enable-interwork --enable-multilib --enable-languages="c,c++" --with-newlib --with-headers=$pwd/"newlib-"$n$newlib_ver/newlib/libc/include
if [ $? -ne 0 ]
then
echo -e "configuration failed"
exit
fi
make all-gcc install-gcc
if [ $? -ne 0 ]
then
echo -e "make failed"
exit
fi
echo -e "Make gcc successful \n"
}
make_newlib() {
cd $pwd/"newlib-"$newlib_ver
mkdir buildir
cd buildir
../configure --target=arm-elf --prefix=$toolchain_dir --enable-interwork --enable-multilib
if [ $? -ne 0 ]
then
echo -e "configuration failed"
exit
fi
make all install
if [ $? -ne 0 ]
then
echo -e "make failed"
exit
fi
echo -e "make newlib successful \n"
}
# **The main script begins here**
url_formation
download $binutils_url
download $gcc_url
download $newlib_url
pwd=$PWD
echo $pwd
untar_binutils="binutils-"$binutils_ver".tar.bz2"
untar_gcc="gcc-"$gcc_ver".tar.gz"
untar_newlib="newlib-"$newlib_ver".tar.gz"
tar -xjvf $pwd/$untar_binutils
tar -xjvf $pwd/$untar_gcc
tar -xzvf $pwd/$untar_newlib
toolchain_dir=$pwd/toolchain
mkdir $toolchain_dir
make_binutils
export PATH=$PATH:$toolchain_dir/bin
make_gcc
make_newlib
cd $pwd/"gcc-"$gcc_ver/buildir/
make all install
if [ $? -ne 0 ]
then
echo -e "make failed"
exit
fi
if [ -e "$toolchain_dir/bin/arm-elf-gcc" ]
then
echo -e "tool chain compiled successfully. \n"
echo -e "Toolchain available in $toolchain_dir \n"
else
echo "arm-elf-gcc not created"
fi
exit