Categories
electrónica

MSP430 LaunchPad in Ubuntu

There are a few sites with info about how to use the TI’s Launchpad platform in linux, but none of them worked for me, but mixing them I’ve got a functional development enviroment in my ubuntu box.

These are the steps I’ve done to compile and burn program into the microcontroller:

  1. Install required packages:

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

  2. Download and compile mspgcc:

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

    Press enter to use the default answers when the scripts ask you. Only write yes when it ask “Do you want to start build right now? (y/n) [n] ” because the default is no.

  3. Download and compile mspdebug:

    wget -O mspdebug.tar.gz http://sourceforge.net/projects/mspdebug/files/latest
    tar -zxvf mspdebug.tar.gz
    cd mspdebug
    make
    sudo make install

  4. Create a udev rule to be able to use the usb debug shield

    sudo nano /etc/udev/rules.d/46-TI_launchpad.rules

    Now paste inside the following rule:

    ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev"
    

    Restart the udev service:

    sudo restart udev

  5. Create a file named led.c and paste the following:
    /* Blink LED example */
    
    #include <msp430g2231.h>
    
    /** Delay function. **/
    delay(unsigned int d) {
      int i;
      for (i = 0; i<d; i++) {
        nop();
      }
    }
    
    int main(void) {
      WDTCTL = WDTPW | WDTHOLD;
      P1DIR = 0xFF;
      P1OUT = 0x01;
    
      for (;;) {
        P1OUT = ~P1OUT;
        delay(0x4fff);
      }
    }
    

    The include is wrong, but will do the trick for the example.

  6. Compile the source code and create de elf file data to be uploaded to the chip:

    /opt/msp430-gcc-4.4.5/bin/msp430-gcc -Os -mmcu=msp430x2231 -o led.elf led.c

  7. Connect the platform to the pc and upload the program to chip:

    mspdebug rf2500
    prog led.elf
    run

  8. Now you have to see red and green lights blinking alternatively. Let’s try to do your own changes to the code and create awesome projects!

Sources: hackaday.com and mylightswitch.

Updated 18/11/2010: thanks to hvontres I’ve changed the retrieval of th mspgcc4 code and now it download the latest version from git. Indeed it has support for the microcontrollers that come with the Launchpad, so I also changed the sample code to include the correct header and the compilation command.
Updated 28/05/2011: thanks to Andrew I’ve changed the mspdebug download link to always download the latest release.

56 replies on “MSP430 LaunchPad in Ubuntu”

Thanks for this. I installed it using instructions on other sites but couldn’t get the C files compiled. Turns out I didn’t install mspgcc properly (used all ‘1’ rather than the defaults). Reading your post helped me realize 1 was the default for some 🙂 Thanks.

Thanks for the instructions. I think the svn repo is no longer the main branch. This is the log entry for the last revision:
“Add note that SVN is for WASP and general users should use Git.”

So I think the correct checkout procedure would be to use the following command:

git clone git://mspgcc4.git.sourceforge.net/gitroot/mspgcc4/mspgcc4

@Joel, I’m glad you find useful the post. Feel free to come back in the future to see example uses of the Launchpad.

@hvontres, thanks for the tip, I’ve updated the post with the new way of retrieval the code, the included header in the example code and the compilation command. 😀

@sucotronic, I’m still getting compile errors on any Launchpad code I try to compile, including the LED example here. Here’s the error:

led.c:12: error: ‘WDTCTL’ undeclared (first use in this function)
led.c:12: error: (Each undeclared identifier is reported only once
led.c:12: error: for each function it appears in.)
led.c:12: error: ‘WDTPW’ undeclared (first use in this function)
led.c:12: error: ‘WDTHOLD’ undeclared (first use in this function)
led.c:13: error: ‘P1DIR’ undeclared (first use in this function)
led.c:14: error: ‘P1OUT’ undeclared (first use in this function)

Seems like I’m missing some kind of dependency. But I’m new to the C world so I’m having problems figuring it out. I have redone everything several times. I’ll try using the GIT repo. Do you have any other instructions?

Thanks.

@Joel, it seems the compiler isn’t finding the included header file. Try to do the step one again with the updated git repository and note that in the example code I’ve also changed the included file.

Thank you; this was a great help getting up and running with Launchpad on Linux!

I found I have to run mspdebug rf2500 as a super-user or it comes up with errors:

“Trying to open interface 1 on 003
rf2500: warning: can’t detach kernel driver: Operation not permitted
rf2500: can’t claim interface: Operation not permitted
rf2500: failed to open RF2500 device”

If I use “sudo mspdebug rf2500”, it works just fine.

Best Regards,
Rob

@sucotronic, You may have the default rule overriding for /dev/ttyACM0, I found with my system (Ubuntu 10.10) I had to move the 46-TI_launchpad.rules suggested above to 56-TI_launchpad.rules in order for plugdev group to be assigned (otherwise dialout group applies, you could just join it instead and skip the specific rule altogether).

… Niall

@Niall, I tried “sudo mv /etc/udev/rules.d/46-TI_launchpad.rules /etc/udev/rules.d/56-TI_launchpad.rules” but it didn’t work, what do I have to do?

@Bino, I would have expected that command to work, are you in group plugdev ? What permissions and ownership are on the newly created device ? Try enabling debug on udev and watching what happens when you plugin the board.

@Niall, yes, I am in the plugdev group. How do I see the permissions and how do I enable debug on udev?
Thanks for your help!

@Niall, damned double quotes! I’ve copied the code from the tutorial but the double quotes were of this type -> ” instead of this type -> “, so it didn’t work.
Thanks for the help though! 😀

Hi sucotronic

I was able to compile and program the g2231 but I have to keep using sudo mspdebug rf2500. Is this because the double quotes used in the udev rule? What should I change?

TIA
gmm

@gmm, I’ve changed the style of that paragraph in order to do the copy&paste well. Try it now to see if it is solved.

Thanks for the information, everything works.

I run mspdebug as a normal user, the mspdebug gives a error on the first try in finding the board. But then the program does a second try and finds it and works.

I am running Mint 10 linux, based on Ubuntu.

I compiled the led program, loaded it and run it…

Thanks again for a great job….

@Eric (USA), you’re welcome. I’m doing a small gui in python to help coding for msp430, so keep in touch for new articles about this device and linux 🙂

@sucotronic, you rock, worked perfectly ! Thank you ! I am going to post it on my blog, of course with your reference only.

Worked like a charm on Ubuntu 10.04, thanks for the article! I used mspdebug version 0.15 without a hitch too.

@Andrew, you’re welcome. I’ve changed the download link in order to download always the latest mspdebug release.

Hi i’have been trying to run it through linux from past a month, and till now i couldn’t. after all “make” process when i enter the compiling line i get an error,..

$ /opt/msp430-gcc-4.4.5/bin/msp430-gcc -Os -mmcu=msp430x2231 -o led.elf led.c
bash: /opt/msp430-gcc-4.4.5/bin/msp430-gcc: No such file or directory

while i navigated into the /opt/msp430-gcc-4.4.5 folder i found it empty,.!! can any one please help me,..

im in a real urgent, coze im using this for my project work so i put my outputs that i faced while installing them,..
here goes my terminal window’s output while compiling mspgcc and mspdbug,. (command line output in pastebin)

PS: I’ve edited this comment to move the code to pastebin instead of storing it in a comment.

@arvindh, according to the output of the scritp, it seems that it is unable to download the binutils source tar file. You can modify it in order to download a file named binutils-2.21.1.tar.bz2 instead of the binutils-2.21.tar.bz2 of your actual script.

@arvindh, nice to know you finally got it 🙂 I’m preparing also an article about using the new toolchain (as mentioned in the url you posted) for new msp430 development.

Hey dude, im getting a new kind of error now,..
and this time its happening during burning the program into the IC.
its saying,..

(mspdebug) prog bright.c
binfile: this format contains no code
(mspdebug)

I can’t get this to work on Ubuntu 11.04 – binutils version has changed, edited scripts to get a “good” one, patching then failed… gave up and grabbed a binary msp430 gcc from another link in the comments, can compile basic code but nothing which sources msp430* header files. Bit of a mess 🙁

@Andy Piper, hey Andy,..

i first was using ubuntu 11.04, and messed things like any thing. there were too many dependency errors with the kernel version and the binutils,..
for some reason i shifted back to 10.04,.. and lately try’d it. with some little dep,. errors i was able to get it right,..

but, do search a lot, coze i’ve came across people those who have made it work on both 11.04 & .10,…

Good Luck m/

te cuento que el link a unikl.de da un 404… 🙁

gracias, mi tercer intento con los dichosos 430…

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”
–2012-02-07 11:06:07– http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.21.tar.bz2
Resolving http://ftp.uni-kl.de... 131.246.123.4, 2001:638:208:ef1b:0:ff:fe00:4
Connecting to http://ftp.uni-kl.de|131.246.123.4|:80… connected.
HTTP request sent, awaiting response… 404 Not Found
2012-02-07 11:06:09 ERROR 404: Not Found.

@arvindh, see point 5 in the instructions above “Compile the source code and create de elf file data to be uploaded to the chip:”

@sucotronic, ¡Gracias! te cuento que haciendo trampa, bajando el tarbal de zucotronic (link en el comentario a arvindh), la cosa marcha, y ya tengo mi 430 flasheando feliz. Antes de la noche: codiguear mi controlador de step-motor.

MUY feliz. AHora, ni idea si la cosa funcionó gracias a la montaña de código que he bajado estos días – más bien, milagro que funcionó, a veces cuando uno intenta diversas recetas (y te cuento, traté VARIAS), se llega a romper el entramado del espacio-tiempo. Sería cosa de probar en un install fresco.

Definitívamente más difícil que el Arduino, pero por el precio, vale la pena!

Gracias de nuevo

Hi,

thank you for that introduction.
Unfortunately the build of the MSP430-GCC aborts with errors:

______

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”
–2012-06-03 19:17:30– http://ftp.uni-kl.de/pub/gnu/binutils/binutils-2.21.tar.bz2
Resolving http://ftp.uni-kl.de (ftp.uni-kl.de)… 131.246.123.4, 2001:638:208:ef1b:0:ff:fe00:4
Connecting to http://ftp.uni-kl.de (ftp.uni-kl.de)|131.246.123.4|:80… connected.
HTTP request sent, awaiting response… 404 Not Found
2012-06-03 19:17: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.
______

Du you have any clue why?

@BrEin, right now I cannot check it and help you sorry. But I’m preparing a new article about compiling code using uniarch new toolchain.

Leave a Reply

Your email address will not be published. Required fields are marked *