X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=ef218333005c155af87cb76312e79ffba3475219;hp=d97fb947e96d938fd0c6e4e218135d2f8c0f4de6;hb=5ea4c9f824eed5226b9939b4f28fe1fda9c14dda;hpb=6fa60e61ed4566a368eec48bcca567b5d45310e0 diff --git a/client/GoodFET.py b/client/GoodFET.py index d97fb94..ef21833 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]); @@ -208,9 +288,9 @@ class GoodFET: 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): @@ -234,8 +314,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, @@ -275,27 +358,53 @@ class GoodFET: """Execute supplied code.""" self.writecmd(0,0x31,2,#len(code), code); - def peekbyte(self,address): + def MONpeek8(self,address): """Read a byte of memory from the monitor.""" self.data=[address&0xff,address>>8]; self.writecmd(0,0x02,2,self.data); #self.readcmd(); return ord(self.data[0]); - def peekword(self,address): + def MONpeek16(self,address): """Read a word of memory from the monitor.""" - return self.peekbyte(address)+(self.peekbyte(address+1)<<8); + return self.MONpeek8(address)+(self.MONpeek8(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 pokebyte(self,address,value): + return self.MONpeek8(address)+(self.MONpeek8(address+1)<<8); + def eeprompeek(self,address): + """Read a word of memory from the monitor.""" + return self.MONpeek8(address)+(self.MONpeek8(address+1)<<8); + def peekbysym(self,name): + """Read a value by its symbol name.""" + #TODO include memory in symbol. + reg=self.symbols.get(name); + return self.peek8(reg,"data"); + def pokebysym(self,name,val): + """Write a value by its symbol name.""" + #TODO include memory in symbol. + reg=self.symbols.get(name); + return self.pokebyte(reg,val); + def pokebyte(self,address,value,memory="vn"): """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