Jump to content
jp430bb

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
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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
JTAG_connct
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
Erasing...
led red
led red
Programming...
Writing   74 bytes at 1100...
led red
led red
Writing   32 bytes at ffe0...
led red
led red
Done, 106 bytes total
(mspdebug)

Share this post


Link to post
Share on other sites

Did you happen to try this with any chips that also have SBW (2-wire JTAG)? It seems like the tst/rst toggle sequence might be different for them. I couldn't get any recent chips to respond to this.  I tried with a msp430g2553 and a msp430fr5969.  It doesn't want to let me connect.

 

-rick

Share this post


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_rst_clr(p);
        p->f->jtdev_power_on(p);
-       jtag_tst_set(p);
        jtag_tdi_set(p);
        jtag_tms_set(p);
        jtag_tck_set(p);
        jtag_tclk_set(p);
+
+       jtag_rst_set(p);
+       jtag_tst_clr(p);
+
+       jtag_tst_set(p);
        jtag_rst_clr(p);
+       jtag_tst_clr(p);
+
+       jtag_tst_set(p);
+
        p->f->jtdev_connect(p);
        jtag_rst_set(p);
        jtag_reset_tap(p);

Share this post


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.

 

Thanks,

 

-rick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×