By now, almost everyone’s managed to acquire a bajillion cheap ARM dev boards, and there are always more coming.  As these chips get cheaper, and available in more hacker-friendly packages, they’re going to overtake chips and boards like the AVR and the Arduino, it’s just a matter of time.  Unfortunately, the ARM ecosystem isn’t as simple to work with as the AVR or PIC ecosystem.  With both of these 8-bitters, you’re working in the manufacturer’s walled garden.  ARM manufacturers, on the other hand, are free to glue whatever crazy stuff they want onto the ARM core.  As a result, peripheral sets and their use vary widely, even within the same manufacturer.  Efforts like the CMSIS ameliorate this effect to some degree, but this isn’t a cake-walk.  Add on to that the difficulties in simply getting a toolchain up and running, and anyone with mere Arduino experience is lost (even more experienced 8-bit devs are going to have some tough going).

So, here’s a short guide to getting a toolchain for the STM32 series up and running quickly.  These instructions will be specific to Linux, but should translate to OSX or Windows fairly easily.

First, I downloaded the Linaro Bare-Metal ARM toolchain (  It’s important to get the Bare-Metal toolchain.  Other toolchains generate binaries that aren’t capable of running sans operating system. The bare-metal toolchain is at the bottom of the page.  This package contains the compiler, linker, debugger, and other tools used to turn source code into machine code.  I used the precompiled package from Linaro because it’s a simple off-the-shelf method to get up and running quickly.  Unlike Codesourcery/Sourcery Tools, the Linaro toolchain supports the Cortex M4 with FPU right out of the box.

In the past, I have attempted to compile their own toolchain (, but this is not a simple process.

In Linux, I just extracted the tar.gz file to the folder I wanted it to live, and added that folder to my PATH.

Next comes OpenOCD.  OpenOCD is an open source debugger/flash utility for lots and lots of different chips.  I had to get the latest dev version from the git repo, (, as the latest stable release does not include STLink code.  If a version beyond 0.5.0 is released by the time you’re reading this, download that instead.

Installation was pretty easy.  I installed the dependencies using “sudo apt-get build-dep openocd”, then ran “./bootstrap”, followed by “./configure –enable-maintainer-mode –enable-stlink”, followed by “make” and “make install”.

Once I had the toolchain and debugger up and running, I downloaded some software to compile.  This github repository ( includes the test firmware provided by ST, with a Makefile capable of building it using GCC. Chibios ( also includes demo files for all the discovery boards.

The first time I attempted to build the STM32F4 firmware, it didn’t quite work out.  Due to the varied nature of the ecosystem, a separate linker script is needed for each chip.  Furthermore, different compilers need different sections to their linker scripts, so it might not be possible to simply yank one from somewhere else.  The linker script tells the linker where different memory sections map into real, physical memory on the chip.

Here’s the linker script I eventually got working for my STM32F4-Discovery:

Makefiles themselves are beyond the scope of this post (and beyond the scope of my brain, in a lot of ways), but taking a peek at the Makefile used in the STM32F4 Demonstration firmware from above, there are  a boatload of dependencies from outside the project.  These are all CMSIS drivers, or required startup code.  This is a big part of why ARM chips are more difficult to use than ARM or PIC chips.  Fortunately, most manufacturers release some boilerplate startup code for their chips.  As long as it’s included in the makefile, everything will work as it should.

And those are the basics of going from nothing, to compiling demonstration code.  Right now, I’m looking heavily at the ChibiOS platform to develop some projects.  This abstracts a lot of the hardware stuff, although it isn’t nearly as simple as Arduino for getting up and running.  Hopefully with the upcoming release of the Arduino Due, there will be some development in making a really easy-to-use ARM platform.

Comments on this entry (13 comments)

Did you like this post? You can share your opinion with us! Simply click here.

Scott Knight

I don’t know if you’ve ever looked into it, but there’s a set of gcc ARM toolchain pre built out there that the GBA and NDS coders use. You’d have to create a custom crt0 script, but might be worth looking into since it comes with nice installers for linux/windows/mac I think.

DS oberoi

How is the object code, downloaded into the chip.

Circuit and sotware used for the pupose may be indicated.


That is highly dependent on the chip.

Lucas Pirolla

Brad, I’m using the LPC1788 chip, and developing with the LPXpresso IDE. Problem is that this IDE limits the size of the file to be flashed in 128Kb. I really need a way to overcome this. Can you help me out?

DS Oberoi

Pls. do let me the tools/programmer/etc – Open source for LPC1114FN28.
I may get sample by next weekend

DS Oberoi

Excellent article.

WIll CoIDE from work for LPC1114FN28.



There is no official support for the LPC1114FN28 in CoIDE, but it supports other chips in the same range, so you may be able to get it to work. You should contact the folks at coocox for details on that, though.


This GCC toolchain would work for that, although you’d have to spend the effort to extract libraries and linker scripts from the LPCXpresso IDE. Unfortunately, that’s a lot of work that I’m not sure how to do. If you don’t have a large existing codebase, it might be easier to start fresh with the CMSIS libraries from NXP (or others). Google around (or search github) for CMSIS LPC17xx or GCC LPC17xx, and you’ll find examples that pertain more to what you’re doing.

DS oberoi

Thanx. How to download object code to MCU LPC1114FN8.


I bought an lpc1768 dev board, i installed keil from the Included CD and checked datasheets for registers and ran some examples for the touchscreen etc, but the problem is, i want to program on linux and the samples and stuff like that tell you absolutely nothing about how they work. they tell you do this and do this and you have an example running!

do you have any idea how I can start learning everything about my lpc1768 and programming it in linux? My only experience is with Arduino which comes with an ide and is much like pc. and i wrote AVR code which only required me to install the avr compiler and simply compile it and than run avr dude, i can write programs for my lpc1768 using keil but i’ve no idea about needed libraries and what are cmsis linkers etc, can anyone help me? things sound much more complicated on arm! and i find no good resources like arduino and avr does :(
im an absolute beginner My programming experiance is mostly for pc(Qt, OpenGL, C/C++ java python android etc…)
and those don’t require you to know much about linkers etc


Before a month i bought LPC1788 development board from “”. I tried to put uboot and uclinux on this so many times but couldn’t. I flashed uboot which downloaded from “” ,In this uboot i couldn’t load linux image through tftp . While browsing google i seen your blog profile. So Please help me for this.

Thank you.


Add Your Comment