Quantitative tests of AVR power stability,
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Tue, 1 Dec 2009 07:48:10 +0000 (07:48 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Tue, 1 Dec 2009 07:48:10 +0000 (07:48 +0000)
working toward glitching.

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

client/GoodFET.py
client/GoodFETCC.py
client/goodfet.cc
firmware/apps/avr/avr.c
firmware/apps/chipcon/chipcon.c
firmware/apps/glitch/glitch.c
firmware/goodfet.c

index 63e38e9..cfc2079 100755 (executable)
@@ -103,7 +103,7 @@ class GoodFET:
             
             #Debugging string; print, but wait.
             if self.app==0xFF and self.verb==0xFF:
             
             #Debugging string; print, but wait.
             if self.app==0xFF and self.verb==0xFF:
-                print "DEBUG %s" % self.serialport.read(self.count);
+                print "DEBUG %s" % self.serialport.read(self.count);
             else:
                 self.data=self.serialport.read(self.count);
                 return self.data;
             else:
                 self.data=self.serialport.read(self.count);
                 return self.data;
index e2f28e6..3f4d1d9 100644 (file)
@@ -53,7 +53,7 @@ class GoodFETCC(GoodFET):
         self.CCstop();
         print "Done.";
 
         self.CCstop();
         print "Done.";
 
-    def CCsetup(self):
+    def setup(self):
         """Move the FET into the CC2430/CC2530 application."""
         #print "Initializing Chipcon.";
         self.writecmd(0x30,0x10,0,self.data);
         """Move the FET into the CC2430/CC2530 application."""
         #print "Initializing Chipcon.";
         self.writecmd(0x30,0x10,0,self.data);
@@ -111,6 +111,13 @@ class GoodFETCC(GoodFET):
         self.data=[adr&0xff];
         self.writecmd(0x30,0x02, 1, self.data);
         return ord(self.data[0]);
         self.data=[adr&0xff];
         self.writecmd(0x30,0x02, 1, self.data);
         return ord(self.data[0]);
+    def CCpeekiramword(self,adr):
+        """Read the little-endian contents of IRAM at an address."""
+        return self.CCpeekirambyte(adr)+(
+            self.CCpeekirambyte(adr+1)<<8);
+    def CCpokeiramword(self,adr,val):
+        self.CCpokeirambyte(adr,val&0xff);
+        self.CCpokeirambyte(adr+1,(val>>8)&0xff);
     def CCpokeirambyte(self,adr,val):
         """Write the contents of IRAM at an address."""
         self.data=[adr&0xff, val&0xff];
     def CCpokeirambyte(self,adr,val):
         """Write the contents of IRAM at an address."""
         self.data=[adr&0xff, val&0xff];
@@ -156,7 +163,7 @@ class GoodFETCC(GoodFET):
                 str="%s %s" %(self.CCstatusbits[i],str);
             i*=2;
         return str;
                 str="%s %s" %(self.CCstatusbits[i],str);
             i*=2;
         return str;
-    def CCstart(self):
+    def start(self):
         """Start debugging."""
         self.writecmd(0x30,0x20,0,self.data);
         ident=self.CCidentstr();
         """Start debugging."""
         self.writecmd(0x30,0x20,0,self.data);
         ident=self.CCidentstr();
@@ -166,7 +173,7 @@ class GoodFETCC(GoodFET):
         self.CChaltcpu();
         #print "Status: %s." % self.CCstatusstr();
         
         self.CChaltcpu();
         #print "Status: %s." % self.CCstatusstr();
         
-    def CCstop(self):
+    def stop(self):
         """Stop debugging."""
         self.writecmd(0x30,0x21,0,self.data);
     def CCstep_instr(self):
         """Stop debugging."""
         self.writecmd(0x30,0x21,0,self.data);
     def CCstep_instr(self):
index 3f2860d..2905eb5 100755 (executable)
@@ -33,8 +33,8 @@ client=GoodFETCC();
 client.serInit()
 
 #Connect to target
 client.serInit()
 
 #Connect to target
-client.CCsetup();
-client.CCstart();
+client.setup();
+client.start();
 
 if(sys.argv[1]=="test"):
     client.CCtest();
 
 if(sys.argv[1]=="test"):
     client.CCtest();
@@ -238,4 +238,4 @@ if(sys.argv[1]=="pokedata"):
     print "Poking %04x to become %02x." % (start,val);
     client.CCpokedatabyte(start,val);
 
     print "Poking %04x to become %02x." % (start,val);
     client.CCpokedatabyte(start,val);
 
-client.CCstop();
+client.stop();
index a4ba6fd..a127ea2 100644 (file)
@@ -106,7 +106,6 @@ u8 avr_lockbits(){
 }
 //! Write lock bits.
 void avr_setlock(u8 bits){
 }
 //! Write lock bits.
 void avr_setlock(u8 bits){
-  debugstr("Setting lock bits.");
   avrexchange(0xAC,0xE0,0x00,
              bits);
 }
   avrexchange(0xAC,0xE0,0x00,
              bits);
 }
@@ -138,8 +137,10 @@ void avrhandle(unsigned char app,
   unsigned int at;
   static u8 connected=0;
   
   unsigned int at;
   static u8 connected=0;
   
+  /*
   if(!avr_isready() && connected)
     debugstr("AVR is not yet ready.");
   if(!avr_isready() && connected)
     debugstr("AVR is not yet ready.");
+  */
   
   switch(verb){
   case READ:
   
   switch(verb){
   case READ:
index 478e877..135d2a6 100644 (file)
@@ -150,6 +150,7 @@ void cchandle(unsigned char app,
     txdata(app,verb,0);
     break;
   case START://enter debugger
     txdata(app,verb,0);
     break;
   case START://enter debugger
+    ccsetup();
     ccdebuginit();
     txdata(app,verb,0);
     break;
     ccdebuginit();
     txdata(app,verb,0);
     break;
index e125544..e3b226d 100644 (file)
@@ -23,6 +23,13 @@ void glitchsetup(){
   P6OUT|=0x40;
   
   glitchsetupdac();
   P6OUT|=0x40;
   
   glitchsetupdac();
+
+  WDTCTL = WDTPW + WDTHOLD;             // Stop WDT                                                                                                                                
+  TACTL = TASSEL1 + TACLR;              // SMCLK, clear TAR                                                                                                                        
+  CCTL0 = CCIE;                         // CCR0 interrupt enabled                                                                                                                  
+  CCR0 = glitchcount;
+  TACTL |= MC1;                         // Start Timer_A in continuous mode                                                                                                        
+  _EINT();                              // Enable interrupts 
 #endif
 }
 
 #endif
 }
 
@@ -31,14 +38,41 @@ void glitchsetupdac(){
   glitchvoltages(glitchL,glitchH);
 }
 
   glitchvoltages(glitchL,glitchH);
 }
 
+// Timer A0 interrupt service routine                                                                                                                                              
+interrupt(TIMERA0_VECTOR) Timer_A (void)
+{
+  
+  switch(glitchstate){
+  case 0:
+    P1OUT|=1;
+    glitchstate=1;
+    DAC12_0DAT = glitchH;
+    break;
+  case 1:
+    P1OUT|=1;
+    glitchstate=0;
+    DAC12_0DAT = glitchL;
+    break;
+  default:
+    P1OUT&=~1;
+    //Do nothing.
+    break;
+  }
+  CCR0 += glitchcount;                        // Add Offset to CCR0                                                                                                                      
+}
+
+
+
 
 u16 glitchH=0xfff, glitchL=0xfff,
 
 u16 glitchH=0xfff, glitchL=0xfff,
-  glitchstate, glitchcount;
+  glitchstate=2, glitchcount=0;
 
 //! Glitch an application.
 void glitchapp(u8 app){
   debugstr("That app is not yet supported.");
 }
 
 //! Glitch an application.
 void glitchapp(u8 app){
   debugstr("That app is not yet supported.");
 }
+
+
 //! Set glitching voltages.
 void glitchvoltages(u16 low, u16 high){
   int i;
 //! Set glitching voltages.
 void glitchvoltages(u16 low, u16 high){
   int i;
index b08313f..ee97ebb 100644 (file)
@@ -38,6 +38,7 @@ void handle(unsigned char app,
            unsigned char verb,\r
            unsigned long len){\r
   //debugstr("GoodFET");\r
            unsigned char verb,\r
            unsigned long len){\r
   //debugstr("GoodFET");\r
+  P1OUT&=~1;\r
   switch(app){\r
   case GLITCH:\r
     glitchhandle(app,verb,len);\r
   switch(app){\r
   case GLITCH:\r
     glitchhandle(app,verb,len);\r