A Linux-Based Open Source Toolchain for the STM32F4

ST Microelectronics has released the STM32F4 "Discovery" evaluation board for the M4f Cortex ARM processor chip. In addition to the M4f ARM microprocessor, itself a pretty awesome tool boasting 32bit floating point precision and a vast array of assignable I/O capabilities, the STM32F4 is loaded with tons of sensors, USB hosting capabilities, and even a fully accessible ST-Link V2 programmer, which allows the user to program other M4f microprocessors. Check out this great demo / explanation here.

The board is extremely cheap, and the processor itself even cheaper (ST was actually giving these things away for free at one point), making this powerful hardware an attractive tool for the audio programmer. There must be a catch, right??


The Catch: Unless you have a spare $2K to invest, you cannot use ST's full toolchain for programming the board. The demo version is extremely crippled, only runs in windoze, and (unless I misread) has some potentially sour flavored licensing attached to it.

The Solution: Roll your own Free Open Source Toolchain!
...Of course, this is far easier said than done. I had endless struggles getting anything to work in OSX, and I'm still not sure I got it working. I had so many issues, in fact, that I don't want to waste space on them here. If I find myself in a particularly morbid mood someday, perhaps I'll tell the internets of my woes in another post. However, in Linux, setting up a toolchain and a simple workflow was comparably simple.

After literally months of toiling with various toolchains for OSX, I decided to start in with Linux using a fresh install of Ubuntu Quantal, running the 3.5.0-19-generic kernel and a lightweight Xfce windowing environment. I began by following some fantastic instructions from Jeremy Herbert.

To my dismay, running summon-arm-toolchain hung at the same point as a few of my previous attempts had in OSX: ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz . So I commented out that line in summon-arm-toolchain and manually downloaded the file in a browser, moved tar.gz into summon-arm-toolchain/sources/ and ran summon-arm-toolchain again.

Result: error "neither an int nor a vector nor an array..."

Changed OOCD_EN=1 to OOCD_EN=0 and ran summon-arm-toolchain.
Same errors:

gtype-desc.c:8834:18: error: subscripted value is neither array nor pointer nor vector
gtype-desc.c:8953:36: error: subscripted value is neither array nor pointer nor vector
gtype-desc.c:9037:31: error: subscripted value is neither array nor pointer nor vector
gtype-desc.c:9058:31: error: subscripted value is neither array nor pointer nor vector
gtype-desc.c:9065:31: error: subscripted value is neither array nor pointer nor vector
gtype-desc.c:9072:31: error: subscripted value is neither array nor pointer nor vector
make[2]: *** [gtype-desc.o] Error 1
make[2]: *** Waiting for unfinished jobs....

Blarghhh. This is where it gets ugly (as if it wasn't already). I ended up switching OOCD_EN=0 back to OOCD_EN=1, and *cough* changing the subscripted values to unsubscripted ones. I even wrote "Hail Mary" into my log files...

Believe it or not, this fix seemed to work. The script moved forward until:

* Unpacking libopencm3-f713fffde4fd6d510536b7f640e0a707726ff4ae
archive type bz2
* Building libopencm3-f713fffde4fd6d510536b7f640e0a707726ff4ae
make: *** No targets specified and no makefile found. Stop.

So I grabbed newest version of libopencm3 from git:
$ git clone git://github.com/libopencm3/libopencm3.git
And changed script from
clone libopencm3 ${LIBOPENCM3_GIT} git://libopencm3.git.sourceforge.net/gitroot/libopencm3/libopencm3
clone libopencm3 ${LIBOPENCM3_GIT} git://github.com/libopencm3/libopencm3.git

And now after adding my toolchain's path to my shell's search path, arm-none-eabi-gcc --version responds with something sensible! Mission accomplished!

I have been following Elia's great tutorial and altering his makefile to fit my other projects. The basic mechanics of using the toolchain with st-util to cross-compile and burn onto the board are posted here.

Perhaps the best part about this workflow is the lack of an IDE. All that noodling around in Eclipse really made my head hurt! I'll take a simple text editor (vim, gedit, or even pico) over all those bells and whistles any day...

If you actually read this blog and think my altered summon-arm-toolchain script or my altered makefiles would be of use to you, hit me up in the comments section.

happy coding!

4 thoughts on “A Linux-Based Open Source Toolchain for the STM32F4

  1. I'm stuck on this exact problem. Thanks for the help!

    I can probably figure out what your changes were, but it'd sure be nice if you forked the script and included your changes, then submitted a pull request so that others will not have to go through this.

    Likewise with GCC, if there's a bug, please report it. And, if there's a patch that fixes it, it'd be great to include that in the summon-arm-toolchain script as well.

  2. Hi, I have read your post at all.
    I had same message you've got.
    Could you share your efforts to me?
    Thank you 🙂

  3. Hey,

    i just changed a line in the script and now it works, also downloading newlib
    Change line 245 from: wget -c --no-passive-ftp --no-check-certificate $2 && touch ${STAMPS}/$1.fetch
    to: wget -c $2 && touch ${STAMPS}/$1.fetch

    Hope it helps somebody 😉

Leave a Reply

Your email address will not be published. Required fields are marked *