Reading seems to work on MSP430X2, but some regions seem to be unpopulated.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Fri, 4 Sep 2009 09:49:57 +0000 (09:49 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Fri, 4 Sep 2009 09:49:57 +0000 (09:49 +0000)
Need to extend messaging protocol for 20 bit addresses.

git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@123 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETMSP430.py
client/goodfet.msp430
firmware/apps/jtag/jtag430.c
firmware/apps/jtag/jtag430x2.c

index 22b7ee8..83154c0 100644 (file)
@@ -41,10 +41,10 @@ class GoodFETMSP430(GoodFET):
         self.writecmd(self.MSP430APP,0x02,2,self.data);
         return ord(self.data[0])+(ord(self.data[1])<<8);
     def MSP430poke(self,adr,val):
         self.writecmd(self.MSP430APP,0x02,2,self.data);
         return ord(self.data[0])+(ord(self.data[1])<<8);
     def MSP430poke(self,adr,val):
-        """Read the contents of memory at an address."""
+        """Write the contents of memory at an address."""
         self.data=[adr&0xff, (adr&0xff00)>>8, val&0xff, (val&0xff00)>>8];
         self.writecmd(self.MSP430APP,0x03,4,self.data);
         self.data=[adr&0xff, (adr&0xff00)>>8, val&0xff, (val&0xff00)>>8];
         self.writecmd(self.MSP430APP,0x03,4,self.data);
-        return;# ord(self.data[0])+(ord(self.data[1])<<8);
+        return ord(self.data[0])+(ord(self.data[1])<<8);
     def MSP430start(self):
         """Start debugging."""
         self.writecmd(self.MSP430APP,0x20,0,self.data);
     def MSP430start(self):
         """Start debugging."""
         self.writecmd(self.MSP430APP,0x20,0,self.data);
index b1a129c..368cb0f 100755 (executable)
@@ -103,6 +103,19 @@ if(sys.argv[1]=="peek"):
     while start<=stop:
         print "%04x: %04x" % (start,client.MSP430peek(start));
         start=start+2;
     while start<=stop:
         print "%04x: %04x" % (start,client.MSP430peek(start));
         start=start+2;
+if(sys.argv[1]=="poke"):
+    start=0x0000;
+    val=0x00;
+    if(len(sys.argv)>2):
+        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);
+    
+    while client.MSP430peek(start)!=val:
+        client.MSP430poke(start,val);
+        print "Poked to %04x" % client.MSP430peek(start);
+
 
 
 if(sys.argv[1]=="whatever"):
 
 
 if(sys.argv[1]=="whatever"):
index 52601d8..65d4e31 100644 (file)
@@ -82,7 +82,6 @@ void jtag430_writemem(unsigned int adr, unsigned int data){
   SETTCLK;
 }
 
   SETTCLK;
 }
 
-
 //! Write data to flash memory.  Must be preconfigured.
 void jtag430_writeflashword(unsigned int adr, unsigned int data){
   /*
 //! Write data to flash memory.  Must be preconfigured.
 void jtag430_writeflashword(unsigned int adr, unsigned int data){
   /*
index e496346..44d4941 100644 (file)
@@ -57,6 +57,38 @@ unsigned long jtag430_deviceid(){
 }
 
 
 }
 
 
+//! Write data to address
+unsigned int jtag430x2_writemem(unsigned long adr,
+                               unsigned long data){
+  jtag_ir_shift8(IR_CNTRL_SIG_CAPTURE);
+  if(jtag_ir_shift8(0) & 0x0301){
+    CLRTCLK;
+    jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
+    if(adr>=0x100)
+      jtag_ir_shift8(0x0500);//word mode
+    else
+      jtag_ir_shift8(0x0510);//byte mode
+    jtag_ir_shift8(IR_ADDR_16BIT);
+    jtag_dr_shift20(adr);
+    
+    SETTCLK;
+    
+    jtag_ir_shift8(IR_DATA_TO_ADDR);
+    jtag_ir_shift8(data);//16 word
+
+    CLRTCLK;
+    jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
+    jtag_ir_shift8(0x0501);
+    SETTCLK;
+
+    CLRTCLK;
+    SETTCLK;
+    //init state
+  }else{
+    while(1) P1OUT^=1; //loop if locked up
+  }
+}
+
 //! Read data from address
 unsigned int jtag430x2_readmem(unsigned long adr){
   unsigned int toret=0;
 //! Read data from address
 unsigned int jtag430x2_readmem(unsigned long adr){
   unsigned int toret=0;
@@ -72,7 +104,7 @@ unsigned int jtag430x2_readmem(unsigned long adr){
       jtag_dr_shift16(0x0511);//byte read
     }
     jtag_ir_shift8(IR_ADDR_16BIT);
       jtag_dr_shift16(0x0511);//byte read
     }
     jtag_ir_shift8(IR_ADDR_16BIT);
-    jtag_dr_shift20(adr);
+    jtag_dr_shift20(adr); //20
 
     jtag_ir_shift8(IR_DATA_TO_ADDR);
     SETTCLK;
 
     jtag_ir_shift8(IR_DATA_TO_ADDR);
     SETTCLK;
@@ -85,9 +117,9 @@ unsigned int jtag430x2_readmem(unsigned long adr){
     CLRTCLK;
     SETTCLK;
     // Processor is now again in Init State
     CLRTCLK;
     SETTCLK;
     // Processor is now again in Init State
+  }else{
+    return 0xDEAD;
   }
   }
-
-
   
   return toret;
 }
   
   return toret;
 }
@@ -97,7 +129,7 @@ unsigned int jtag430x2_readmem(unsigned long adr){
 void jtag430x2handle(unsigned char app,
                   unsigned char verb,
                   unsigned char len){
 void jtag430x2handle(unsigned char app,
                   unsigned char verb,
                   unsigned char len){
-  
+  jtag430_resettap();
   switch(verb){
   case START:
     //Enter JTAG mode.
   switch(verb){
   case START:
     //Enter JTAG mode.
@@ -139,6 +171,11 @@ void jtag430x2handle(unsigned char app,
   case JTAG430_SETINSTRFETCH:
   case JTAG430_WRITEMEM:
   case POKE:
   case JTAG430_SETINSTRFETCH:
   case JTAG430_WRITEMEM:
   case POKE:
+    jtag430x2_writemem(cmddataword[0],
+                      cmddataword[1]);
+    cmddataword[0]=jtag430x2_readmem(cmddataword[0]);
+    txdata(app,verb,2);
+    break;
   case JTAG430_WRITEFLASH:
   case JTAG430_ERASEFLASH:
   case JTAG430_SETPC:
   case JTAG430_WRITEFLASH:
   case JTAG430_ERASEFLASH:
   case JTAG430_SETPC: