Wednesday, November 12, 2014

MSP430 - How to use mspdebug

When using the MSP430 under Linux, in order to load the compiled code with mspgcc, exists a
utility called mspdebug.


Mspdebug is not part of the MSPGCC toolchain, so it must be downloaded and prepared separatedly.
Also the final placement could end  not be in the toolchain path but on a more generic one.
Almost every distribution has it, so the easiest way to install it is from there.

Alternatively, is possible to download the code from the mspdebug web site, then be sure to have installed the necessary libraries.

In particular must be installed :
  • libncurses5-dev
  • zlibc
  • zlib1g-dev
  • libx11-dev
  • libusb-dev
  • libreadline5-dev (or libreadline6-dev for newver version of Ubuntu)

Then :
  • $ tar xvfz mspdebug-version.tar.gz
  • $ cd mspdebug-version
  • $ make
  • $ sudo make install

At the end of the process, the mspdebug program will be placed in /usr/local/bin directory.

LaunchPad - Use


I'm describing the operations to use mspdebug with the LaunchPad.
Connect the LaunchPad to the host USB
Verify that the interface is seen by the system (the entry to check is highlighted) using lsusb.

steve@Oliver3:~$ lsusb
Bus 008 Device 023: ID 0781:a7c1 SanDisk Corp.
Bus 008 Device 001: ID 0000:0000
Bus 007 Device 018: ID 0451:f432 Texas Instruments, Inc.
Bus 007 Device 016: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 007 Device 015: ID 06cd:0121 Keyspan USA-19hs serial adapter
Bus 007 Device 014: ID 17d0:0116
Bus 007 Device 003: ID 0409:0058 NEC Corp. HighSpeed Hub
Bus 007 Device 001: ID 0000:0000
Bus 005 Device 002: ID 04a9:2206 Canon, Inc. CanoScan N650U/N656U
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 002: ID 138c:0001
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 003: ID 0a81:0205 Chesen Electronics Corp. PS/2 Keyboard+Mouse Adapter
Bus 002 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000

Unless enabling the USB to a specific user, you need to be superuser to run mspdebug.
The interface to use is called rf2500.

Here a session opened with my main host (Ubuntu 8.04 LTS) and LaunchPad :

steve@Oliver3:~$ sudo mspdebug rf2500
MSPDebug version 0.9 - debugging tool for MSP430 MCUs
Copyright (C) 2009, 2010 Daniel Beer <>
This is free software; see the source for copying conditions. There is NO

Trying to open interface 1 on 018
Initializing FET...
FET protocol version is 30066536
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
Device ID: 0xf201
Device: MSP430F2013
Code memory starts at 0xf800

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

At this point is possible to work on the target, erasing the memory, loading test code and running the debugger.

For example, just to load a program (ELF format) on the MSP430, simply digit from inside the mspdebug program :

prog name_program.elf

Debugger (manual)

Here a sequence of operations to debug the code manually, using the debugger.
It is assumed that the mspdebug program is launched from the directory containing the elf file to debug.
The bolded lines are the ones to digit.

Load the program to be debugged in the microcontroller (from mspdebug)
(mspdebug) prog name_program.elf
Start the remote (target) gdb
(mspdebug) gdb
Bound to port 2000. Now waiting for connection...

At this point open a new terminal and go to the directory where the source code and elf are.
The bolded lines are the ones to digit.

Start the debugger

$ msp430-gdb name_program.elf
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=msp430"...

Attach the debugger to the target
(gdb) target remote localhost:2000
Remote debugging using localhost:2000
0x0000f800 in _reset_vector__ ()

At this point it is possible to debug the code using the gdb commands.

No comments:

Post a Comment