|Building a GNU-ARM-Toolchain - Update: With Binaries now!|
The GNU-ARM-Toolchain contains everything needed for developing and debugging ARM based systems. For Windows, there are several pre-build toolchains available on the web, namely YAGARTO or GnuARM. Those are not always up to date or might not meet your expectations. This tutorial describes all neccessary steps of how to build such a toolchain on both Windows/Cygwin and Linux. It is based on the article GNU ARM Toolchain from the Ubuntuusers.de wiki.
Since you might only be interested in obtaining a working toolchain, I decided to upload my build. It is packed with 7-Zip for heavy compression, in case you wonder about the file extension and contains all neccessary Cygwin-DLLs, so you do not have to install Cygwin on your machine. Keep in mind, that it can cause Problems, if you have multiple versions of those libraries available in PATH (you will get error messages that tell you what's wrong). I have also a Cygwin based GNU AVR toolchain installed on my computer and it works for me so.
Facts of my build:
Before starting the process, you need to prepare your machine for what it's doing.
All you need to do, is installing a few packages. I assume you're using Ubuntu, so we need sudo for that:
sudo aptitude install build-essential libgmp3-dev libmpfr-dev libx11-6 libx11-dev texinfo flex bison libncurses5 libncurses5-dbg libncurses5-dev libncursesw5 libncursesw5-dbg libncursesw5-dev zlibc
For the rest of the tutorial, I will not prepend sudo where neccessary, assuming you can guess that yourself easily.
The easiest way on Windows is using Cygwin. The drawback is, that we do not get a native Windows GNU compiler - it will always need Cygwin installed or at least the Cygwin DLLs available.
Another possibility is a cross compile under Linux. That means you're creating native Windows binaries under Linux using MinGW. If you want to use Cygwin, you can step the next lines, otherwise here is the approach in short. Install MinGW:
sudo aptitude install mingw32 mingw32-binutils mingw32-runtime
Find out the prefix, you have to append to all options of each ./configure:
find /usr -name \*mingw32\*gcc
For me it is --host=i586-mingw32msvc. That's all. I succeeded building GNU binutils that way, but got stuck with GCC. If GCC asks for gmp and mpfr, download the sources and copy it to the GCC sources root. Nevertheless, I gave up, since it worked via Cygwin for me.
As a third option, using MinGW in combination with Msys under Windows is pain and didn't work for me at all.
There are several tutorials available on the internet, that describe the installation process of Cygwin. This is not magic, just leave the defaults and you're save. The only thing you must know, is what packages you need to install for beeing able to build the toolchain. If you have enough bandwith and disk space, just select the whole "devel" section (about 400Mb). You can uninstall most of it later, if you want.
If you completed the installation, there should be a Cygwin icon on your desktop. It opens a Linux like shell, where you can execute the following commands.
3. Build Process
The build process is the same in both Linux and Windows. With last one, just use the Cygwin shell. Remember to be shure you have enough free disk space (>2.5Gb). Note: I experienced, that compiling with Cygwin takes several times longer than native in Linus. The whole process (especially GCC) takes more than three hours, depending on your machine. No time to waste, so lets start with the fist step.
Download all neccessary source packages. I used following versions:
If you want, you can try newer versions, but I honestly admit, that not all combinations work. In time of writing, it already is a rather up to date choice, that supports also newer cores like the Cortex-M3, which I use for my projects. If you choose above versions, you make a save bet.
Unpack all source packages into a folder:
tar -xf gcc-4.4.1.tar.bz2
Create build directories:
mkdir build-gcc build-binutils build-newlib build-gdb build-insight
Now we can start the build process. Do not try to compile different packages at the same time. It won't work - one package is based on another, e. g. you can't create the c library Newlib for ARM if you don't have an ARM compiler. So let's start with Binutils:
This installs the GNU Binutils to /opt/gnuarm. The created binaries must be available via $PATH, before you can continue with GCC. You can either add /opt/gnuarm/bin to your global $PATH environment variable, or simply link them to /usr/local/bin:
ln -s /opt/gnuarm/bin/* /usr/local/bin
You should do that after each build step in this tutorial, where it is not needed, it does no harm.
3.3. GCC - First act
At first we build only the cross compiler without any libraries. To enable Thumb interworking, you need to edit gcc-4.4.1/gcc/config/arm/t-arm-elf. Uncomment the following lines:
MULTILIB_OPTIONS += mhard-float/msoft-float
Then compile and install:
If you do not need c++ you can remove that from the enable-languages option and save some compile time.
Newlib is a lean c library, designed especially for microcontrollers. It does create much less overhead as the bloated glibc. Now we use the freshly installed GCC to build our ARM c-library:
If make all stops with an error message, displaying that it misses arm-elf-cc, create a symbolic link to arm-elf-gcc:
ln -s /opt/gnuarm/bin/arm-elf-gcc /opt/gnuarm/bin/arm-elf-cc
3.5. GCC - Second act
3.6. GDB and Insight
Building GDB straightforward:
Same with Insight (a GUI for GDB):
Insight tends to be a bit buggy. Try to avoid long path names and spaces for your project.
Creating Linux software packages or Windows installers is one of your strengths? If you should shake your head now, we're both in company. Luckily you can simply copy the whole /opt/gnuarm folder to whereever you want, it contains every part of the toolchain. Just remember to add the ./bin directory to $PATH or make won't find it. Cygwin users need either to install Cygwin on each machine they want to use the toolchain or add the Cygwin DLLs to the ./bin directory.
|Zuletzt aktualisiert am Samstag, den 04. Dezember 2010 um 14:09 Uhr|