Toolchain for ARM on Linux

Introduction

In the guide that follows will be presented the procedure for installing a complete toolchain for ARM microcontrollers. The toolchain is based on open source software: the GNU compiler and debugger, the Eclipse integrated development environment, the OpenOCD JTAG interface manager.

The main software components being used are:

  • gcc-4.4.2 compiler
  • gdb-6.8 debugger
  • openocd-0.2.0
  • eclipse Galileo

The installation process is articulated through the following steps: updating the Linux operating system, installation of OpenOCD, installing gcc and gdb, installation of Eclipse. An internet connection is required to download the necessary software components.

Testing and fine tuning of the various packages installed here will be addressed in another page of our site that will be developed shortly.

Updating Linux

Tests for the toolchain were made on a clean installation of Ubuntu 9.10, desktop version. The first step will update and/or supplement the basic package with some necessary libraries to the various components of the toolchain. The commands were collected in a script to be run as sudo for the necessary access rights (this also applies to all the other scripts below). To execute from the command line simply type the following code:

apt-get update

apt-get dist-upgrade

apt-get install libgmp3-dev libmpfr-dev build-essential zlib1g-dev libncurses5-dev patch texinfo libreadline5-dev gawk default-jre

Some of the commands may be redundant; it is convenient, however, during installation, to follow the results presented in the terminal window to catch any problems in the script as soon as possible.

As it is preferable to know what is installed, let's go to a quick overview of the libraries selected:

  • build-essential: a set of basic packages for the recompilation of the Linux development system;
  • zlib1g-dev: development tools for compression library;
  • libncurses5-dev: development tools for the shared libraries for terminal handling;
  • patch: library to create patches for updating programs;
  • texinfo: documentation system that uses a single source file to produce both online information or documents for printing;
  • libreadline5-dev: instruments of development for librarys of management of the command line readline and history;
  • gawk: language research and the process models of text;
  • default-jre: Java runtime library standard or compatible;
  • m4: library used by GMP.

Download the upgrade script for Linux

Top

Install OpenOCD

For this step is required prior installation of package libusb-dev, i.e. development tools for USB devices programming library, then, because of using Amontec JTAG interface based on FTDI chip, it will be installed open source libfti-dev library, which contains the development tools that are alternative to proprietary library of FTDI. In that respect, it should be read what is shown on the site http://openocd.berlios.de/web/ about the inclusion of the proprietary library FTDI libftd2xx in open source applications (licensing violations).

OPENOCD=openocd-0.2.0

apt-get install libusb-dev

apt-get install libftdi-dev

mkdir build

wget -c http://download.berlios.de/openocd/$OPENOCD.tar.bz2

tar xfvj $OPENOCD.tar.bz2

cd build

../$OPENOCD/configure --enable-ft2232_libftdi

make

make install

cd ..

rm -rf build/* $OPENOCD $OPENOCD.tar.bz

After the installation of libusb-dev and dev-libftdi, the script creates the directory build, downloads the package OpenOCD-0.2.0 from Berlios site, unzips the archive and enters the build directory. From here you run the configuration file with the directive - enable-ft2232_libftdi, to compile OpenOCD dedicated to the FTDI FT2232 chip. The commands make and make install respectively shall compile OpenOCD and install the appropriate folders. The last command removes the build folder and all its contents.

Download openOCD installation script

Top

Installing gcc / gdb

The step of installing gcc and gdb is the most complex and relies on a script by Michael Fischer, planned to install the toolchain under Windows, has been modified by us in some parts. In particular:

  • scripts before exiting for any error wait for input from the keyboard;
  • the gcc source was taken as a complete file and not divided into gcc-core and gcc-gpp;
  • patch for newlib has been restored;
  • the flag D__USE_MINGW_ACCESS has been eliminated ;
  • package was installed with apt-get install m4 to compile gmp (see above Update Linux);
  • binutils package was configured with - disable-werror
  • gdb package was configured with - disable-werror/li>
  • strip script was modified unrolling the for loop.
After downloading and unpacking the archive file build-scripts.tar.gz installation requests to download software packages within the subfolder download:

  1. binutils-2.19.1
  2. gcc-4.4.2
  3. newlib-1.17.0
  4. expat-2.0.1
  5. gdb-6.8
  6. gmp-4.3.1
  7. mpfr-2.4.1

From the terminal window, being in the build-scripts folder, execute the command:

sudo ./xx-build-all.sh

This script is the main, which sequentially calls:

  • 00-set-env.sh
  • 01-build-expat.sh
  • 02-build-gmp.sh
  • 03-build-mpfr.sh
  • 04-build-binutils.sh
  • 05-build-bootgcc.sh
  • 06-build-newlib.sh
  • 07-build-gcc.sh
  • 08-build-gdb.sh
  • 09-strip.sh

If there are any problems you can also run the scripts individually. Note that if the script _env-only.sh (normally called from 00-set-env.sh) is launched separately, it must be invoked with the command

. ./_env-only.sh

in order to properly load the environment variables globally. At start every script automatically creates a text file temp.txt with the start time; at the completion of each script this file is modified into ready.txt with total time of execution.

The script uses a lot of time for full implementation, by creating a folder install with all files and folders resulting from the compilation; it is necessary, however, to keep all the intermediate results because errors could escape that are reflected in the overall toolchain operation.

After producing the install folder you can move it anywhere, updating the system PATH variable; you get this by opening the file "/etc/environment" and adding to the PATH variable the full path from the root /(... )/install/bin.

Download the installation script for gcc/gdb

Note: for the lazy is available a single archive with a complete toolchain with OpenOCD and gcc/gdb, downloading the file install.tar.bz2. The archive contains an OpenOCD setup for the Olimex LPC-2378-STK development board. With a few modifications may be possible to adapt this configuration to other cards with different micro.

Top

Installing Eclipse Galileo

Installing Eclipse Galileo is not a proper installation, so we haven't prepared a dedicated script. It's better to directly download Eclipse IDE for C/C++ Developers, unzip and run the program Eclipse. In order to add Embedded CDT debugging functionality you must download a Zylin plug-in using the following steps:

  • access the Help menu choosing the command Install New Software...
  • in the list box Work with: type in the address
    http://opensource.zylin.com/zylincdt
  • select with tick mark the proposed package (by now 4.10.1)
  • complete the installation pressing the key Next.

install new software...

Top

bluefish