X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=c3ab99e6d8a5b3a662e5ab6e0c99ef8dc07c0f1d;hp=7e327730a0d3f6f25144428712d62f1f1a6ab477;hb=d37fc4cb79d9361dbc70bab5f5ae0306dbbb2254;hpb=08d4b0b5273fa05983e1564d1aac464c56b70200 diff --git a/client/GoodFET.py b/client/GoodFET.py index 7e32773..c3ab99e 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -13,7 +13,8 @@ fmt = ("B", ">16)&0xFF]); print "Got %02x%02x buffer size." % (self.data[1],self.data[0]); @@ -195,6 +277,10 @@ class GoodFET: print "# DEBUG %s" % self.serialport.read(self.count) elif self.verb==0xFE: print "# DEBUG 0x%x" % struct.unpack(fmt[self.count-1], self.serialport.read(self.count))[0] + elif self.verb==0xFD: + #Do nothing, just wait so there's no timeout. + print "# NOP."; + sys.stdout.flush(); else: self.data=self.serialport.read(self.count); @@ -202,7 +288,7 @@ class GoodFET: 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."; + print "This shouldn't happen after syncing. Exiting for safety."; sys.exit(-1) return self.data; #Glitching stuff. @@ -227,8 +313,11 @@ class GoodFET: """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, @@ -277,11 +366,26 @@ class GoodFET: def peekword(self,address): """Read a word of memory from the monitor.""" return self.peekbyte(address)+(self.peekbyte(address+1)<<8); + 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 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