val&0xff, (val&0xff00)>>8];
self.writecmd(self.MSP430APP,0x03,6,self.data);
return ord(self.data[0])+(ord(self.data[1])<<8);
+ def MSP430pokeflash(self,adr,val):
+ """Write the contents of flash memory at an address."""
+ self.data=[adr&0xff, (adr&0xff00)>>8,
+ (adr&0xff0000)>>16,(adr&0xff000000)>>24,
+ val&0xff, (val&0xff00)>>8];
+ self.writecmd(self.MSP430APP,0xE1,6,self.data);
+ return ord(self.data[0])+(ord(self.data[1])<<8);
+
def MSP430start(self):
"""Start debugging."""
self.writecmd(self.MSP430APP,0x20,0,self.data);
#print "started"
if(sys.argv[1]=="info"):
- print "Model %08x " % client.MSP430deviceid();
- print "Core %04x " % client.MSP430coreid();
- print "Identity %04x" % client.MSP430ident();
- print "Identifies as %s" % client.MSP430identstr();
+ #print "Model %08x " % client.MSP430deviceid();
+ #print "Core %04x " % client.MSP430coreid();
+ #print "Identity %04x" % client.MSP430ident();
+ print "Identifies as %s (%04x)" % (
+ client.MSP430identstr(),
+ client.MSP430ident());
if(sys.argv[1]=="test"):
client.MSP430test();
if(sys.argv[1]=="dump"):
start=int(sys.argv[2],16);
if(len(sys.argv)>3):
val=int(sys.argv[3],16);
- print "Poking %06x to become %02x." % (start,val);
+ print "Poking %06x to become %04x." % (start,val);
while client.MSP430peek(start)!=val:
- client.MSP430poke(start,val);
+ client.MSP430pokeflash(start,val);
print "Poked to %04x" % client.MSP430peek(start);
//! Write data to flash memory. Must be preconfigured.
void jtag430_writeflashword(unsigned int adr, unsigned int data){
- /*
+
CLRTCLK;
jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
jtag_dr_shift16(0x2408);//word write
CLRTCLK;
jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
jtag_dr_shift16(0x2409);
- */
+ /*
jtag430_writemem(adr,data);
CLRTCLK;
jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
jtag_dr_shift16(0x2409);
+ */
//Pulse TCLK
jtag430_tclk_flashpulses(35); //35 standard
//FCTL2=0xA540, selecting MCLK as source, DIV=1
jtag430_writemem(0x012A, 0xA540);
//FCTL3=0xA500, should be 0xA540 for Info Seg A on 2xx chips.
- jtag430_writemem(0x012C, 0xA500);
+ jtag430_writemem(0x012C, 0xA500); //all but info flash.
//Write the word itself.
jtag430_writeflashword(adr,data);
//! Handles classic MSP430 JTAG commands. Forwards others to JTAG.
-void oldjtag430handle(unsigned char app,
+void jtag430handle(unsigned char app,
unsigned char verb,
unsigned char len){
register char blocks;
break;
case JTAG430_WRITEMEM:
case POKE:
- jtag430_writemem(cmddatalong[0],cmddataword[2]);
- cmddataword[0]=jtag430_readmem(cmddatalong[0]);
+ jtag430_writemem(cmddataword[0],cmddataword[2]);
+ cmddataword[0]=jtag430_readmem(cmddataword[0]);
txdata(app,verb,2);
break;
case JTAG430_WRITEFLASH:
- jtag430_writeflash(cmddataword[0],cmddataword[1]);
+ debugstr("Poking flash memory.");
+ jtag430_writeflash(cmddataword[0],cmddataword[2]);
cmddataword[0]=jtag430_readmem(cmddataword[0]);
txdata(app,verb,2);
break;
}
jtag430_resettap();
}
-
-//! Handles unique MSP430 JTAG commands. Forwards others to JTAG.
-void jtag430handle(unsigned char app,
- unsigned char verb,
- unsigned char len){
- switch(jtag430mode){
- case MSP430MODE:
- return oldjtag430handle(app,verb,len);
- case MSP430X2MODE:
- return jtag430x2handle(app,verb,len);
- default:
- txdata(app,NOK,0);
- }
-}