MSP430 Development with Linux

Using Linux and the TI MSP430 processor to create blinking LEDs is a learning exercise, not just a way to make cheap Sci-Fi movie panels.
A Simple Blinking LED

Blinking an LED is the embedded equivalent of “Hello World”. We will modify one of the examples to make it a little easier to understand. Copy the leds example from /opt/cdk4msp/examples/mspgcc/leds/ to a working directory, and replace main.c with the simplified version below. Edit the Makefile and set the CPU variable to msp430x149 so that it compiles for the correct target. If you are using a different version of the MSP430, you can get a list of the supported types by running msp430-gcc --target-help | less and then set CPU to the appropriate type.

Figure 1. Picture of My LED Blinker Development Board and JTAG Adapter

Figure 2. Simple Schematic of the LED Blinker Setup

Replacement for main.c:

/* Simple LED Blinker program for MSP430 */
#include <msp430x14x.h>

/* Brute Force delay loop */
void delay(unsigned int d)
    for (; d>0; d--) {

int main( void )
    /* Init watchdog timer to off */

    /* Init Output ports to GND */
    P1OUT  = 0x00;
    P2OUT  = 0x00;

    /* I/O not module control */
    P1SEL  = 0x00;
    P2SEL  = 0x00;

    /* Setup the data direction registers
       P1.0 output, input on the rest
    P1DIR  = 0x01;
    P2DIR  = 0x00;

    /* No Interrupts on Port Pins */
    P1IES  = 0x00;
    P2IES  = 0x00;
    P1IE   = 0x00;
    P2IE   = 0x00;

    /* Loop until the universe breaks down */
    while (1) {
        /* Toggle P1.0 ouput pin */
        P1OUT ^= 0x01;

        /* Delay for a while before blinking */
    }  /* while */

Run make to compile it. You should see no warnings or errors:

msp430-gcc -mmcu=msp430x149 -O2 -Wall -g   -c -o main.o main.c
msp430-gcc -mmcu=msp430x149 -o leds.elf main.o
msp430-objcopy -O ihex leds.elf leds.a43
msp430-objdump -dSt leds.elf >leds.lst

At this point, we have the software development set up, but no hardware to run it on or LEDS to blink.

MSP430 Simple Hardware Setup

Very little hardware or money is required to get started with the MSP430. You need a PC board with the processor on it and a JTAG adapter to connect the board to the parallel port. Olimex makes a number of inexpensive evaluation boards and JTAG adapters for the MSP430, ARM, AVR and PIC. In the US, their products are carried by a neat place called Spark Fun Electronics, which carries the Olimex boards as well as its own unique collection of adapter boards and projects. Table 1 shows what's needed to build the circuit on the schematic in Figure 1.

Table 1. Materials and Cost for Circuit

DescriptionPart #Price (US)
Olimex MSP430F149 header boardMSP-H149$22
Olimex MSP430 JTAG AdapterMSP-JTAG$15
AA battery pack from DigiKey2463K-ND$0.78
Red LED from DigiKey160-1499-ND$3.60/10
330-ohm resistor220QBK-ND$0.56/10

One problem with low-powered devices like the MSP430 is that when you try to turn them off, they don't discharge the supply capacitors all the way to ground. This can result in a brownout condition where the processor won't reboot until reset properly. For the sake of simplicity, we are going to run the processor directly off of a pair of AA batteries. It will also run off the power from the JTAG adapter itself if you don't have any batteries handy.

In a production design, I would add a power supply with reset manager to prevent any brownout problems, but for our simple circuit, pulling the batteries loose for a few seconds is sufficient to reset it.

The next thing we need to do is set up the gdb proxy and JTAG software. This requires using the PC's parallel port, and if your Linux installation is set up to use a local printer, you need to remove the printer and disable the printer dæmon before you can use the port for JTAG. You also may need to add your development user to the group that has access to the port. On Fedora Core, this is the lp group, and you can add users to it by editing the /etc/group file as root.

Now that we have the required hardware set up, it's time to compile and flash our LED blinker program. In the directory where we ran make earlier, you can now run make download-jtag, and the program will be flashed into the target processor:

msp430-jtag -e leds.elf
MSP430 parallel JTAG programmer Version: 1.3
SHF_MASKPROC    = 0xf0000000
Mass Erase...
Program ...
188 bytes programmed.

Next, we need to start the gdb proxy that creates a local port for gdb to connect to and handles the communication with the target hardware. Run this in a second window, because it outputs debugging info to stdout while it is running:

msp430-gdbproxy --debug --port=2000 msp430

Remote proxy for GDB, v0.7.1, Copyright (C) 1999 Quality Quorum Inc.
MSP430 adaption Copyright (C) 2002 Chris Liechti and Steve Underwood

GDBproxy comes with ABSOLUTELY NO WARRANTY; for details
use --warranty' option. This is Open Source software. You are
welcome to redistribute it under certain conditions. Use the
'--copying' option for details.

debug:     msp430: msp430_open()
info:      msp430: Target device is a 'MSP430F149' (type 7)
notice:    msp430-gdbproxy: waiting on TCP port 2000

Figure 3. Simple Diagram of GDB to Target Board Connections

GDB needs to know how to connect to the MSP430 JTAG proxy port. Create a file named .gdbinit in your working directory and put the following three lines into it:

set remoteaddresssize 64
set remotetimeout 999999
target remote localhost:2000

Now we are ready to debug our LED blinker program. When you ran make download-jtag, the LED should have begun to blink, and when the gdbproxy was started, it should have stopped, because the processor is being held in reset by the JTAG.

Start debugging by using the msp430-gdb program:

msp430-gdb leds.elf

Run until main() by entering:

break main

Debug as you normally would. Here is an example session:

(gdb) break main
Breakpoint 1 at 0x1152: file main.c, line 16.
(gdb) c

Breakpoint 1, main () at main.c:16
(gdb) n
19          P1OUT  = 0x00;
(gdb) n
20          P2OUT  = 0x00;
(gdb) break delay
Breakpoint 2 at 0x1140: file main.c, line 7.
(gdb) c

Breakpoint 2, delay (d=20479) at main.c:7
7           for (; d>0; d--) {
(gdb) n
8               nop();
(gdb) n
9               nop();
(gdb) n
7           for (; d>0; d--) {
(gdb) print d
$1 = 20479

What's happening here is that the proxy is communicating with the JTAG adapter and opening up port 2000 to accept connections from the gdb debugger. The debugger needs to know where to connect to, hence the creation of the .gdbinit file with the port number and timeout in it. When you run msp430-gdb, it is making a TCP/IP connection to the JTAG proxy program, which is in turn communicating with the target hardware if all is going well.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

naken430asm msp430

Anon's picture

naken430asm msp430 assembler/disassembler:

naken430asm msp430

Anon's picture

naken430asm msp430 assembler/disassembler:


cihip's picture

MSP430 Development with Linux post for thanx.

MSP430 programmer

Dilip Shirke's picture

Dear sir/madam

I am student of electronic sc. I want to develope systems using MSP430 but I donot have development board for it I know technique for PCB fabrication If you provide me layout for it so I can start working on it.

Thank you

You should put this on TI's MSP430 site

Anonymous's picture

Go to They have tons of msp430 apps available for download!

MSP430 Dev just got a lot easier and cheaper

Doug LaRue's picture

Nice article Brian but I just wanted to let everyone know that TI has a MSP430F2013 dev setup for $20 and it works with the msp430-dgbproxy. It's call the EZ430 and you can even get 3 extra msp4302012 boards for $10, also from TI.

Now the real 'goody' is that you can get Eclipse using standard packaging software in Ubuntu/Kubuntu/Edubuntu along with the CDT but it's an older CDT so I had to get v3.1.1 in .deb format elsewhere. I was also able to build the mspgcc tools, get the gdbproxy 'seeing' the USB based EZ430 and coding/debugging from within Eclipse.

Pretty awesome. I'll be putting together some online pages to help anybody through this and will post the link ASAP.

Oh, supposedly, the MSP430-JTAG-UIF adapter works the same as the EZ430 adapter since they both have the same USB ID. The difference is the EZ430 uses the 4 wire spy-bi-wire interface and not the full JTAG interface. This does mean that a good number of other MSP430 chips can also be developed and debugged with the $20 EZ430 setup with the right wires/pins connected.

ez430 doc

Anonymous's picture

Hi there. Did you ever put up a tutorial for the ez430 and linux? im working in circles trying to get the two work together.


ez430 doc

Anonymous's picture

Hi Wernher,

please have a look at this resources:
(Thanks to Friedrich Lobenstock)

I 've got it work on a openSuse 10.2 (32Bit) System. If you use the, it should install from sources for another distribution too.
To avoid a lot of errors download the complete "downloads" dir to your install directory before you start. There are also a few problems with the pathes in - you should solve them.

Good luck,


help help help

Ankur shah's picture

neeed desperate help!
i am a first time user of gcc and am trying to work out things for a project. howeve a silly thing frustrates me. can anyone tell me how one can read or retrieve data from the keyboard using gcc?? i am finding it difficlut using scanf or even commands like getchar, which my system doesnt recognise? are there any other ways??

msp430 and Linux 10 64bit

Parseval's picture


I'am trying a solution of the cdk-msp under linux 10 64bit since 3 days now and it is making me crazy.

I cann't use the src.rpm (error: Legacy syntax is unsupported: copyright).

My problem is to get the connection to the JTAG Interface with the msp430-jtag or the msp430-dbgproxy.

Can someone help me plz.


64 Bit MSP

amattas's picture

Were you ever able to get 64Bit MSP430 to work?

Eagle, PCB Fabrication

Frank Chambers's picture

The Eagle website has links to several PCB suppliers that can and will work directly from Eagle .brd files. I have used these services for several years and have obtained very good results at a low cost. The company I have done the most with CustomPCB seeems to prefer working with the brd file and provides a rules file for design check prior to sending the file.

This saves the extra steps of converting to Gerber and then trying to see if it is correct.


excellent article

timborn's picture

I look forward to LJ every month, and with few exceptions read every article. The quality and caliber is uniformly high.

This particular article, however, got positively dog-eared from being re-read a half dozen times. It rekindled a lost love of micros and tinkering. I had flashbacks of when Ciarcia wrote Circuit Celler articles for BYTE many years back (yep, I know about Circuit Cellar Ink, but I'm basically a sotfware guy with a hardware itch, and most of those articles are lost on me).

I would love to see more articles along this line, perhaps expanding on the board layout & etching process eluded to at the tail end of the article. I have etched boards before at home; it's a pain. Clearly there are better ways available now.

Curious how one goes about installing surface mount chips, since it looks like the MSP430 are all surface mount - no bugs with legs for tinkerers!

I make a lot of my own PCBs

Leon Heller's picture

I make a lot of my own PCBs at home, and don't have any problems soldering chips like the MSP430 - plenty of light, magnification and a good soldering iron (I use Metcal equipment) are essential.


Using MSP-430 USB debug interface

Sameer's picture

Hi all,
I want to know whether we could work out programming and debugging msp430 using the MSP430-USB-Debug-Interface. I have MSPGCC's latest version. I tried download using msp430-jtag -e filename.elf but is don't seem to be working. I found very few explations about using USB interface for MSP430 on net.

Sameer S. Upasani
India, Pune

Using MSP430 - eZ430 on ubuntu / linux?

Arun's picture

I would like to know if there is way to use the eZ430 USB stick on linux specifically on ubuntu! Any info in this regard will be of great help :-)
Thanks and regards,

Ez430 Linux USB Driver FIX!

Anonymous's picture


After two days of searching the net, I finally found the fix we've been waiting for.
First, I made fetched ti_usb_3410_5052 v1.1 driver, hoping that would fix it (v0.9 is in the latest kernel for some reason.) After an hour of fixing it to compile with my ubuntu kernel, I was back to square one with this error (v1.1 just adds some product ids, doesn't seem to add any other functionality.)

[462913.996000] drivers/usb/serial/usb-serial.c: USB Serial support registered for TI USB 3410 1 port adapter
[462914.000000] drivers/usb/serial/usb-serial.c: USB Serial support registered for TI USB 5052 2 port adapter
[462914.000000] ti_usb_3410_5052 3-4:1.0: TI USB 3410 1 port adapter converter detected
[462914.000000] /home/tom/tars/ti_usb_2.6-1.1/src/ti_usb_3410_5052.c: ti_startup - product 0xF430, num configurations 1, configuration value 1
[462914.000000] /home/tom/tars/ti_usb_2.6-1.1/src/ti_usb_3410_5052.c: ti_startup - device type is 3410
[462914.000000] /home/tom/tars/ti_usb_2.6-1.1/src/ti_usb_3410_5052.c: ti_download_firmware - downloading firmware
[462914.532000] /home/tom/tars/ti_usb_2.6-1.1/src/ti_usb_3410_5052.c: ti_download_firmware - download successful
[462914.812000] usb 3-4: reset full speed USB device using ohci_hcd and address 58
[462915.020000] usb 3-4: device firmware changed
[462915.020000] usb 3-4: USB disconnect, address 58
[462915.020000] ti_usb_3410_5052: probe of 3-4:1.0 failed with error -5

That was the original error. Essentially, it is a bug in driver. After looking at 5+ patches, I ran across one by Oleg V.

It is also right here.

Quoting Oleg Verych <[EMAIL PROTECTED]>:

> pp-by: Oleg Verych
> ---
> i.e. no more uGLYdev with sysfs
> Alan, i'm looking forward to deal with this crutch :-E
> drivers/usb/serial/ti_usb_3410_5052.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> Index: linux-2.6.21-rc1/drivers/usb/serial/ti_usb_3410_5052.c
> ===================================================================
> --- linux-2.6.21-rc1.orig/drivers/usb/serial/ti_usb_3410_5052.c
> 2007-02-23
> 05:03:57.691537658 +0100
> +++ linux-2.6.21-rc1/drivers/usb/serial/ti_usb_3410_5052.c 2007-02-23
> 05:22:22.766512292 +0100
> @@ -389,13 +389,13 @@
> usb_reset_device(dev);
> }
> - status = -ENODEV;
> + status = 0x01E; /* positive status -- device to be reconfigured
> */
> goto free_tdev;
> }
> - /* the second configuration must be set (in sysfs by hotplug script) */
> if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) {
> - status = -ENODEV;
> + (void) usb_driver_set_configuration(dev, TI_ACTIVE_CONFIG);
> + status = 0xA1B;
> goto free_tdev;
> }
> --

So all you have to do, is download your kernel sources, and apply this patch. Now if yoti_usb_3410_5052ur kernel version is < 2.6.16 or so, you will also have to add in the PRODUCT_ids for the Ez430 device. I suggest you upgrade your kernel, since the product id fix is in kernels >~ 2.6.16 or so.

I applied the patch by hand, to the /usr/src/linux-source---/drivers/usb/serial/ti_usb_3410_5052.c file.

recompile.... And viola, it works! if I modprobe it before or after the device is inserted, no hotplug script needed!

Here is the working dmesg dump

[464233.560000] drivers/usb/serial/usb-serial.c: USB Serial support registered for TI USB 3410 1 port adapter
[464233.560000] drivers/usb/serial/usb-serial.c: USB Serial support registered for TI USB 5052 2 port adapter
[464233.564000] usbcore: registered new interface driver ti_usb_3410_5052
[464233.564000] /home/tom/tars/ti_usb_2.6-1.1/src/ti_usb_3410_5052.c: TI USB 3410/5052 Serial Driver v1.1
[464241.468000] ti_usb_3410_5052 3-4:2.0: TI USB 3410 1 port adapter converter detected
[464241.468000] usb 3-4: TI USB 3410 1 port adapter converter now attached to ttyUSB0

So in conclusion, apply patch to a newer kernel, and enjoy. I'm glad I devoted my time into fixing this stupid problem once and for all.

--Tom Golubev

TI MSP-30 USB interface

Tommaso Toffoli's picture

Dear Sameer:

I'm very interested in that issue. I wonder whether you got any
responses to you enquiry, or in any event found some information on how to interface the MSP430 USB development kit to Linux. I would like to
drive the development (assembly/running/debugging from a Python environment.
Many thanks


Bodo Michalski's picture

By reviewing your articles I found out that the quality is very high. I take a lot of advantages from the articles for my work. Thank you to the linux-team and all the comments.
Bodo Michalski from Germany

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState