CVS: python/msp430 jtag.py,1.8,1.9
Chris Liechti <[email protected]>
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mspgcc/python/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23864/python/msp430
Modified Files:
jtag.py
Log Message:
- better ability to control messages to stderr
- partial support for USB FET library (not yet functional)
Index: jtag.py
===================================================================
RCS file: /cvsroot/mspgcc/python/msp430/jtag.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- jtag.py 6 Nov 2004 00:15:48 -0000 1.8
+++ jtag.py 14 Jun 2005 10:15:26 -0000 1.9
@@ -60,9 +60,16 @@
MSP430_Initialize = MSP430mspgcc.MSP430_Initialize
MSP430_Initialize.argtypes = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_long)]
MSP430_Initialize.restype = ctypes.c_int
+ try:
MSP430_Open = MSP430mspgcc.MSP430_Open
MSP430_Open.argtypes = []
MSP430_Open.restype = ctypes.c_int
+ except AttributeError:
+ if DEBUG:
+ sys.stderr.write('MSP430_Open not found in library, using dummy.\n')
+ #TI's USB-FET lib does not have this function
+ def MSP430_Open():
+ return STATUS_OK
MSP430_Close = MSP430mspgcc.MSP430_Close
MSP430_Close.argtypes = [ctypes.c_long]
MSP430_Close.restype = ctypes.c_int
@@ -81,24 +88,28 @@
MSP430_Memory = MSP430mspgcc.MSP430_Memory
MSP430_Memory.argtypes = [ctypes.c_long, ctypes.POINTER(ctypes.c_char), ctypes.c_long, ctypes.c_long]
MSP430_Memory.restype = ctypes.c_int
- MSP430_ReadRegister = MSP430mspgcc.MSP430_ReadRegister
- MSP430_ReadRegister.argtypes = [ctypes.c_long, ctypes.POINTER(ctypes.c_long)]
- MSP430_ReadRegister.restype = ctypes.c_int
- MSP430_WriteRegister = MSP430mspgcc.MSP430_WriteRegister
- MSP430_WriteRegister.argtypes = [ctypes.c_long, ctypes.c_long]
- MSP430_WriteRegister.restype = ctypes.c_int
MSP430_VerifyMem = MSP430mspgcc.MSP430_VerifyMem
MSP430_VerifyMem.argtypes = [ctypes.c_long, ctypes.c_long, ctypes.c_char_p]
MSP430_VerifyMem.restype = ctypes.c_int
MSP430_EraseCheck = MSP430mspgcc.MSP430_EraseCheck
MSP430_EraseCheck.argtypes = ctypes.c_long, ctypes.c_long
MSP430_EraseCheck.restype = ctypes.c_int
+ try:
+ MSP430_ReadRegister = MSP430mspgcc.MSP430_ReadRegister
+ MSP430_ReadRegister.argtypes = [ctypes.c_long, ctypes.POINTER(ctypes.c_long)]
+ MSP430_ReadRegister.restype = ctypes.c_int
+ MSP430_WriteRegister = MSP430mspgcc.MSP430_WriteRegister
+ MSP430_WriteRegister.argtypes = [ctypes.c_long, ctypes.c_long]
+ MSP430_WriteRegister.restype = ctypes.c_int
MSP430_Funclet = MSP430mspgcc.MSP430_Funclet
MSP430_Funclet.argtypes = [ctypes.c_char_p, ctypes.c_long, ctypes.c_int, ctypes.c_int]
MSP430_Funclet.restype = ctypes.c_int
MSP430_isHalted = MSP430mspgcc.MSP430_isHalted
MSP430_isHalted.argtypes = []
MSP430_isHalted.restype = ctypes.c_int
+ except AttributeError:
+ #TI's USB-FET lib does not have this function
+ pass
messagecallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_short, ctypes.c_short) #void f(WORD count, WORD total)
@@ -260,6 +271,7 @@
def __init__(self):
self.showprogess = 0
self.data = None
+ self.verbose = 1
# ---------- direct use API ---------------
@@ -292,6 +304,7 @@
def reset(self, execute=0, release=0):
"""perform a reset and optionaly release device."""
+ if self.verbose:
sys.stderr.write("Reset %sdevice...\n" % (release and 'and release ' or ''))
sys.stderr.flush()
_parjtag.reset(execute, release)
@@ -300,11 +313,13 @@
def actionMassErase(self):
"""Erase the flash memory completely (with mass erase command)."""
+ if self.verbose:
sys.stderr.write("Mass Erase...\n")
_parjtag.memerase(ERASE_ALL)
def actionMainErase(self):
"""Erase the MAIN flash memory, leave the INFO mem"""
+ if self.verbose:
sys.stderr.write("Erase Main Flash...\n")
sys.stderr.flush()
_parjtag.memerase(ERASE_MAIN, 0xfffe)
@@ -316,6 +331,7 @@
def __init__(self, segaddr):
self.address = segaddr
def __call__(self):
+ if self.verbose:
sys.stderr.write("Erase Segment @ 0x%04x...\n" % self.address)
sys.stderr.flush()
_parjtag.memerase(ERASE_SEGMENT, self.address)
@@ -341,6 +357,7 @@
def actionProgram(self):
"""Program data into flash memory."""
if self.data is not None:
+ if self.verbose:
sys.stderr.write("Program...\n")
sys.stderr.flush()
if self.showprogess:
@@ -349,6 +366,7 @@
for seg in self.data:
_parjtag.memwrite(seg.startaddress, seg.data)
bytes += len(seg.data)
+ if self.verbose:
sys.stderr.write("%i bytes programmed.\n" % bytes)
sys.stderr.flush()
else:
@@ -373,11 +391,13 @@
def actionFunclet(self):
"""Download and start funclet"""
if self.data is not None:
+ if self.verbose:
sys.stderr.write("Download and execute funclet...\n")
sys.stderr.flush()
if len(self.data) != 1:
raise JTAGException("Funclets must have exactly one segment")
_parjtag.funclet(self.data[0].data)
+ if self.verbose:
sys.stderr.write("Funclet OK.\n")
sys.stderr.flush()
else:
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20