This note explains how to install the command-line tools in Ubuntu to compile, load and run images destined for the Texas Instrument EZ430-F2013.
The TI EZ430-F2013 is a USB development environment for small dongles that host a TI MSP430 micro-controller (MSP430-F2012 and MSP430-F2013).
This note relates to:
Install Packages
The packages required to work with the MSP430 are available from the main repositories.
|
sudo apt-get install binutils-msp430 gcc-msp430 gdb-msp430 msp430-libc msp430mcu mspdebug |
Verify Drivers for EZ430-F2013
Insert the EZ430-F2013 in a USB port. Then, run “dmesg” to verify that it was detected correctly:
The output should end with a set of lines that looks as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
[47661.708176] usb 5-1: new full-speed USB device number 8 using uhci_hcd [47661.905243] usb 5-1: New USB device found, idVendor=0451, idProduct=f430 [47661.905253] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [47661.905260] usb 5-1: Product: MSP-FET430UIF JTAG Tool [47661.905266] usb 5-1: Manufacturer: Texas Instruments [47661.905272] usb 5-1: SerialNumber: TUSB3410572A43E3DB45FFB1 [47661.909238] ti_usb_3410_5052 5-1:1.0: TI USB 3410 1 port adapter converter detected [47662.492172] usb 5-1: reset full-speed USB device number 8 using uhci_hcd [47662.636193] usb 5-1: device firmware changed [47662.636240] ti_usb_3410_5052: probe of 5-1:1.0 failed with error -5 [47662.636365] usb 5-1: USB disconnect, device number 8 [47662.804100] usb 5-1: new full-speed USB device number 9 using uhci_hcd [47663.029224] usb 5-1: New USB device found, idVendor=0451, idProduct=f430 [47663.029233] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [47663.029240] usb 5-1: Product: MSP-FET430UIF JTAG Tool [47663.029246] usb 5-1: Manufacturer: Texas Instruments [47663.029252] usb 5-1: SerialNumber: TUSB3410572A43E3DB45FFB1 [47663.032921] ti_usb_3410_5052 5-1:1.0: TI USB 3410 1 port adapter converter detected [47663.032950] ti_usb_3410_5052: probe of 5-1:1.0 failed with error -5 [47663.037227] ti_usb_3410_5052 5-1:2.0: TI USB 3410 1 port adapter converter detected [47663.037509] usb 5-1: TI USB 3410 1 port adapter converter now attached to ttyUSB0 |
The report from “dmesg” shows that the development kit was mounted to /dev/ttyUSB0. For the remainder of the note, this value is assumed. However, you might need to adjust this value to fit your particular installation.
Writing a program for MSP430-F2013
Create a new source file.
Paste the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <msp430f2013.h> #define DIM(x) (sizeof(x)/sizeof(x[0])) #define DOT {10000, 1} #define DASH {30000, 1} #define SP { 8000, 0} #define LTR {16000, 0} #define WRD {80000, 0} #define MORSE_S DOT,SP,DOT,SP,DOT,LTR #define MORSE_O DASH,SP,DASH,SP,DASH,LTR typedef struct _Segment { unsigned long delay; unsigned char state; } Segment; Segment segments[] = { MORSE_S ,MORSE_O ,MORSE_S ,WRD }; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= 0x01; // Set P1.0 to output direction int sequence = 0; for (;;) { volatile unsigned long i; Segment segment = segments[sequence]; if( segment.state ) { P1OUT |= 0x01; // Turn on LED } else { P1OUT &= 0xfe; // Turn off LED } i = segment.delay; // Delay do (i--); while (i != 0); // Go to next segment ++sequence; if( sequence >= DIM(segments) ){ sequence = 0; } } return 0; } |
The code above drives the LED found on the MSP430-F2013 to emit “SOS” in Morse code. A number of definitions are already declared in the file “msp430f2013.h”. Many header files relating to the MSP430 can be found in the directory /usr/msp430/include.
Compiling and Linking Program
Compiling and linking programs/images for the MSP430 is done by using “msp430-gcc”, which is a version of “gcc” that targets the MSP430 micro-controller. Most options available for “gcc” are also available for “msp430-gcc”.
Compiling using “msp430-gcc” yields object files, as with “gcc”. However, invoking the linker produces *.elf files, which can be loaded on the MSP430-F2013 via the development kit (EZ430-F2013).
Following the example started above, the two lines required to produce an object file from the source code, and then link into an image:
|
msp430-gcc -c -mmcu=msp430f2013 -g -Os -Wall -Wunused -IInclude -o sos.o sos.c msp430-gcc sos.o -mmcu=msp430f2013 -Wl,-Map=sos.map -o sos.elf |
mspdebug
A command line utility called “mspdebug” is used to perform most operations that involves the EZ430-F2013 development kit.
First, insert the EZ430-F2013 in a USB port and verify that it is mounted to /dev/ttyUSB0 (see steps above).
When invoking “mspdebug”, one must specify the device that the EZ430-F2013 is mounted as.
|
mspdebug uif -d /dev/ttyUSB0 |
This command opens a shell where a number of commands can be sent to the development kit. To leave the shell, press CTRL-D.
Loading Image on MSP430-F2013
Loading an image on an instance of MSP430-F2013 via the development kit is accomplished by using “mspdebug”:
|
mspdebug uif -d <device> "prog <elf-file>" |
where:
- <device> refers to the device file name where the USB development kit is mounted
- <elf-file> refers to the ELF file produce by the msp430-gcc linker
Following the example above:
|
mspdebug uif -d /dev/ttyUSB0 "prog sos.elf" |
Debugging MSP430
Via the EZ430-F2013, one can debug the program loaded in the MSP430, including single-step execution, via the “gdb” debugger provided by the MSP430 packages. The command-line utility “msp430-gdb” is similar to “gdb” but designed for the MSP430 micro-controller. However, “mspdebug” is needed to bridge “msp430-gdb” to the MSP430 via the EZ430-F2013 development kit.
The command “gdb” within the shell provided by “mspdebug” start a server that listens to commands from “msp430-gdb” and forwards them to the EZ430-F2013 development kit. When “msp430-gdb” connects to “mspdebug”, it provides a shell similar to the one provided by “gdb”.
The command required to start the server is:
|
mspdebug uif -d <device> gdb |
In a different terminal, attach the debugger with the following command:
The commands available in “gdb” are also available in “msp430-gdb”:
- To execute program: continue
- To stop program: CTRL-C
- To list stack variables: info locals
- To list global variables: info variables
To continue the example started above:
|
mspdebug uif -d /dev/ttyUSB0 gdb & msp430-gdb sos.elf |
Debug using X Debugger: ddd
If X is available, one can use “ddd”, which is a GUI application to simplify the use of gdb.
To use “msp430-gdb” via “ddd”, one must first start “mspdebug” and then invoke “ddd” by specifying “msp430-gdb”. To continue the example in this note:
|
mspdebug uif -d /dev/ttyUSB0 gdb & ddd --debugger msp430-gdb sos.elf |
Conclusion
Using the TI EZ430-F2013 development kit with an Ubuntu platform is a snap since all the tools required are readily available in the main repositories. Furthermore, anyone familiar with gcc and gdb can easily transition to the line of tools designed for the MSP430 since the commands and options are almost the same.