Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8d9ce19

Browse files
committedAug 2, 2019
applet.debug.msp430.{jtag,sbw}: new applets.
1 parent a03db27 commit 8d9ce19

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed
 

Diff for: ‎software/glasgow/applet/all.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .debug.arc import DebugARCApplet
1919
from .debug.mips import DebugMIPSApplet
2020
from .debug.arm.swd import DebugARMSWDApplet
21+
from .debug.msp430 import DebugMSP430JTAGApplet, DebugMSP430SBWApplet
2122

2223
from .program.avr.spi import ProgramAVRSPIApplet
2324
from .program.ice40_flash import ProgramICE40FlashApplet

Diff for: ‎software/glasgow/applet/debug/mips/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ def add_run_arguments(cls, parser, access):
829829
help="select TAP #INDEX for communication (default: %(default)s)")
830830

831831
async def run(self, device, args):
832-
jtag_iface = await super().run(device, args)
832+
jtag_iface = await self.run_lower(DebugMIPSApplet, device, args)
833833
tap_iface = await jtag_iface.select_tap(args.tap_index)
834834
if not tap_iface:
835835
raise GlasgowAppletError("cannot select TAP #%d" % args.tap_index)

Diff for: ‎software/glasgow/applet/debug/msp430/__init__.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Ref: MSP430™ Programming With the JTAG Interface
2+
# Accession: G00038
3+
4+
import logging
5+
import asyncio
6+
from abc import ABCMeta, abstractmethod
7+
8+
from ....support.aobject import *
9+
from ....support.bits import *
10+
from ....arch.msp430.jtag import *
11+
from ...interface.jtag_probe import JTAGProbeApplet
12+
from ...interface.sbw_probe import SpyBiWireProbeApplet
13+
from ... import *
14+
15+
16+
class MSP430DebugError(GlasgowAppletError):
17+
pass
18+
19+
20+
class MSP430FamilyDebugInterface(aobject, metaclass=ABCMeta):
21+
async def __init__(self, interface, logger):
22+
self.lower = interface
23+
self._logger = logger
24+
self._level = logging.DEBUG if self._logger.name == __name__ else logging.TRACE
25+
26+
def _log(self, message, *args):
27+
self._logger.log(self._level, "MSP430: " + message, *args)
28+
29+
@abstractmethod
30+
async def attach(self):
31+
pass
32+
33+
34+
class MSP430DebugInterface(MSP430FamilyDebugInterface):
35+
async def attach(self):
36+
self._log("attach")
37+
await self.lower.write_ir(IR_CNTRL_SIG_16BIT)
38+
await self.lower.write_dr(DR_CNTRL_SIG_124(R_W=1, TAGFUNCSAT=1, TCE1=1).to_bits())
39+
await self.lower.write_ir(IR_CNTRL_SIG_CAPTURE)
40+
cntrl_sig = DR_CNTRL_SIG_124.from_bits(await self.lower.read_dr(16))
41+
if not cntrl_sig.TCE:
42+
raise MSP430DebugError("cannot attach: CNTRL_SIG {}"
43+
.format(cntrl_sig.bits_repr(omit_zero=True)))
44+
45+
46+
class DebugMSP430AppletMixin:
47+
preview = True
48+
description = "" # nothing to add for now
49+
50+
async def interact(self, device, args, msp430_iface):
51+
await msp430_iface.attach()
52+
53+
54+
class DebugMSP430JTAGApplet(DebugMSP430AppletMixin, JTAGProbeApplet, name="debug-msp430-jtag"):
55+
logger = logging.getLogger(__name__)
56+
help = "debug MSP430 processors via JTAG"
57+
description = """
58+
Debug Texas Instruments MSP430 processors via the 4-wire JTAG interface.
59+
""" + DebugMSP430AppletMixin.description
60+
61+
async def run(self, device, args):
62+
jtag_iface = await self.run_lower(DebugMSP430JTAGApplet, device, args)
63+
await jtag_iface.test_reset()
64+
return await MSP430DebugInterface(jtag_iface, self.logger)
65+
66+
67+
class DebugMSP430SBWApplet(DebugMSP430AppletMixin, SpyBiWireProbeApplet, name="debug-msp430-sbw"):
68+
logger = logging.getLogger(__name__)
69+
help = "debug MSP430 processors via Spy-Bi-Wire"
70+
description = """
71+
Debug Texas Instruments MSP430 processors via the 2-wire Spy-Bi-Wire interface.
72+
""" + DebugMSP430AppletMixin.description
73+
74+
async def run(self, device, args):
75+
jtag_iface = await self.run_lower(DebugMSP430SBWApplet, device, args)
76+
await jtag_iface.test_reset()
77+
return await MSP430DebugInterface(jtag_iface, self.logger)

0 commit comments

Comments
 (0)
Please sign in to comment.