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.


MSP430 Launchpad development using GNU tools

I bought myself an MSP430 Launchpad development board from Texas Instrument. Upon receiving it I started to investigate the available tools for software development. Sure, we could use a free version of IAR Embedded Workbench from TI, but that would limits us to 4 kB code size and force us to use Windows. Or we could the Eclipse route and use Code Composer Studio from TI, which also runs on Linux, but the free version is limited to 16 kB code size. This is not a problem for the MSP 430 chips that are included with the Launchpad, but surely it would be more interesting to use the GNU toolset and other free tools to do the development?

After doing some web searches, it seems that most of the tutorials in this area are quite old. There is a lot of stuff about how to compile your MSP430-gcc, but nowadays we have the tools we need included in a stock Ubuntu distribution, so there is no need to spend time on that. So I will try to describe how get up and running with Ubuntu, gcc and gas. In the upcoming blog posts, we will visit the following topics:

  • Installing the software on Ubuntu 13-04
  • Programming the MSP430 in C using GCC
  • Programming the MSP430 in pure assembler using GAS