Circle Device


Quick Reference

Building TI/RedHat's GCC from Source

This is really quite simple, though I will go though it just for fun. Remember I am using Gentoo and I don't have any bells or whistles installed.

First, download the sources from TI's site: and extract.

  • msp430-gcc-source.tar.bz2
$ tar -xf msp430-gcc-source.tar.bz2
$ cd source
$ mkdir build
$ cd build


Now you need two things that may not be installed on your system: expect (part of the TCL/TK thingy) and you will also need expat, and the static libraries!

# emerge -av dev-tcltk/expect

Change USE flags to include static-libs for dev-libs/expat... or do it the lazy and naughty way:

# USE="static-libs" emerge -av expat
$ ../tools/configure --prefix=/opt/msp430-elf --target=msp430-elf

Then make and maybe -j5 but if something goes wrong you might not be able to see it so easily but rerunning make without -j5 will let you see that problem I think

Using the newly compiled toolchain

You will now need to install it or just put the executables in your path, you should know how to do this but just incase you forgot:

# make install
$ export PATH=$PATH:/opt/msp430-elf/bin

Compiling a simple programme may not work because the required support files cannot be located by the newly installed toolchain. There are two ways to fix this: extract the into any location you like and use the compiler and linker flags -I, -L and -T. Or you could install the files somewhere the toolchain will look for them anyway.

There is a problem with the current release of the RedHat GCC, the file tools/gcc/fortran/trans-expr.c has an error on line 8726, function alloc_scalar_allocatable_for_assignment. Simply change:

else if (cm->ts.type == BT_CLASS)


else if (expr1->ts.type == BT_CLASS)

and everything should work fine, we are not using fortran anyway so perhaps we should change our configure command line to not build it?

Extract the Support Files

The support files include msp430.h and related files (msp430g2553.h etc.) along with the important .ld files which tell the linker the specific locations of the Flash, Info, SFR and RAM areas of the MCU. To avoid any special flags being passed to the compiler every time (I am thinking of -I and -L) we will put these support files where GCC will look for them anyway.

# cd /opt/msp430-elf
# unzip -x ~ben/Downloads/
# mv GCC_RH/include/* include
# rm -r GCC_RH

Now the support files are located in the /opt/msp430-elf/include directory, please make sure the permissions on the files and directories allow everyone to read them or you may have problems.

msp430-elf-gcc -mmcu=msp430g2553 -c main.c

That should have worked.

Finally to link the programme into a nice .elf file. The linker will find the location of the .ld files automatically but I have included the switch and argument in the below examples for fun, you do not need to include the -L.

msp430-elf-ld -L /opt/msp430-elf/include -T msp430g2553.ld main.o -o main.elf

Or you could do this:

msp430-elf-gcc -mmcu=msp430g2553 -L /opt/msp430-elf/include main.o -o main.elf


Final Notes

All you need now is to programme the device, for this I recommend you look at mspdebug, the most fantastic programme for this, it is available in the main portage tree dev-embedded/mspdebug and from source:

Difficulties with the newly compiled toolchain... it does not make a jump table from suitable case statements!



Quick Links: Techie Stuff | General | Personal | Quick Reference