Loading code onto target msp and debugging

In the last post I finally compiled the blinked led example and created a makefile. Now we want to load program onto the target and let it run.

First you need to connect your EZ430 to your computer. It will start running the whatever was loaded last.

Then connect mspdebug to your ez430 with ‘mspdebug -d /dev/ttyUSB0‘. If this gives you an error you will need to find the correct device. You can see if the device is recognized by your system by watching your /var/log/message file when you connect the EX430 and via the lsusb command. Below is the output I get on my system for both commands.

$ lsusb
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 005: ID 0451:f430 Texas Instruments, Inc. MSP-FET430UIF JTAG Tool
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ tail -f /var/log/messages
Aug 15 22:26:56 linux-desktop kernel: [21806.152048] usb 4-1: new full speed USB device using ohci_hcd and address 4
Aug 15 22:26:56 linux-desktop kernel: [21806.337313] usb 4-1: configuration #1 chosen from 1 choice
Aug 15 22:26:56 linux-desktop kernel: [21806.341196] ti_usb_3410_5052 4-1:1.0: TI USB 3410 1 port adapter converter detected
Aug 15 22:26:56 linux-desktop kernel: [21806.341216] usb 4-1: firmware: requesting ti_usb-v0451-pf430.fw
Aug 15 22:26:56 linux-desktop kernel: [21806.345078] usb 4-1: firmware: requesting ti_3410.fw
Aug 15 22:26:56 linux-desktop kernel: [21807.028065] usb 4-1: reset full speed USB device using ohci_hcd and address 4
Aug 15 22:26:57 linux-desktop kernel: [21807.193080] usb 4-1: device firmware changed
Aug 15 22:26:57 linux-desktop kernel: [21807.193140] ti_usb_3410_5052: probe of 4-1:1.0 failed with error -5
Aug 15 22:26:57 linux-desktop kernel: [21807.193231] usb 4-1: USB disconnect, address 4
Aug 15 22:26:57 linux-desktop kernel: [21807.332049] usb 4-1: new full speed USB device using ohci_hcd and address 5
Aug 15 22:26:57 linux-desktop kernel: [21807.549300] usb 4-1: configuration #1 chosen from 2 choices
Aug 15 22:26:57 linux-desktop kernel: [21807.552564] ti_usb_3410_5052 4-1:1.0: TI USB 3410 1 port adapter converter detected
Aug 15 22:26:57 linux-desktop kernel: [21807.552604] ti_usb_3410_5052: probe of 4-1:1.0 failed with error -5
Aug 15 22:26:57 linux-desktop kernel: [21807.557526] ti_usb_3410_5052 4-1:2.0: TI USB 3410 1 port adapter converter detected
Aug 15 22:26:57 linux-desktop kernel: [21807.557729] usb 4-1: TI USB 3410 1 port adapter converter now attached to ttyUSB0
^C

If your system connects correctly you can load the code via ‘prog led.hex’ and use mspdebug as a gdb proxy via the ‘gdb’ command.

$ mspdebug -d /dev/ttyUSB0 uif
MSPDebug version 0.10 - debugging tool for MSP430 MCUs
Copyright (C) 2009, 2010 Daniel Beer
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Trying to open UIF on /dev/ttyUSB0…
Initializing FET…
FET protocol version is 10002000
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
Device: MSP430F20x3
Code memory starts at 0xf800
Number of breakpoints: 2

Available commands:
= dis hexout opt reset step
break erase isearch prog run sym
cgraph gdb md read set
delbreak help mw regs setbreak

Available options:
color gdb_loop

Type “help ” for more information.
Press Ctrl+D to quit.

(mspdebug) prog led.hex
Erasing…
Writing 104 bytes to f800…
Writing 32 bytes to ffe0…
(mspdebug) gdb
Bound to port 2000. Now waiting for connection…

Now you can call ddd via ‘ ddd –debugger msp430-gdb led.elf‘ which tells ddd to use the msp430-gdb debugger and we are debugging led.elf. To connect I typed ‘target remote :2000‘ in the command window followed by a ‘continue‘ and then pressing the interrupt command but. I also found out that it is best to remove all breakpoints in ddd before connecting the target and always first issue the continue command otherwise the connection would be lost. Now you can single step the code, visualize your data and iron out the last bugs.

Finally to stop the ddd session use the ‘disconnect‘ command.

DDD session screenshot

Comments are closed.