MSP430 Launchpad development on Ubuntu

Given a nice installation of Ubuntu, what do we need to get started with MSP430 development? These instructions have been written for Ubuntu 13.04, but originally I also tried it on 12.10, so it might work for earlier versions as well.

First of all, we need some way of connecting to the Launchpad, program its flash memory, execute and break programs, step through a running program, etc. This is done using a debugger, and for MSP430 it is provided in the package mspdebug. This debugger contains some basic hardware controlling functions and assembly stepping, but it can also be used as a backend to GDB if we want to have more advanced debugging facilities, and also have the connection to our C source code. GDB itself is provided in the package gdb-msp430. Finally, we will want to compile C source code using GCC. A version of GCC that suits the MSP430 is provided in the package gcc-msp430. So, let’s install these packages!

$ sudo apt-get install mspdebug gdb-msp430 gcc-msp430

Nice and simple! If we do dpkg -L on these packages in turn, we see that gcc-msp430 contains C runtime libraries and (at least somewhat surprisingly for me) some more advanced math routines. Besides our selected packages, we also get some additional package dependencies installed automatically. Package binutils-msp430 contains utilities for handling MSP430 object files, together with assembler, linker and top-level linker scripts that we will be looking at in a later tutorial. Package msp430-libc contains an implementation of most of the functions of a standard libc, along with relevant standard header files. Finally, package msp430mcu contains include files and lower-level linker scripts for all the different MSP430 versions.

Now, we should be ready to try connecting to the Launchpad, so let’s go ahead and plug in the USB cable from the Launchpad. Typing the command

$ dmesg

we should see some log events about a new full-speed USB device Texas Instruments MSP-FET430UIF having been found. Despite the fact that it presents itself as FET430UIF, when connecting to the Launchpad we should actually use the rf2500 driver. (I don’t know the details about the differences.)

$ mspdebug rf2500

If all goes well, mspdebug starts up, connects to the Launchpad, and acknowledges that it has found a device to communicate with. For my version of the Launchpad, this is

...
Device ID: 0x2553
Device: MSP430G2553
...

We can now play around with the debugger a little bit. Try for example the commands reset, run, and then break the execution with Ctrl-C to see a dump of the sixteen MSP430 registers and the disassembled code that was running at the time of break. When we’re done, the exit command terminates the debug session.