Fast MSP430 Flash writes.
[goodfet] / client / goodfet.msp430
index d012728..9fcb68f 100755 (executable)
@@ -77,17 +77,37 @@ if(sys.argv[1]=="flash"):
     
     h = IntelHex16bit(f);
     
+    #Should this be default?
+    #Makes flashing multiple images inconvenient.
     client.MSP430masserase();
+    
+    count=0; #Bytes in commit.
+    first=0;
+    vals=[];
+    last=0;  #Last address committed.
     for i in h._buf.keys():
-        #print "%04x: %04x"%(i,h[i>>1]);
+        if((count>0x40 or last+2!=i) and count>0 and i&1==0):
+            #print "%i, %x, %x" % (len(vals), last, i);
+            client.MSP430pokeflashblock(first,vals);
+            count=0;
+            first=0;
+            last=0;
+            vals=[];
         if(i>=start and i<stop  and i&1==0):
             val=h[i>>1];
-            val2=client.MSP430pokeflash(i,val);
-            if(val!=val2):
-                print "Write error at %04x, %04x!=%04x." %(
-                    i, val, val2);
+            if(count==0):
+                first=i;
+            last=i;
+            count+=2;
+            #val2=client.MSP430pokeflash(i,val);
+            #if(val!=val2):
+            #    print "Write error at %04x, %04x!=%04x." %(
+            #        i, val, val2);
+            vals+=[val&0xff,(val&0xff00)>>8];
             if(i%0x100==0):
                 print "%04x" % i;
+    if count>0: #last commit, ivt
+        client.MSP430pokeflashblock(first,vals);
 if(sys.argv[1]=="verify"):
     f=sys.argv[2];
     start=0;