Bytes on page boundaries were corrupted.
[goodfet] / client / goodfet.cc
index 3f2860d..19a0b13 100755 (executable)
@@ -33,9 +33,20 @@ client=GoodFETCC();
 client.serInit()
 
 #Connect to target
-client.CCsetup();
-client.CCstart();
+client.setup();
+client.start();
 
+if(sys.argv[1]=="explore"):
+    print "Exploring undefined commands."
+    print "Status: %s" %client.CCstatusstr();
+    
+    cmd=0x04; #read status
+    for foo in range(0,0x5):
+        client.CCcmd([(0x0F<<3)|(0x00)|0x03,0x09<<3]);
+        print "Status %02x: %s" % (foo,client.CCstatusstr());
+    for foo in range(0,3):
+        print "PC: %04x" % client.CCgetPC();
+        
 if(sys.argv[1]=="test"):
     client.CCtest();
 if(sys.argv[1]=="deadtest"):
@@ -135,16 +146,14 @@ if(sys.argv[1]=="flash"):
    
      h = IntelHex(f);
      page = 0x0000;
-     pagelen = 2048; #2kB pages in 32-bit words
+     pagelen = client.CCpagesize(); #2048; #2kB pages in 32-bit words
+     
      bcount = 0;
      
-     print "Wiping Flash."
-     #Wipe all of flash.
-     #client.CCchiperase();
      #Wipe the RAM buffer for the next flash page.
-     #client.CCeraseflashbuffer();
+     client.CCeraseflashbuffer();
      for i in h._buf.keys():
-         while(i>page+pagelen):
+         while(i>=page+pagelen):
              if bcount>0:
                  client.CCflashpage(page);
                  #client.CCeraseflashbuffer();
@@ -216,7 +225,23 @@ if(sys.argv[1]=="peek"):
     while start<=stop:
         print "%04x: %02x" % (start,client.CCpeekirambyte(start));
         start=start+1;
-
+if(sys.argv[1]=="verify"):
+    f=sys.argv[2];
+    start=0;
+    stop=0xFFFF;
+    if(len(sys.argv)>3):
+        start=int(sys.argv[3],16);
+    if(len(sys.argv)>4):
+        stop=int(sys.argv[4],16);
+    
+    h = IntelHex(f);
+    for i in h._buf.keys():
+        if(i>=start and i<stop):
+            peek=client.CCpeekcodebyte(i)
+            if(h[i]!=peek):
+                print "ERROR at %04x, found %02x not %02x"%(i,peek,h[i]);
+            if(i%0x100==0):
+                print "%04x" % i;
 if(sys.argv[1]=="peekcode"):
     start=0x0000;
     if(len(sys.argv)>2):
@@ -238,4 +263,4 @@ if(sys.argv[1]=="pokedata"):
     print "Poking %04x to become %02x." % (start,val);
     client.CCpokedatabyte(start,val);
 
-client.CCstop();
+client.stop();