This is a guest post by one of our members, [A]lvaro. He’s been kind enough to offer step by step tutorial to setup a MSP430 toolchain. Although his work environment is Ubuntu, the described steps should make it easier for you to get going on other platforms. You can also download the pdf version of this tutorial.

[A]lvaro Aguilar is currently an undergraduate student at St. Mary’s University in San Antonio, TX, where he is  pursuing a double Bachelor’s in Physics and Electrical Engineering. His final year project is a robot based around the MSP430; this robot will be used by other students to explore the endless applications of microprocessors.

I put together this guide from various sources I found on the internet. It is meant to help a beginner set-up the Eclipse IDE to work with MSPGCC and be able to use it to debug and program MSP430 devices. This guide is just a compilation, so you may fi nd further insight into some of the steps by visiting the following sites:

1. MSPGCC Wiki
2. MSPGCC4 and MSPDEBUG
3. MSP430 Eclipse MSPGCC Ubuntu Tutorial
4. Eclipse IDE with MSPGCC

Before beginning with the installation, you have to make sure you have the following packages:
subversion,texinfo, patch, libncurses5-dev,zlibc,zlib1g-dev,libx11-dev,libusb-dev,libreadline6-dev

Now that the basics are covered, we will fi rst install and set up mspgcc. We will later tell Eclipse to use these tools in order to compile our C programs and output a code that the MSP430s can understand.
Keep in mind during the process the Eclipse is a general working environment, and we must tell it what to do with the files: what compiler to feed them to, and with what parameters.

MSPGCC
There are two option for this package. The older version is more robust, but needs additional installation of certain packages. Basically, you will need to install an older version of gcc because Ubuntu ships with v.4.x but you need v.3.x for the original MSPGCC. Additional information can be found at MPGCC Wiki The newer version, mspgcc4, is available for download as a pre-built package. I installed mspgcc version 4 by visiting the following website:

[sourcecode language=”plain” light=”1″]http://sourceforge.net/projects/mspgcc4/files/c[/sourcecode]

Extract its contents onto /opt/mspgcc and change its permissions using the following command:

[sourcecode language=”bash” light=”1″]sudo chown -R $USER.$USER /opt/mspgcc[/sourcecode]

In order to debug your device, you will additionally need “msp430-gdbproxy“. Run the following set of commands to get it along with its libraries:

[sourcecode language=”bash” light=”1″]cd /opt/mspgcc/bin
wget http://www.soft-switch.org/downloads/mspgcc/msp430-gdbproxy
chmod 777 msp430-gdbproxy
cd /usr/lib
sudo wget http://www.soft-switch.org/downloads/mspgcc/libHIL.so
sudo wget http://www.soft-switch.org/downloads/mspgcc/libMSP430.so[/sourcecode]

Now that we have mspgcc installed we must add the /opt/mspgcc/bin path to our environment so that we may call these functions from the command line. Edit the fi le /etc/environment and add the path at the end of the line. A reboot is needed in order for the change to take e ffect.

Finally, there is a small tweak needed in order to recognize the newer MSP430 devices. Running the command dmesg | tail after plugging in your device should reveal what is needed. If you see an error saying ti_download_ firmware – firmware not found, then you must perform the following step. You will need the firmware called ti_3410.fw, which can be found under /lib/firmware/ti 3410.fw. Run the following command in order to make it accessible:

[sourcecode language=”bash” light=”1″]ln -s /lib/firmware/ti_3410.fw /lib/firmware/ti_usb-3410.bin[/sourcecode]

Reconnecting the device and running dmesg | tail again should generate an output in which you see a line saying:

[sourcecode language=”bash” light=”1″]TI USB 3410 1 port adapter converter now attached to ttyUSB0[/sourcecode]

If you don’t see this, then you should change the confi guration value of the USB device. Attention: The USB device that you change will depend on your dmesg | tail output, and the device that is recognized (in my example it was 5-1). Become root before attempting to do this:

[sourcecode language=”bash” light=”1″]echo 2 > /sys/bus/usb/devices/5-1/bConfigurationValue[/sourcecode]

Since /dev/ttyUSB0 is owned by root.uucp, you should add your $USER to the uucp group. Replace $USER in the following command in order to add a di erent user to the group. Also, be sure to use the -a
flag in order to append the file to the group rather than overwriting its contents:

[sourcecode language=”bash” light=”1″]usermod -a -G uucp $USER[/sourcecode]

You may now start msp430-gdbproxy by trying the following command:

[sourcecode language=”bash” light=”1″]msp430-gdbproxy msp430 /dev/ttyUSB0[/sourcecode]

If all goes well the proxy should be initialized and ready to receive commands through port 2000. By the way, this is not the only way to communicate with your device. You may also download a tool called mspdebug. This one supports newer devices that might not be supported by the usual msp430-gdb (like the eZRF-2500). Check out this tutorial for info on how to set it up.
Now that MSPGCC is set-up, we can set up Eclipse in order to work with it.

Eclipse
You will need to install Eclipse and a few add-ons. Begin by installing eclipse from the command line:

[sourcecode language=”bash” light=”1″]sudo apt-get install eclipse[/sourcecode]

After the installation is done, fi re up eclipse. Go to Help : Install New Software. . .

You will want to install two software packages from the following locations:
1. CDT add-on (Choose the one for your version of Eclipse):
http://www.eclipse.org/cdt/downloads.php
2. Zylin Embedded CDT:
http://opensource.zylin.com/embeddedcdt.html

On those sites, you will nd the correct link to plug into the “Work with:” box in Eclipse Install New Software. When the installation is done, Eclipse will need to reboot for the changes to take eff ect.
After the restart, you will have to make a new C project. I created a regular project like this:

Click next and create a new project (I called mine led) as an Empty Executable:

Click fi nish and you will be greeted by the default C/C++ perspective under Eclipse. On the left side you will see the Project Explorer, where you will be able to visualize everything under your source code. For now, you can drag and drop the fash LED example in there. I got mine from the IAR Embedded Workbench installation on a Windows Machine, but you can download sample code from the TI website. This is what the screen should look like after opening up the source fi le:


Now that we have a project made, we need to specify the settings so that Eclipse may build this project using the MSPGCC compiler. Right-click on the project name and select Properties from the menu. Go to C/C++ Build and expand its contents to select Settings. Under the Tool Settings tab, you will nd settings for the Compiler, Linker and Assembler. First of all, open up a terminal and type the following command:

[sourcecode language=”bash” light=”1″]msp430-gcc –target-help[/sourcecode]

The output will show all the supported MCU names; keep the correct one for your device in mind. For example, my device is the MSP430F2013, and the correct MCU name was msp430x2013.
Back on the GCC C Compiler option inside Eclipse, specify the following command:

[sourcecode language=”bash” light=”1″]msp430-gcc -mmcu=msp430x2013[/sourcecode]

Of course, change to your specfi c MCU name from before.

In order to include header fi les, the compiler must know where to find them. Go to the Directories option under GCC C Compiler and specify the directories where you keep the header fi les for mspgcc. The default directory is /opt/mspgcc/msp430/include. In the end, I included the following directories.

[sourcecode language=”bash” light=”1″]/opt/mspgcc/msp430/include
/opt/mspgcc/include
/usr/include[/sourcecode]

Now we need to set up the GCC C Linker part in a similar manner. The command needs to be the same, so just copy and paste the same information into that fi eld. However, we must tell the linker where the libraries are, so under GCC C Linker, go to Libraries and include the following under “\Library search path (-L)“:

[sourcecode language=”bash” light=”1″]/opt/mspgcc/msp430/lib
/opt/mspgcc/lib
/usr/local/lib[/sourcecode]

Finally, the Assembler must be set-up correctly, so navigate down to it. This time, the command is di erent, so in the \Command” fi eld, enter the following: msp430-as. As usual, we must also tell this assembler where to fi nd the include files. Click on General and add the following paths to the “Include paths (-I)” box:

[sourcecode language=”bash” light=”1″]/opt/mspgcc/msp430/include
/opt/mspgcc/include[/sourcecode]

Now that our compiling tools are ready to be used, we need to tell Eclipse what type of fi le to create. Head over to the “Build Artifact” tab and type in “elf” under “Artifact Extension“. On the next tab over “Binary Parsers“, make sure that the Elf Parser is selected.

Compiling set-up is now fi nally done, so clicking OK should bring you to the main page. Try building the project by selecting Project : Build Project. If everything went well, you should have a succesful build. Otherwise, check the console and correct the issues presented.

Now that we have a working executable, we want to debug it. I used msp430-gdbproxy along with msp430-gdb in order to achieve this. You can also use mspdebug by itself to do this step, and the set-up is similar so you may use this guide to set it up under Eclipse as well. The proxy part is just a proxy that forwards the commands from msp430-gdb to the actual MSP430 device connected to your computer. Therefore the fi rst thing we will do is set-up Eclipse to run the proxy before anything else. Head over to Run : External Tools : External Tools Confi gurations. . . . Create a new con figuration and set it up like this. You should take a quick read at the man page of msp430-gdbproxy before con guring the parameters in order to ensure you got the right device. The arguments I passed where msp430 (type of device) and then the port at which it was attached (this should be known from the previously issued command dmesg | tail).

As you can see, I also other tools available. Namely, msp430-gdbproxy running under wine. Find a great tutorial for this here. Additionally, I also have a tool for running mspdebug. The following is a screenshot with the parameters that worked for me. However, you should read the man page for that command in order to make sure everything is set-up for your device.

Now that the proxy is set-up, try running it and observe the console output. It should include certain information about your device and end with the line “Listening on port 2000” or so. Once that is ready to go, we can set up msp430-gdb to work as the debugger from inside Eclipse. In order to do this, we need to open the Project Properties again. Therefore right-click on the project name, and select Properties from the drop-down menu. Under Run/Debug Settings, select New. . . and then click OK. Under the “Main” tab ensured that the correct names are given for the Project and for the Executable created during compilation. Now head to the “Debugger” tab and select remote gdb/mi from the “Debugger” drop-down list. Type in msp430-gdb on the “GDB Debugger” line. Go to the “Gdbserver Settings
tab and select the port that msp430-gdbproxy is listening on; the default is 2000 along with 127.0.0.1 for the server name.

Finally, create a le in your home directory called .gdbinit. Inside of this fi le, place the following lines:

[sourcecode language=”bash”]set remoteaddresssize 64
set remotetimeout 999999
target remote localhost:2000[/sourcecode]

Conclusion
Once again, this guide is merely a compilation of di erent articles found online. If you have questions regarding the procedures, or errors along the way, be sure to check out the following websites:
1. MSPGCC Wiki
2. MSPGCC4 and MSPDEBUG
3. MSP430 Eclipse MSPGCC Ubuntu Tutorial
4. Eclipse IDE with MSPGCC

Please feel free to ask any questions in the comments below.