Using the MSP430 Launchpad in Arch Linux

This guide is, for the most part, based off of this document. I'm duplicating much of it here because 1) if it goes down we'll have lost a valuable resource, 2) some of what he says is outdated/wrong, 3) he's wordier than I am, 4) my methods are a bit easier, I think.

To get started, install the following software. You can get all this stuff through AUR, and its dependencies through pacman.

  • binutils-msp430
  • gcc-msp430
  • msp430-gdb
  • msp430-libc
  • msp430mcu
  • mspdebug

Next, you need a make file. This one has worked for me. Change the -mmcu= flag to reflect whatever chips you're working with.

makefile
CC=msp430-gcc
CFLAGS=-Os -Wall -g -mmcu=msp430g2553
OBJS=main.o
 
 
all: $(OBJS)
	$(CC) $(CFLAGS) -o main.elf $(OBJS)
 
%.o: %.c
	$(CC) $(CFLAGS) -c $<
 
clean:
	rm -fr main.elf $(OBJS)

Get your hands on some sample code to play with, something like this that blinks an LED works fine.

main.c
// Copyright 2012 Matthew Hiles
#include <msp430g2553.h>
 
#define pause for (i=0; i < 100; i++) wait(7000)
 
void wait(int ticks)
{
	TAR=0;
	while(TAR < ticks) _NOP();
}
 
void main(void)
{
	int i = 0;
	WDTCTL = WDTPW + WDTHOLD; // stop watchdog
 
	TACTL = TASSEL_2 | MC_2;
 
	// setup TXD and RXD
	P1SEL =  0;   // all ports GPIO
	P1DIR = 0xFF; // all is output
 
 
	while(1)
	{
		P1OUT ^= (BIT0); // toggle bit0 (red LED)
		pause; // wait
	}
}

Now, type “make”. If the gods are smiling upon you, this should happen:

[john@TX100 blinktest]$ make
msp430-gcc -Os -Wall -g -mmcu=msp430g2553 -o main.elf main.o
[john@TX100 blinktest]$ ls
main.c  main.elf  main.o  makefile

If it doesn't, check your code, your makefile, all that good stuff. I'm bad at troubleshooting this because I personally have never had it go wrong.

Now, start mspdebug:

[john@TX100 blinktest]$ sudo mspdebug rf2500


....
A bunch of jibberish
...

(mspdebug)

Now you're at the (mspdebug) prompt, and you can do things like program code to your msp, erase your msp, look at the data on the msp, etc. I don't know what all I can do, but I get the feeling that it's fairly powerful if you know what you're doing.

To program your code onto the chip, first type 'erase' at the prompt to make sure the chip is wiped. This will take about a second. Now type 'prog main.elf' and whamo-blamo, you've programmed your MSP430 in linux.

If you want to do realtime debugging and stuff you can mess around with msp430-gdb. I've not found much use for it yet, but I'm sure that one day there will be. It's a little bit complicated, so if you're interested in it you can read about it in the guide linked at the top of this page.

msplinux.txt · Last modified: 2018/03/06 08:59 (external edit)
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0