MSP430 in 64-bit Ubuntu 12.04 Linux - the Arduino Way

MSP430 in 64-bit Ubuntu 12.04 Linux – the Arduino Way

Programming MSP430 microcontrollers in 64-bit Ubuntu 12.04 Linux

Programming MSP430 microcontrollers in 64-bit Ubuntu 12.04 Linux

I recently had a chance to take a closer look at programming a new (to me) familty of microcontrollers – MSP430 by Texas Instruments. The opportunity came courtesy of Newark, which is where the TI MSP430 Launchpad Development Board can be purchased on their Analog & Embedded Catalog website. I’ve had access to TI MSP430 development boards before but, since I ran a Linux shop here, the hurdles of using the stock Windows-based developing environment were too much for me and I never actually got to play with them and I’ve pretty much given up on TI until this opportunity came along. Much has changed since then, so keep reading if you are interested in working with MSP430 in Linux

{adinserter Internal_left}The good news is that in 2012 you do not have to switch back to Windows or abandon MSP430 in favor of a microcontroller with better Linux tools, such as Atmel. MSPGCC toolchain for programming MSP430 microcontrollers in C has been available for awhile now on many operating systems, including Linux, and a new Arduino-like free and open source Integrated Development Environment (IDE) called Energia is making programming an MSP430 as easy as the more common ATMEga microcontroller of the Arduino boards. I have to add here that at $4.30 each (check current price at Newark) LaunchPad MSP-EXP430G2 is a little wonder of a development board by itself because it comes with 2(!) very capable MCUs as well as a 32.768kHz quarz and a USB cable and is undoubtedly the lowest cost MCU development tool around. A perfect way to start programming micricontrollers and this is exactly where the beginner-friendly Arduino-like Energia IDE comes very handly.

MSP430G2 Launchpad Development Tool powered via USB

MSP430G2 Launchpad Development Tool powered via USB

This tutorial is about installing and configuring Energia and MSPGCC for use with the MSP430G2-based Launchpad Development Board (TI P/N MSP-EXP430G2, on the left). Note that at different times TI had shipped different hardware versions of Launchpad. This tutorial is based on V1.5 which is what I got.

As is the case with the Arduino IDE, once installed, the environment can be very easily reconfigured to work with different types of boards and MSP430-family MCUs by selecting the appropriate item from the Tools->Board menu. My own installation process has been helped along big times by other MSPGCC and Energia installation tutorials, such as Sakoman’s here but there were several issues specific to 64-bit Linux which I could not find described elsewhere hence this tutorial.

Energia provides a familiar Arduino interface (albeit in a strange red color scheme)

Energia provides a familiar Arduino interface (albeit in a strange red color scheme)

The 64-bit Linux Energia installation process can be broken down to four steps:

  1. Install prerequisite libraries and binaries
  2. Download and install Energia. The Energia binaries work on a 64-bit system but mspgcc needs to be recompiled. Included mspgcc binaries won’t work.
  3. Complile and install 64-bit MSPGCC toolchain. The source codes needed for compiling are included in the Energia download above
  4. Make sure your system recognises Launchpad as a USB device, has a proper driver, and your user has permissions to use it

please note: on a 32-bit system you can get Energia’s binaries with already pre-compiled mspgcc toolchain utilities and therefore the separate mspgcc install is not required.

Install prerequisites.
In Ubuntu/Debian:

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get build-dep gcc
sudo apt-get install libgmp3-dev libmpfr-dev libmpc-dev
sudo apt-get install texinfo texi2html
sudo pico /etc/apt/sources.list
sudo apt-get build-dep gcc-4.5
sudo apt-get build-dep gcc-4.6
sudo apt-get build-dep gcc
sudo apt-get install libstdc++
sudo apt-get install libcurses5-dev
sudo apt-get install build-essential
sudo apt-get install libncurses5-dev
sudo apt-get install zlibc
sudo apt-get install libexpat1-dev zlib1g-dev libreadline6-dev
sudo apt-get install mspdebug

Download Energia Binary Files (includes MSPGCC4.6 sources) and compile mspgcc

mkdir ~/electronics/energia
cd ~/electronics/energia
tar xzf ./energia-0101E0008-linux.tgz
cd energia-0101E0008/hardware/tools
sudo ./build-mspgcc
cd ~/electronics/energia/energia-0101E0008/lib
cp '' '' 

Update Energia’s start script to point to the right binary path
./build-mspgcc that comes with the Linux binary installs mspgcc into /opt/energia/bin. So, open the energia script and change the header of the fine to export new path.

pico ~/electronics/energia/energia

Edit the file to look like this:

#export PATH=$PATH:/opt/mspgcc/bin
export PATH=$PATH:/opt/energia/bin
APPDIR="$(dirname -- $(readlink -f -- "${0}") )"

for LIB in \
    java/lib/rt.jar \
    java/lib/tools.jar \
    lib/*.jar \


export PATH="${APPDIR}/java/bin:${PATH}"


You should be able to start Energia by running ~/electronics/energia/energia (add a menu item to avoid using terminal every time to start Energia if you like). Load one of the standard example that come in the Sketchbook directory, Blink for example, and try to compile it (Verify). At this point you should see no errors, otherwise mspgcc did not get installed properly.

Setting up serial comunication with the Launchpad board
Launchpad requires a USB Abstract Control Model driver called cdc-acm in Linux. If your system already has the cdc-acm driver from a previous install of another USB device that also needed it, you’re fine – you can start uploading your compiled Energia sketches now.
If you don’t have the driver, you will need to install it and make sure it gets associated with Launchpad and your Linux user has permissions to use it.
Plug Launchpad into a USB port and run:

sudo lsusb

You should see a like like this:
Bus 002 Device 013: ID 0451:f432 Texas Instruments, Inc. eZ430 Development Tool
Where 0451:f432 is the ID of the current version of the Launchpad hardware that Newark ships right now. Make note of the ID. The device should become a virtual serial port /dev/ttyACM0
run this to verify that cdc-acm driver is installed:

 sudo modinfo cdc-acm

if you don’t see the module’s name in the output, you will need a new cdcacm driver. By the way, it doesn’t help matters much that the driver is called cdcacm and the module loads as cdc-acm (with a dash) – be careful about these naming differenced. The best way to go about reinstalling the patch is to take a look at this thread on TI forums which contains links to patch files and more descriptions. I’m going to have to skip explaining the process in detail because I’m writing this about a week after the actual installation and my records about the process now, after the fact, make very little sense to me, so I would like to avoid confusing my readers. I have used that TI forums page linked above as a guide.
Once you have the driver and the module loads, you still need to add a udev rule so that Launchpad is recognized every time you plug it in and you have permissions to use it:

  • create a file called 71-persistent-msp430.rules in /etc/udev/rules.d/ directory
  • Add this line in there:
    ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev"

    note that eariler versions of Launchpad had “f430” in there, but the current v1.5 needs “f432”

  • Add your user to the group plugdev:
    sudo adduser user plugdev
  • restart udev service:
    sudo service udev restart

Plug Launchpad in now, you should be able to upload your compiled sketches and use it just as you would an Arduino. My Launchpad came with an MSP430G2553 MCU plugged in, so this is what I selected in Tools->Board, so pick the right MCU and program away using your shiny new tool that only set you back $4.30 🙂

I anticipate that there may be a lot of questions related to installing Energia and programming MSP430, so I have create a special MSP430 Board in the Forums. Please direct yourt more specific questions and comments there instead of the comments form below for easier-to-use discussion format.

Good luck!

5 Responses to “MSP430 in 64-bit Ubuntu 12.04 Linux – the Arduino Way”

  • Jose Martinez:

    FOR UBUNTU-12.04, 32 BITS
    The file /usr/lib/ it’s broke, for to solve this problem is necesary to install this library:

    sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/
    sudo apt-get install libgmp3c2
    sudo apt-get update

    That’s all.

  • Hi! Good job!
    I’ve got problem, please help me. I use ubuntu 13.04. And aaa, somethings wrong:

    energia/hardware/tools/msp430/bin/mspdebug: error while loading shared libraries: cannot open shared object file: No such file or directory

    sudo apt-get install libusb-dev ==> can’t help

    Sorry about my english, thanks!

  • Chanceleir:

    Hello and thanks for the detailed expalnation

    Actually I am trying to install energia on my 64 bit Ubunto 14.04 LTS distro.
    The command ‘sudo ./build-mspgcc’ did not work for me !! the error msg is ‘sudo: ./build-mspgcc: command not found’ and I think there is no such a command as ‘sudo ./build-mspgcc’ !
    Can you please give me a solution for this

    Thanks and regards

Leave a Reply

Or use the Forums ! If your comment is a question, please consider posting it to a matching section of our Electronics Forums. The forums allow for a more natural conversation flow, especially if multiple replies are required. Additionally, you'll be able to style your writing (bold font, italics etc.) and post images which can help with a good answer.