def getClient(name="GoodFET"):
import GoodFET, GoodFETCC, GoodFETAVR, GoodFETSPI, GoodFETMSP430, GoodFETNRF;
if(name=="GoodFET" or name=="monitor"): return GoodFET.GoodFET();
- elif name=="cc" or name=="chipcon": return GoodFETCC.GoodFETCC();
+ elif name=="cc" or name=="cc51": return GoodFETCC.GoodFETCC();
+ elif name=="cc2420" or name=="ccspi": return GoodFETCC.GoodFETCC();
elif name=="avr": return GoodFETAVR.GoodFETAVR();
elif name=="spi": return GoodFETSPI.GoodFETSPI();
elif name=="msp430": return GoodFETMSP430.GoodFETMSP430();
return self.data;
except TypeError:
if self.connected:
- print "Error: waiting for serial read timed out (most likely).";
- print "This shouldn't happen after syncing. Exiting for safety.";
- sys.exit(-1)
+ print "Warning: waiting for serial read timed out (most likely).";
+ #print "This shouldn't happen after syncing. Exiting for safety.";
+ #sys.exit(-1)
return self.data;
#Glitching stuff.
def glitchApp(self,app):
"""Time the execution of a verb."""
if data==None: data=[];
self.data=[app&0xff, verb&0xFF]+data;
+ print "Timing app %02x verb %02x." % (app,verb);
self.writecmd(self.GLITCHAPP,0x82,len(self.data),self.data);
- return ord(self.data[0])+(ord(self.data[1])<<8);
+ time=ord(self.data[0])+(ord(self.data[1])<<8);
+ print "Timed to be %i." % time;
+ return time;
def glitchVoltages(self,low=0x0880, high=0x0fff):
"""Set glitching voltages. (0x0fff is max.)"""
self.data=[low&0xff, (low>>8)&0xff,
def peek(self,address):
"""Read a word of memory from the monitor."""
return self.peekbyte(address)+(self.peekbyte(address+1)<<8);
+ def eeprompeek(self,address):
+ """Read a word of memory from the monitor."""
+ return self.peekbyte(address)+(self.peekbyte(address+1)<<8);
+
def pokebyte(self,address,value):
"""Set a byte of memory by the monitor."""
self.data=[address&0xff,address>>8,value];
self.writecmd(0,0x03,3,self.data);
return ord(self.data[0]);
+ def poke16(self,address,value):
+ """Set a word of memory by the monitor."""
+ self.pokebyte(address,value&0xFF);
+ self.pokebyte(address,(value>>8)&0xFF);
+ return value;
+ def setsecret(self,value):
+ """Set a secret word for later retreival. Used by glitcher."""
+ self.eeprompoke(0,value);
+ self.eeprompoke(1,value);
+ def getsecret(self):
+ """Get a secret word. Used by glitcher."""
+ self.eeprompeek(0);
+
def dumpmem(self,begin,end):
i=begin;
while i<end:
return 0;
return 1;
def monitorclocking(self):
- DCOCTL=self.peekbyte(0x0056);
- BCSCTL1=self.peekbyte(0x0057);
- return "0x%02x, 0x%02x" % (DCOCTL, BCSCTL1);
-
+ """Return the 16-bit clocking value."""
+ return "0x%04x" % self.monitorgetclock();
+
+ def monitorsetclock(self,clock):
+ """Set the clocking value."""
+ self.poke16(0x56, clock);
+ def monitorgetclock(self):
+ """Get the clocking value."""
+ return self.peek16(0x56);
# The following functions ought to be implemented in
# every client.