Just moozing

Before you can check your notes, you must make them…

MSP430 on Debian

leave a comment »

I have some small project that I want done, and for that purpose I have need of a small embedded system. The students use the TI MSP430, so it was natural for me to look at that also. In this blog, I will set up the system for command line access to the MSP430.

The device

I use the MSP-EXP430G2 evaluation board. It has a price tag on TI.com of $4.30, so, from a financial point of view, it seems to be a reasonable device to build into stuff. The specific chip I use is the MSP430G2231, which is a modest chip with 128 bytes of memory and 2 kB of flash – so we are not going to do big projects on this one. The MSP430 is a series of chip from TI.com with a broad range of features, so starting with this one, it is possible to expand the system with more IOs, wireless and peripherals in general.

Connecting the device

#tail -f /var/log/syslog
Jan 20 14:06:05 Tinkerbell kernel: [ 1758.320074] usb 3-2: new full-speed USB device number 2 using uhci_hcd
Jan 20 14:06:06 Tinkerbell kernel: [ 1758.528022] usb 3-2: New USB device found, idVendor=0451, idProduct=f432
Jan 20 14:06:06 Tinkerbell kernel: [ 1758.528052] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 20 14:06:06 Tinkerbell kernel: [ 1758.528058] usb 3-2: Product: Texas Instruments MSP-FET430UIF
Jan 20 14:06:06 Tinkerbell kernel: [ 1758.528062] usb 3-2: Manufacturer: Texas Instruments
Jan 20 14:06:06 Tinkerbell kernel: [ 1758.528066] usb 3-2: SerialNumber:
Jan 20 14:06:06 Tinkerbell mtp-probe: checking bus 3, device 2: "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2"
Jan 20 14:06:06 Tinkerbell mtp-probe: bus: 3, device: 2 was not an MTP device
Jan 20 14:06:07 Tinkerbell kernel: [ 1759.756582] cdc_acm 3-2:1.0: This device cannot do calls on its own. It is not a modem.
Jan 20 14:06:07 Tinkerbell kernel: [ 1759.756593] cdc_acm 3-2:1.0: No union descriptor, testing for castrated device
Jan 20 14:06:07 Tinkerbell kernel: [ 1759.756683] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
Jan 20 14:06:07 Tinkerbell kernel: [ 1759.759967] usbcore: registered new interface driver cdc_acm
Jan 20 14:06:07 Tinkerbell kernel: [ 1759.759973] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
Jan 20 14:06:07 Tinkerbell modem-manager[2806]:  (ttyACM0) opening serial port...
Jan 20 14:06:12 Tinkerbell kernel: [ 1765.353888] tty_port_close_start: tty->count = 1 port count = 0.
Jan 20 14:06:17 Tinkerbell kernel: [ 1769.841125] generic-usb 0003:0451:F432.0001: usb_submit_urb(ctrl) failed
Jan 20 14:06:17 Tinkerbell kernel: [ 1769.841157] generic-usb 0003:0451:F432.0001: timeout initializing reports
Jan 20 14:06:17 Tinkerbell kernel: [ 1769.842171] generic-usb 0003:0451:F432.0001: hiddev0,hidraw0: USB HID v1.01 Device [Texas Instruments Texas Instruments MSP-FET430UIF] on usb-0000:00:1d.1-2/input1
Jan 20 14:06:17 Tinkerbell kernel: [ 1769.842214] usbcore: registered new interface driver usbhid
Jan 20 14:06:17 Tinkerbell kernel: [ 1769.842218] usbhid: USB HID core driver

Some comments

  • I was surprised that it took 10 seconds to settle.
  • The MTP driver decides that it it not a music device.
  • cdc-acm (common device class, Abstract control model) – I don’t know much about it, except that it the one that we use for some serial connection 🙂

And the system now has a serial device called ttyACM0.

# ls /dev/ttyACM0 -al
crw-rw---T 1 root dialout 166, 0 Jan 20 14:06 /dev/ttyACM0

This tells me that the user needs to be in the dialout group to be able to use it. For some reason it doesn’t work, so unplug the device a replug it

#ls -l /dev/ttyACM0
crw-rw---T 1 root plugdev 166, 0 Jan 20 17:38 /dev/ttyACM0

This changed the group to plugdev, and that is what we want for later.

Installing software

We will be using gcc and the other tools available on Linux. It is possible to use code composer studio, but I decided to use standard eclipse with the appropriate plugins (more on that in a later blog post).

Basically, you need compilers, linkers, libraries, programmers and debuggers, aka. a tool chain. On Debian, it is in the prebuild packages. I use Debian Wheezy. Some inspiration was from this site.

# apt-get install mspdebug gcc-msp430 gdb-msp430 build-essential

This will install extra packages also.

Testing tool chain

First we need a hello world program. Get it from here and save it in a directory – say, ~/Downloads/MSP430.

Compile and link the hello_world code

$ msp430-gcc -g -mmcu=msp430g2231 -o hello_world.elf hello_world.c

Accessing the device

$ mspdebug rf2500

If you get permission issues when running the mspdebug command, check your groups and the group of the ttyACM? device. It must be plugdev.

Upload and run the program

(mspdebug) prog hello_world.elf
(mspdebug) run

now you should have the green and red diode blinking alternately. Congratulations.

The debugger

On the net a lot of reference to msp-gdbproxy was found – it seems to be something that you use if you have an external JTAG debugger. That is not applicable to our setup, where we use the build-in debugging possibilities of the evaluation board.

To test msp430-gdb I follow the few steps outlined here.

You need two terminals

In terminal #1

$ mspdebug rf2500 gdb

In terminal #2
Create a text file with the commands we want to run

$ cd ~/Documents/MSP430
$ cat > gdbcmd.txt << EOF
set remoteaddresssize 16
set remotetimeout 999999
target remote localhost:2000
set remote memory-write-packet-size 512
set remote memory-write-packet-size fixed
set remote memory-read-packet-size 512
set remote memory-read-packet-size fixed
erase all
load hello_world.elf

And run it

$ msp430-gdb --command=gdbcmd.txt

Do check the output for errors.

So what did we just do? In terminal #1 we started mspdebug which connected to the MSP board and opened port 2000 for debugging. In terminal #2, we started the debugger which connected to port 2000, set some variables  erase the old program, downloaded the hello world program and ran it. If you have doubts, just try to change the blink time, and you will be convinced that we downloaded the program over the debug port.


Closing words

The tool chain is now working and we have even tested that it works.

Some stuff that should be done at some point.

  • Find the reference manual and example code for the MSP430. We want the list of stuff like P1DIR and what it means.
  • Setup eclipse to get some GUI based editing, testing and debugging.
  • Get to know GDB. I have a feeling that I am going to get obscure GDB error messages when I start doing real debugging on the MSP 🙂

Stay tuned. The MSP stuff will be tagged MSP430.


Written by moozing

January 21, 2013 at 09:00

Posted in Tech

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: