Building the MSP430 toolchain on Mac OS X / Most *nix'es

For a consulting project recently I was in need of an msp430 toolchain to use with the msp430f2001. Getting a working toolchain proved to be a bit of trial and error, since the official documentation for building an mspgcc toolchain is very out of date. The following instructions will show you how to build binutils-2.18, gcc-3.2.3, msp430-libc and gdb 6.8 for the msp430, hosted on Mac OS X. These instructions are also very applicable to building on other *nix systems; just skip the Mac OS X specific sections.

NOTE**: These instructions do NOT build any JTAG tools for the MSP. This is because all the jtag tools are dependant on a binary-blob driver from TI, which is only available for windows or linux. I'm looking at options for working around this, such as WINE, but so far, no luck. There appears to be an incompatibility between Parallels VM and the TI USB FET tools, so virtualizing a guest os to run the GDB proxy doesn't work either in my tests. I currently run msp430-gdbproxy on a windows laptop, and connect to it with GDB over the network.

NOTE***: mspgcc provides a global makefile in packaging/. This may or may not build a complete toolchain on OSX; I haven't tried it, but I suspect not because gcc would bomb due to the bad config.gcc check. I found the makefile after figuring out these build instructions, and in any case, I prefer having a bit more control over my build process.

These steps also available in convenient script form: build_mspgcc_osx.sh

Precompiled binaries for 10.5.5 Intel 32bit, --prefix=/opt/msp430/: msp430_osx_toolchain.tar.bz2

Steps to build
  1. Preparation / MSPGCC Checkout
    1. cd /path/to/working/directory
    2. cvs -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc login
    3. cvs -z3 -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc co -P gcc/gcc-3.3 packaging msp430-libc
    4. mkdir -p build/
    5. cd build
  2. Setup some handy variables
    1. export PREFIX=/opt/msp430/ substitute whichever install path you'd like
    2. export TARGET=msp430
    3. export CFGSTR="--prefix=${PREFIX} --target=${TARGET} --disable-nls"Disable NLS is optional; it reduces compile times, and I don't need any translations
    4. export PATH=${PATH}:${PREFIX}/bin
  3. Building Binutils
    1. curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
    2. tar -xjf binutils-2.18.tar.bz2
    3. cd binutils-2.18
    4. patch -p1 < ../../packaging/patches/binutils-2.18-14x1-20x1-20x2-20x3-22x4-42x-42x0-461x.patch
    5. patch -p1 < ../../packaging/patches/binutils-2.18-msp430x24x-msp430x26x.patch
    6. patch -p1 < ../../packaging/patches/binutils-ld_scripts.patch
    7. patch -p1 < ../../packaging/patches/binutils-2.18-430X.patch
    8. ./configure $CFGSTR
    9. make
    10. make install
    11. cd ..
  4. Building GCC
    1. curl -O ftp://mirrors.usc.edu/pub/gnu/gcc/gcc-3.2.3/gcc-core-3.2.3.tar.bz2
    2. curl -O http://www.carnelec.com/msp_osx/gcc_3.2.3_i686_darwin_thunk.patch [this patch is a hack, but it works. Only necessary on OSX / intel]
    3. tar -xjf gcc-core-3.2.3.tar.bz2
    4. cp -r ../gcc/gcc-3.3/{gcc,include,config*} gcc-3.2.3/
    5. cd gcc-3.2.3
    6. patch -p1 < ../gcc_3.2.3_i686_darwin_thunk.patch
    7. ./configure $CFGSTR
    8. make
    9. make install
    10. cd ..
  5. Building msp430-libc
    1. cp -r ../msp430-libc .
    2. curl -O http://www.carnelec.com/msp_osx/msp430_libc_tlv_prefix_fix.patch
    3. cd msp430-libc/
    4. patch -p1 < ../msp430_libc_tlv_prefix_fix.patch
    5. cd src/
    6. make
    7. make install
    8. cd ..
  6. Building GDB
    1. curl -O http://ftp.gnu.org/gnu/gdb/gdb-6.8.tar.bz2
    2. tar -xjf gdb-6.8.tar.bz2
    3. cd gdb-6.8
    4. patch -p1 < ../../packaging/patches/msp430-gdb-6.8.patch
    5. patch -p1 < ../../packaging/patches/msp430-gdb-6.8-fix.patch
    6. patch -p1 < ../../packaging/patches/gdb-6.8-430X.patch
    7. ./configure $CFGSTR
    8. make
    9. make install
    10. cd ..
Testing results

I wrote a script that tested compiling a basic program [ just WDTCTL=0 ] for each of the -mmcu settings that gcc claimed to support. The results are listed below. The fails appear to be due to an incomplete device header in msp430-libc

-mmcu settingstatus
msp430x110pass
msp430x112pass
msp430x1101pass
msp430x1111pass
msp430x1121pass
msp430x1122pass
msp430x1132pass
msp430x122pass
msp430x123pass
msp430x1222pass
msp430x1232pass
msp430x133pass
msp430x135pass
msp430x1331pass
msp430x1351pass
msp430x147pass
msp430x148pass
msp430x149pass
msp430x1471pass
msp430x1481pass
msp430x1491pass
msp430x155pass
msp430x156pass
msp430x157pass
msp430x167pass
msp430x168pass
msp430x169pass
msp430x1610pass
msp430x1611pass
msp430x1612pass
msp430x2001pass
msp430x2011pass
msp430x2002pass
msp430x2012pass
msp430x2003pass
msp430x2013pass
msp430x2101pass
msp430x2111pass
msp430x2112pass
msp430x2121pass
msp430x2122pass
msp430x2131pass
msp430x2132pass
msp430x2232pass
msp430x2234pass
msp430x2252pass
msp430x2254pass
msp430x2272pass
msp430x2274pass
msp430x233pass
msp430x235pass
msp430x2330pass
msp430x2350pass
msp430x2370pass
msp430x247pass
msp430x2471pass
msp430x248pass
msp430x2481pass
msp430x249pass
msp430x2491pass
msp430x2410pass
msp430x2416pass
msp430x2417pass
msp430x2418pass
msp430x2419pass
msp430x2616pass
msp430x2617pass
msp430x2618pass
msp430x2619pass
msp430x311pass
msp430x312pass
msp430x313pass
msp430x314pass
msp430x315pass
msp430x323pass
msp430x325pass
msp430x336pass
msp430x337pass
msp430x412pass
msp430x413pass
msp430x415pass
msp430x417pass
msp430x423pass
msp430x425pass
msp430x427pass
msp430x4250pass
msp430x4260pass
msp430x4270pass
msp430xG4250pass
msp430xG4260pass
msp430xG4270pass
msp430xE423pass
msp430xE4232pass
msp430xE4242pass
msp430xE4252pass
msp430xE425pass
msp430xE427pass
msp430xE4272pass
msp430xW423pass
msp430xW425pass
msp430xW427pass
msp430xG437pass
msp430xG438pass
msp430xG439pass
msp430x435pass
msp430x4351pass
msp430x436pass
msp430x4361pass
msp430x437pass
msp430x4371pass
msp430x447pass
msp430x448pass
msp430x449pass
msp430xG4616pass
msp430xG4617pass
msp430xG4618pass
msp430xG4619pass
msp430x4783pass
msp430x4784pass
msp430x4793pass
msp430x4794pass
msp430x5418fail
msp430x5419fail
msp430x5435fail
msp430x5436fail
msp430x5437fail
msp430x5438fail