sakoman.com

How to develop MSP430 Launchpad code on Linux PDF Print E-mail

The LaunchPad is an easy-to-use, affordable, and scalable introduction to the world of microcontrollers and the MSP430 family.

The LaunchPad development kit is a part of TI's MSP430 Value Line series. It has an integrated DIP target socket that supports up to 20 pins, allowing MSP430 Value Line devices to be dropped into the LaunchPad board. Also, an on-board flash emulation tool allows direct interface to a PC for easy programming, debugging, and evaluation.

Unfortunately, the TI supported tools for this kit are Windows only.

It is, however, quite possible to use Linux based tools with Launchpad.  The procedure below outlines the steps to build a Linux based tool chain and debugger, as well as create and test a short C program.

The procedure below should work on either your x86 Linux machine or on an OMAP system using the GNOME image from this site.

If you are using the GNOME image from this site all necessary packages to build the msp430 tools are included.  If you are using an x86 machine you may need to install a few required packages (the below assumes you are using Ubuntu, modify as needed for your distro):

$ sudo aptitude install git-core gcc-4.4 texinfo patch libncurses5-dev
$ sudo aptitude install zlibc zlib1g-dev libx11-dev libusb-dev libreadline6-dev

Next we will download and build the mspgcc compiler:

git clone git://mspgcc4.git.sourceforge.net/gitroot/mspgcc4/mspgcc4
cd mspgcc4
sudo sh buildgcc.sh

The build script will ask a number of questions.  Accept the default by pressing Enter for each question except "Do you want to start build right now?"  The proper response here is of course "yes"!

Next we download and build mspdebug:

cd ..
git clone git://mspdebug.git.sourceforge.net/gitroot/mspdebug/mspdebug
cd mspdebug
make
sudo make install

At this point we're ready to test our first MSP430 program: blinking the red LED connected to the P1 pin.

Create a blink.c file using your favorite editor:

/* Demo app to blink the red LED on the TI Launchpad */

#include <msp430g2231.h>

int main(void) {
volatile int i;

// stop watchdog timer
WDTCTL = WDTPW | WDTHOLD;
// set up bit 0 of P1 as output
P1DIR = 0x01;
// intialize bit 0 of P1 to 0
P1OUT = 0x00;

// loop forever
for (;;) {
// toggle bit 0 of P1
P1OUT ^= 0x01;
// delay for a while
for (i = 0; i < 0x6000; i++);
}
}

Next compile your program:

$ /opt/msp430-gcc-4.4.5/bin/msp430-gcc -oS -o blink.elf blink.c

Connect the Launchpad to your development machine using the supplied USB cable.  Use MSPDebug to download and launch your program.

$ sudo mspdebug rf2500
(mspdebug) prog blink.elf
Erasing...
Programming...
Writing 104 bytes to fc00...
Writing 32 bytes to ffe0...
(mspdebug) run
Running. Press Ctrl+C to interrupt...

You should now see the red LED blinking!

Tags: MSP430 How to
Last Updated on Friday, 27 May 2011 08:21
 

7 Comments

  1. The code above will not blink the LED, because the empty loop will be optimized away by the compiler. Without that wait, the result is a constantly lit LED, which is a bit less bright than what you would expect.

    You need to declare i as being volatile for it to work as expected, so change
    int i;

    to
    volatile int i;

    to have the desired effect.
  2. Quote:
    You need to declare i as being volatile for it to work as expected


    Good point -- wasn't necessary when I ran the test. I suspect compiler quality has improved since I built it!

    I've fixed the code in the article. Thanks!
  3. hi,

    i get an error while compiling,.. saying as
    bash: /opt/msp430-gcc-4.4.5/bin/msp430-gcc: No such file or directory

    when i moved to /opt/msp430-gcc-4.4.5 directory i found it completely empty,.
    please can anybody help me
  4. Quote:
    i get an error while compiling,.. saying as
    bash: /opt/msp430-gcc-4.4.5/bin/msp430-gcc: No such file or directory


    I suspect that you had an error and the compiler build failed. Try again to build the compiler and post any error messages.
  5. When I try to run the install script I get the following error:

    (...)
    -------------------------------------
    Do you want to start build right now? (y/n) [n] y
    Running sh do-binutils.sh "/opt/msp430-gcc-4.4.5" "2.21" "http://ftp.uni-kl.de" "build"
    --2011-11-14 13:48:29-- http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.21.tar.bz2
    Resolving ftp.uni-kl.de... 131.246.123.4, 2001:638:208:ef1b:0:ff:fe00:4
    Connecting to ftp.uni-kl.de|131.246.123.4|:80... connected.
    HTTP request sent, awaiting response... 404 Not Found
    2011-11-14 13:48:30 ERROR 404: Not Found.

    sh do-binutils.sh "/opt/msp430-gcc-4.4.5" "2.21" "http://ftp.uni-kl.de" "build" exited with status code 8.
    Failed to execute sh do-binutils.sh "/opt/msp430-gcc-4.4.5" "2.21" "http://ftp.uni-kl.de" "build" at ./buildgcc.pl line 248, line 9.

    How can solve this? Has anyone found the same error?
  6. I found the same error as Joao Pinto. Apparently the repository doesn't exist anymore. Anyone got some alternate location?
  7. In buildgcc.pl
    Change the line:
    $BINUTILS_VERSION = "2.21";
    to
    $BINUTILS_VERSION = "2.22";

Add Comment


     

    You are here  : Home

    Advertisement

    Advertisement