Xathrya Sabertooth |
Building GCC AVR Toolchain for Slackware64 Posted: 09 Jul 2014 05:19 AM PDT In this article we will about how to build GCC AVR Toolchain for ARM architecture. The built GCC can be used to compile application into ARM’s machine codes. The toolchain then reside on /usr/local path. For this article, I use:
PreparationWe will need some disk space (~2GB should be enough). We also need root access to install it on “system-wide”. Slackware64 14.0 is optional. You can use any linux distribution you like. We will create a working directory. We will refer it as $AVRGCC, so $AVRGCC/src should really be something like ~/AVRGCC/src (the ~ means your home directory). So go ahead and create following directory structure: # set aliases export AVRGCC=~/AVRGCC export TARGET=avr export PREFIX=/usr/local export BINUTILS_BUILD=${AVRGCC}/build/binutils-build export GCC_BUILD=${AVRGCC}/build/gcc-build export GDB_BUILD=${AVRGCC}/build/gdb-build export BINUTILS_SRC=${AVRGCC}/src/binutils-2.24 export GCC_SRC=${AVRGCC}/src/gcc-4.9.0 export GDB_SRC=${AVRGCC}/src/gdb-7.7 export AVRLIBC_SRC=${AVRGCC}/src/avr-libc-1.8.0 # make base dir, original archives dir (orig), source code dir (src), # and working / building dir (build) mkdir ${AVRGCC}{,/{orig,src,build}} # Make build directory for each component mkdir ${AVRGCC}/build/{binutils,gcc,gdb}-build Acquiring the MaterialsDownload latest packages of GCC, GDB, binutils, and Newlib.You can download it using wget or alternatively download via browser and move it to $ARMGCC/orig. The version we will use is GCC 4.9.0, GDB 7.7, binutils 2.24, and newlib 2.1.0. cd ${AVRGCC}/orig wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.bz2 wget ftp://ftp.gnu.org/pub/gnu/gdb/gdb-7.7.tar.bz2 wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2 wget ftp://ftp.twaren.net/Unix/NonGNU//avr-libc/avr-libc-1.8.0.tar.bz2 wget ftp://ftp.gnu.org/pub/gnu/gmp/gmp-6.0.0a.tar.xz wget ftp://ftp.gnu.org/pub/gnu/mpc/mpc-1.0.2.tar.gz wget ftp://ftp.gnu.org/pub/gnu/mpfr/mpfr-3.1.2.tar.gz Then, extract them to src directory. cd ${AVRGCC}/src tar -jxf ${AVRGCC}/orig/gcc-4.9.0.tar.bz2 tar -jxf ${AVRGCC}/orig/gdb-7.7.tar.bz2 tar -jxf ${AVRGCC}/orig/binutils-2.24.tar.bz2 tar -jxf ${AVRGCC}/orig/avr-libc-1.8.0.tar.bz2 Next we need to download some prerequisites, especially GMP (GNU Multiple Precision), MPC (Multiple-Precision Complex), and MPFR (Multiple-Precision Floating Point Reliably) which is used for computation. The prerequisites can be downloaded by invoking following command: The MPFR, GMP, and MPC is not the latest version, but at least we can build GCC. Supposing your working directory at /home/xathrya/AVRGCC, to obtain MPDR, GMP, and MPC invoke following command: cd ${GCC_SRC} ./contrib/download_prerequisites However, the version of GMP, MPC, MPFR, PPL, CLOOG, and ISL is not the latest version. We can switch to the latest version by download the latest version and create symbolic link to it. cd ${GCC_SRC} rm {gmp,mpc,mpfr} tar -Jxf ${AVRGCC}/orig/gmp-6.0.0a.tar.xz tar -zxf ${AVRGCC}/orig/mpc-1.0.2.tar.gz tar -zxf ${AVRGCC}/orig/mpfr-3.1.2.tar.gz ln -s gmp-6.0.0 gmp ln -s mpc-1.0.2 mpc ln -s mpfr-3.1.2 mpfr Building the ToolchainsBuilding stage is pretty simple. Honestly speaking, the tricky part is about how GCC and built concept and ordering them in correct order. BinutilsFirst, built binutils. This will provide lots of useful tools in building ARM libraries and binaries (like objdump, ld, ranlib, etc). Invoke following commands: cd ${BINUTILS_BUILD} ${BINUTILS_SRC}/configure --target=${TARGET} --prefix=${PREFIX} \ --enable-interwork --enable-multilib --enable-shared make configure-host make -j4 all make install You will notice a few configure options that are really critical for getting things to work properly.
GCCNext we will build the GCC. But please note that we are only intereset on C and C++ so we will ignore other language. To built GCC, do this: cd ${GCC_BUILD} ${GCC_SRC}/configure --target=${TARGET} --prefix=${PREFIX} --enable-interwork \ --enable-multilib --enable-languages="c,c++" --with-dwarf2 --disable-libssp \ --enable-c99 --enable-long-long --enable-__cxa_atexit --enable-shared make -j4 all-gcc make -j4 all-target-libgcc make install-gcc install-target-libgcc Now, the important points are:
avr-libcNow build our avr-libc cd ${AVRLIBC_SRC} ./configure --host=avr --build=`./config.guess` --prefix=${PREFIX} make make install GDBOptionally you can build GDB. To do so, invoke following: cd ${GDB_BUILD} ${GDB_SRC}/configure --target=${TARGET} --prefix=${PREFIX} \ --enable-interwork --enable-multilib make -j4 all make install And that’s it. You should have them now. TestingThe toolchain can be tested with the minimal code here: int main() { return 0; } |
You are subscribed to email updates from Xathrya Sabertooth To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Tidak ada komentar:
Posting Komentar