The toolchain.

What is the toolchain?

The tool-chain consists of a compiler, assembler, linker, debugger, libraries and a number of helper programs. Its job is to compile your code into a program that can be executed on the target system. This involves the translation of your code into the target machine language and optionally linking with various helper libraries.
In addition to the tool-chain you will need a program that can be used to download your finished program to the target. You may also require a program that relay signals from the tool-chain's debugger to and from the target system.

Choosing a toolchain

Your choice of tool-chain depends on a number of factors: The target system hardware (cpu)
The target system's software (will it have a operating system?)
The host system (the computer (and operating system) you use to write your code)
Your personal preference (do you prefer a graphical or text based debugger, or a full blown integrated development environment?)

Choosing a programmer/debugger

Choosing a programmer/debugger. Some microprocessor's incorporate a JTAG interface to facilitate program download and debug. You will need a piece of hardware that can relay these JTAG signals back to an interface port on your host computer. In the past, you may have connected your host computer's parallel printer port to a JTAG programming tool. These days however, JTAG to USB converters are the norm.
JTAG programmers and debuggers can be quite expensive. They also require the sacrifice of quite a few microprocessor pins. More recently microprocessors have been making use of the SWD (Serial Wire Debug) standard. This interface requires only three microprocessor pins. Furthermore, SWD to USB interfaces are quite cheap and you will often find them included in microprocessor development systems eliminating the need for additional programming/debugging hardware.
Your choice of programmer/debugger will depend upon the type of interface your target hardware uses. It may also, to a lesser extent, depend upon the tool-chain you use. Some manufacturers (e.g. NXP's LPC Expresso boards) bundle the programmer/debugger interface with the tool-chain making it difficult to use these kits with other tool-chains.
On a personal note, I prefer to make use of tool-chains that are based on the gcc compiler suite and programmers/debuggers that work with open source utilities such as openocd and st-util.

Getting the toolchain

You can download ready to run toolchains and Integrated Development Environments (IDE's) from the following:
IAR (Kickstart edition of its ARM IDE is free but limited to 32kB code)
Keil (Kickstart edition of its ARM IDE is free but limited to 32kB code)
Raisonance (Kickstart edition of its ARM IDE is free but limited to 32kB code)
Yagarto (Windows/Mac)
Mentor/CodeSourcery provide a ready made GCC toolchain (get the EABI edition)
Personally I prefer to build the toolchain locally. If you plan to do this then you must install a compiler. On Debian or Ubuntu (or other Debian derivatives) you do this as follows:
apt-get install build-essential
Buidling a toolchain can be tedious however the nice people who developed the Summon ARM toolchain have automated most of this. This consists of a script that you execute locally. You can read more about this here
. I found that the script would not work from within my corporate firewall as the ports for connecting to a git server were blocked. There was also an issue with passive ftp which I fixed by removing the --no-passive-ftp command line argument to wget in the script.
When you have downloaded/built and installed your toolchain you should be able to execute the compiler by typing arm-none-eabi-gcc on your command line. If the program is not found then check that your PATH environment variable includes the directory where the compiler is stored. If it is not then you need to extend your PATH variable as follows:
Assuming your compiler is stored in /usr/local/bin you extend the path as follows:
You can add this to your .profile file in your home directory to make this change permanent. In future, when you log in your path will be extended automatically


I did a fresh install of Debian Wheezy and documented the process:
enable contrib non-free repositories by editing /etc/apt/sources.list (not really sure that this is required)
apt-get install build-essential git libgmp-dev libmpc-dev zlib1g-dev libncurses5-dev libftdi-dev python-yaml libexpat1-dev
mkdir sat_build
cd sat_build
git clone git://
cd summon-arm-toolchain
The summon arm toolchain downloads and compiles openocd but it is a slightly older version that does not include the stm32f0discovery board so you need to get the latest (>= version 0.6.1)
tar xvfj openocd-0.6.1.tar.bz2
cd openocd-0.6.1
./configure --enable-stlink --enable-maintainer-mode
make install

The debug interface

The STM32 discovery boards can be driven using st-util or openocd. I have found that the current version of openocd works best. I could not get the st-util program to work with the STM32F0Discovery boards although it worked well with the F4 and VL100 boards. You should get the latest openocd from here
. I needed to install additional libraries to make openocd compile (apt-get install libusb-dev (libusb-1.0.0-dev on my system)). Extract the compressed archive as follows, move into the directory that it creates and execute the following:
./configure --enable-stlink --enable-maintainer-mode
then as root or using sudo do this
make install
Openocd requires elevated privilege. You need to use su or sudo when running it.

Further reading