ARM Cortex M3 - Part 3: Tool Chains
The hardest part of getting started with any of the Arm processors is getting a working toolchain. There are basically four approaches:
1) Buy something. 2) Get a free "demo" version of a commercial toolchain and live with the limitations 3) Get a free toolchain bundle that has everything prebuilt 4) Build your own tools
Since I run 64-bit Linux primarily, my choices are a bit limited. For example, CodeSourcery provides a "lite" version of their port of the gcc ARM compiler on 32 bit Linux. Granted, my 64-bit machine can probably run it, but there's no native 64-bit build.
The ST Microelectronics site has plenty of links to other prebuilt toolchains (if you are using the STM32). Many of these have limited free demos including those from Atollic, Hitex, IAR, Kiel, and Raisonance. If you are using Windows and don't mind spending money on tools, you can easily be all set.
There are some free bundles like YARGARTO (Windows only) or GNUARM. Unfortunately, GNUARM hasn't been updated in a few years so if you want the latest and greatest, you may just get stuck with option 4.
Luckily, there are some very clever scripts available that will download and build the whole tool chain for you. Thats the way I do it. It does take awhile to download and build, but once its done you know exactly what you have and can tweak it if necessary. If you have a 486 and 33.6K modem, this might not be the best answer for you, but with a good network connection and a modern processor it isn't that big of a deal.
I used the nxtOSEK script (which is modified from an original script provide by NxOS). However, there are several similar scripts out there (this one for example). When I first built the tools I found I was missing some libraries. The key is a bunch of MULTILIB options in the script. Here's what worked for me:
echo " MULTILIB_OPTIONS = marm/mthumb MULTILIB_DIRNAMES = arm thumb MULTILIB_OPTIONS += mcpu=cortex-m3 MULTILIB_DIRNAMES += cortex-m3 MULTILIB_EXCEPTIONS += marm/mcpu=cortex-m3 MULTILIB_EXCEPTIONS += mcpu=cortex-m3 MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork MULTILIB_DIRNAMES += normal interwork MULTILIB_OPTIONS += mhard-float/msoft-float MULTILIB_DIRNAMES += fpu soft MULTILIB_EXCEPTIONS += mthumb/mhard-float MULTILIB_EXCEPTIONS += mcpu=cortex-m3/m*float MULTILIB_EXCEPTIONS += mcpu=cortex-m3/m*interwork MULTILIB_EXCEPTIONS += mcpu=cortex-m3/m*interwork/m*float MULTILIB_EXCEPTIONS += mcpu=cortex-m3/m*interwork/m*float MULTILIB_EXCEPTIONS += marm/mcpu=cortex-m3/m*interwork MULTILIB_EXCEPTIONS += marm/mcpu=cortex-m3/m*interwork/m*float MULTILIB_EXCEPTIONS += marm/mcpu=cortex-m3/m*float MULTILIB_EXCEPTIONS += mthumb/mcpu=cortex-m3/mthumb-interwork MULTILIB_EXCEPTIONS += mthumb/mcpu=cortex-m3/mthumb-interwork/m*float MULTILIB_EXCEPTIONS += mthumb/mcpu=cortex-m3/mno-thumb-interwork/mhard-float MULTILIB_EXCEPTIONS += mthumb/mcpu=cortex-m3/mhard-float " >> $MULTILIB_CONFIG
Of course, if you get another script you may have to tweak it a bit differently.
At the end of it all you should be able to run the compiler and get a blinking light program or a "Hello World" running. You should even be able to debug it with the simulator or on hardware if you have the right hardware (I'll talk more about that in a future installment).
I know I'm old school and I don't mind the command line or a Makefile. But you can get Eclipse, among others, working with all of the above too. That'll be the subject of Part 4.

