working toward glitching.
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@245
12e2690d-a6be-4b82-a7b7-
67c4a43b65c8
#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;
self.CCstop();
print "Done.";
self.CCstop();
print "Done.";
"""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);
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];
str="%s %s" %(self.CCstatusbits[i],str);
i*=2;
return str;
str="%s %s" %(self.CCstatusbits[i],str);
i*=2;
return str;
"""Start debugging."""
self.writecmd(0x30,0x20,0,self.data);
ident=self.CCidentstr();
"""Start debugging."""
self.writecmd(0x30,0x20,0,self.data);
ident=self.CCidentstr();
self.CChaltcpu();
#print "Status: %s." % self.CCstatusstr();
self.CChaltcpu();
#print "Status: %s." % self.CCstatusstr();
"""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):
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();
print "Poking %04x to become %02x." % (start,val);
client.CCpokedatabyte(start,val);
print "Poking %04x to become %02x." % (start,val);
client.CCpokedatabyte(start,val);
}
//! 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);
}
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.");
txdata(app,verb,0);
break;
case START://enter debugger
txdata(app,verb,0);
break;
case START://enter debugger
ccdebuginit();
txdata(app,verb,0);
break;
ccdebuginit();
txdata(app,verb,0);
break;
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
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;
unsigned char verb,\r
unsigned long len){\r
//debugstr("GoodFET");\r
unsigned char verb,\r
unsigned long len){\r
//debugstr("GoodFET");\r
switch(app){\r
case GLITCH:\r
glitchhandle(app,verb,len);\r
switch(app){\r
case GLITCH:\r
glitchhandle(app,verb,len);\r