print "Some success, some failures. Is a wire loose?";
else:
print "All reads succeeded. Wiring is probably good.";
-
+ print "Erasing.";
+ client.SPIchiperase();
+ print "Testing erase.";
+ data=client.SPIpeekblock(0);
+ for i in data:
+ if ord(i)!=0xFF:
+ print "ERROR not properly erased!";
+ data=range(0,10);
+ client.SPIpokebytes(0,data);
+ print "Testing flash write.";
+ for i in data:
+ if(client.SPIpeek(i)!=i):
+ print "%06x not properly poked to %02x" % (i,i);
+ print "Test complete.";
if(sys.argv[1]=="info"):
data=client.SPIjedec();
print "Ident as %s\nManufacturer: %02x %s\nType: %02x\nCapacity: %02x (%i bytes)" % (
i=start;
while i<=stop:
- data=client.SPIpeekblock(i,255);
+ data=client.SPIpeekblock(i);
#if(i%0x1000==0):
print "Dumped %06x."%i;
for j in data:
file = open(f, mode='rb')
i=start;
- bits=0;
+ bytes=0;
while i<=stop:
- data=client.SPIpeekblock(i,255);
+ data=client.SPIpeekblock(i);
print "Verified %06x." % i;
for j in data:
if i<stop:
- bits|=ord(file.read(1))^ord(j);
+ #bits|=ord(file.read(1))^ord(j);
+ a=ord(file.read(1));
+ b=ord(j);
+ if a!=b:
+ print "%06x: %02x/%02x" % (i,a,b);
+ bytes+=1;
i+=1;
- if bits!=0:
- print "Bits don't match."
+ if bytes!=0:
+ print "%i bytes don't match." % bytes
file.close()
stop=int(sys.argv[4],16);
print "Flashing code from %06x to %06x with %s." % (start,stop,f);
+ print "FIXME This might fail if the file is of an odd size.";
file = open(f, mode='rb')
i=start;
chars=list(file.read());
+ chunksize=0x100;
- #N.B., chunksize must be an even fraction of 0x100.
- chunksize=0x80;
-
- #client.silent(1);
while i<=stop:
bytes=range(0,chunksize);
for j in range(0,chunksize):
i+=chunksize;
if(i%0x1000==0):
print "Flashed %06x."%i;
- print "Done, ending silence.";
- #client.silent(0);
+
+
file.close()