Jump to content

4-wire JTAG with mspdebug and Raspberry Pi GPIO

Recommended Posts

Having a small collection of older F1xx and F4xx MSP430 devices, I've been looking for a convenient way to flash and debug them.  The devices I have don't support Spy By Wire, so they require 4-wire JTAG.  They also have their JTAG pins shared with other functions, so the test and reset pins have to be used to put them into JTAG mode.  


While I do have an Olimex parallel-port JTAG adapter, the computer I use most of the time has no parallel port.  


A Raspberry Pi running Debian Jessie and mspdebug with its gpio driver looked like a good option.  Adding a patch to mspdebug so that the gpio driver supports the reset and test pins got it working.  


The patch is here: https://github.com/johnp789/mspdebug/tree/gpiojtag


Now, I only need a Raspberry Pi Zero, Debian Jessie with the USB ethernet gadget configured on a micro SD card, a USB cable, and 7 jumper wires to flash and debug 4-wire JTAG MSP430 devices.  The Pi Zero might be the lowest-cost 4-wire MSP430 JTAG debugger available!   :)

$ sudo ./mspdebug -j -d "tdi=3 tdo=2 tms=4 tck=17 rst=22 tst=27" gpio
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.

gpio tms= 4
gpio tdi= 3
gpio tdo= 2
gpio tck= 17
gpio rst= 22
gpio tst= 27
Starting JTAG
JTAG_power on
led green
JTAG ID: 0x89
Chip ID data:
  ver_id:         49f4
  ver_sub_id:     0000
  revision:       01
  fab:            40
  self:           0000
  config:         00
Device: MSP430F44x

Available commands:
    !               fill            power           setwatch_r
    =               gdb             prog            setwatch_w
    alias           help            read            simio
    blow_jtag_fuse  hexout          regs            step
    break           isearch         reset           sym
    blow_jtag_fuse  hexout          regs            step
    break           isearch         reset           sym
    cgraph          load            run             verify
    delbreak        load_raw        save_raw        verify_raw
    dis             md              set
    erase           mw              setbreak
    exit            opt             setwatch

Available options:
    color                       gdb_default_port
    enable_bsl_access           gdb_loop
    enable_fuse_blow            gdbc_xfer_size
    enable_locked_flash_access  iradix
    fet_block_size              quiet

Type "help <topic>" for more information.
Use the "opt" command ("help opt") to set options.
Press Ctrl+D to quit.

(mspdebug) prog fet440_1.c.hex
led green
led red
led red
Writing   74 bytes at 1100...
led red
led red
Writing   32 bytes at ffe0...
led red
led red
Done, 106 bytes total
Link to post
Share on other sites

4-wire JTAG with this setup did not work for me with an MSP430G2452.  Mspdebug gave me a response that it read 0xFF for a device ID and exited.  However, looking at the JTAG entry sequence on my scope, it didn't look quite right.  I patched mspdebug again, and now I get a connection to the MSP430G2452.  I haven't changed my wiring back to try it with the 'F449 yet, so I may have broken that.  

$ git diff
diff --git a/drivers/jtaglib.c b/drivers/jtaglib.c
index 1161606..17975ce 100644
--- a/drivers/jtaglib.c
+++ b/drivers/jtaglib.c
@@ -386,12 +386,20 @@ unsigned int jtag_init(struct jtdev *p)
-       jtag_tst_set(p);
+       jtag_rst_set(p);
+       jtag_tst_clr(p);
+       jtag_tst_set(p);
+       jtag_tst_clr(p);
+       jtag_tst_set(p);

Link to post
Share on other sites

It makes me smile inside every time I can cut one of those proprietary TI hooks they use to hold me down.  I'm so happy to be able to use open source software that ships with full source code. It always leads me to a deeper understand of how everything works and greater freedom to work on my choice of hardware now and in the future.


I just loaded up some code and was able to upload and debug it using msp430-gcc, mspdebug, and msp430-gdb that I compiled on the raspberry pi without a trace of any TI software in sight.





Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...