Install MSP430 Toolchain In Minutes on Ubuntu 11.04

First Texas Instruments Logo

First Texas Instruments Logo

Installing the MSP430 GCC toolchain is very easy and quick these days if you are running Ubuntu 11.04 (Natty). Steer clear of all the MSP430 toolchain confusion, installing just eight binaries will have you building and debugging MSP430 code in minutes and not hours!

There are several different methods for obtaining and installing the packages it’s really personal taste. Perhaps the easiest way to get Ubuntu 11.10 (Oneiric) packages is to just download the individual *.deb packages from this saved Launchpad search. In addition to the Ubuntu 11.10 (Oneiric) packages, SRecord from the Ubuntu 11.04 (Natty) packages will also be needed.

Download and Install Packages

Regardless of how the packages are acquired: msp430mcu, binutils-msp430msp430-libcgcc-msp430gdb-msp430mspdebuglibgmp10, and srecord are all needed. Install these modules in this order and you will be compiling and debugging msp430 code in minutes, not hours.

Building First Project

To test the new toolchain try building an example for the MSP430F149. Texas Instruments (TI) has a lot of resources published online, including many very useful example programs for the MSP430F149.

Once slac015n.zip has been downloaded, create a new folder called “helloworld” and copy “fet140_1.c” as “hello_world.c” to the newly created folder. Then obtain a copy of the Makefile posted on the MSPGCC Wiki and save it to the newly created folder as well.

Change the value of the variable “MCU” (line 12 of Makefile) to “msp430f149”. Close the file and from the terminal, execute “make”. If all went well there should be minimal warnings and no errors and most importantly, off all the files the make file created, there should be a file called “hello_world.elf”. Since a Makefile was used, it is very important that the c source file be titled “hello_world.c” or that the make file was changed appropriately for the file name. A tarball of the source and build is attached, helloworld.tar.gz.

Running On “Actual Hardware”

There are several different methods to program MSP processors including using JTAG. If using an MSP430 USB-Debug-Interface like the TI MSP-FET430UIF and Ubuntu 11.04 (Natty) just plug it in and go, even using MSP GDB (debugger) is a breeze under these conditions.

Make sure that the TI field emulation tool (FET) has properly received a TTY interface before continuing. This can easily be done using the command line interface (CLI) tool “dmesg.” The line that shows success is “TI USB 3410 1 port adapter converter now attached to ttyUSB0.”

Once the FET is issued a TTY interface use two terminals, one executing “mspdebug,” which will open an interface for “msp430-gdb,” and one for “msp430-gdb.”

Terminal #1

[bash light=”true”]
$ mspdebug uif -j -d /dev/ttyUSB0 gdb
[/bash]

Executed in terminal #1, the previous code will launch “mspdebug” using the “uif” driver. The option ‘-j’, indicates to “mspdebug” to use the JTAG driver instead of the SPI driver. The option ‘-d’ indicates the serial device interface. The “gdb” option informs “mspdebug” to setup a proxy and to wait for a connection from a program like “msp430-gdb”. “mspdebug”, in this case, replaces “msp430-gdbproxy”. On to terminal #2.

Terminal #2

[bash light=”true”]
$ cd /<path_to_helloworld>
$ msp430-gdb
(gdb) set remoteaddresssize 16
(gdb) set remotetimeout 999999
(gdb) target remote localhost:2000
(gdb) set remote memory-write-packet-size 512
(gdb) set remote memory-write-packet-size fixed
# Respond yes (Y)
(gdb) set remote memory-read-packet-size 512
# Respond yes (Y)
(gdb) set remote memory-read-packet-size fixed
(gdb) erase all
(gdb) load hello_world.elf
(gdb) continue
[/bash]


While I’ve

Image showing MSP430-GDB "Continuing"

Successful connection and debugging using MSP toolchain

The above code establishes some constraints on the data passing process of a debugging session and informs “MSP430-GDB” of the host and port on which to connect to. These settings were obtained from the OpenGina project page. Most of the settings are flexible and may vary depending on project, programmer, driver, etc. The OpenGina project points out that an init file can be created to save having to type many of the previous commands.

On Linux, create a file “.gdbinit” in the home directory with the following contents.

~/.gdbinit

[bash light=”true”]
(gdb) set remoteaddresssize 16
(gdb) set remotetimeout 999999
(gdb) target remote localhost:2000
(gdb) set remote memory-write-packet-size 512
(gdb) set remote memory-write-packet-size fixed
(gdb) set remote memory-read-packet-size 512
(gdb) set remote memory-read-packet-size fixed
[/bash]


I’ve since changed the address size from 16 to 64 and the packet size from 512 to 1024. Supposedly this will increase speed, not that I’ve had any speed issues. Revert back if there are errors or communication faults.

Then all that is left to execute is

Terminal #2

[bash light=”true”]
$ cd /<path_to_helloworld>
$ msp430-gdb
(gdb) erase all
(gdb) load hello_world.elf
(gdb) continue
[/bash]

Once executing “continue” both terminals will be tied up, but if [ctrl+c] is executed in MSP430-GDB (terminal #2) it will break the execution, allowing a multitude of possibilities (see the help documentation).

Exiting MSP430-GDB or issuing the “kill” command to MSP430-GDB will end both sessions MSPDEBUG and MSP430-GDB.

There is a great article on using GDB by IBM title “Linux software debugging with GDB.” Even though the article is for GNU GDB I found it helpful for msp430-gdb.

Conclusion

While brief and lacking much detail, this document hopefully points a finger in the easy direction for setting up the MSP toolchain for Ubuntu 11.04 (Natty) and hopefully for Ubuntu 11.10 (Oneiric). Once the packages for the eight linked downloads are installed things should simply work. The installer should not need to link or update their PATH variables. Most of the MSP resources should have been installed two /usr/bin/ or /usr/msp430/bin. If in doubt use the “whereis” command with the command name as the argument.

[bash light=”true”]whereis mspdebug[/bash]

Advertisements

5 Comments on “Install MSP430 Toolchain In Minutes on Ubuntu 11.04”

  1. […] Post navigation ← Previous […]

  2. Randy Young says:

    Small typo above file name is given as “hellow_world” …
    Great thanks for how to!

  3. Yama Ploskonka says:

    Saved Launchpad Search, Makefile are 404… :-(

  4. […] To test msp430-gdb I follow the few steps outlined here. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s