#
# This code is being rewritten and refactored. You've been warned!
-import sys, time, string, cStringIO, struct, glob, serial, os, random;
+import sys, time, string, cStringIO, struct, glob, os, random;
import sqlite3;
from GoodFET import *;
trials=30;
lock=0; #1 locks, 0 unlocked
vstart=0;
- vstop=200; #Could be as high as 0xFFF, but upper range is useless
+ vstop=1024; #Could be as high as 0xFFF, but upper range is useless
vstep=1;
tstart=0;
tstop=self.client.glitchstarttime();
tstep=0x1; #Must be 1
self.scan(lock,trials,range(vstart,vstop),range(tstart,tstop));
- print "Learning phase complete, beginning to crunch.";
+ print "Learning phase complete, begin to crunch.";
self.crunch();
- print "Crunch phase complete, beginning to explore.";
- self.explore();
+ #print "Crunch phase complete, beginning to explore.";
+ #self.explore();
def scansetup(self,lock):
client=self.client;
client.erase();
print "Scanning %s" % client.infostring();
- self.secret=0x49;
+ #Kind of arbitrary.
+ #16 bit minimum.
+ self.secret=0xdead;
+
+
+ print "-- Setting secret";
+ client.start();
+
+ #Flash the secret, to try and recover it later.
+ client.erase();
+ print "-- Secret was %02x" % client.getsecret();
+ client.setsecret(self.secret);
+ print "-- Secret set to %02x" % client.getsecret();
+ sys.stdout.flush()
+ if(client.getsecret()!=self.secret):
+ print "Secret failed to set. Exiting for safety.";
+ sys.exit();
- while(client.getsecret()!=self.secret):
- print "-- Setting secret";
- client.start();
-
- #Flash the secret to the first two bytes of CODE memory.
- client.erase();
- print "-- Secret was %02x" % client.getsecret();
- client.setsecret(self.secret);
- sys.stdout.flush()
-
#Lock chip to unlock it later.
if lock>0:
client.lock();