only flush once for a sequence, detect 0xffs seqs
authortheStack <sebastian.falbesoner@gmail.com>
Mon, 14 Dec 2009 12:07:47 +0000 (13:07 +0100)
committertheStack <sebastian.falbesoner@gmail.com>
Mon, 14 Dec 2009 12:07:47 +0000 (13:07 +0100)
frprog.py
kernel.py

index b7371c1cfa226c6d2b14877d936a7fa32a3438fe..da4f399dcdbdc179a4d63b50f984e77bd0962768 100755 (executable)
--- a/frprog.py
+++ b/frprog.py
@@ -15,7 +15,6 @@ last_checksum = 0
 def sendByte(byte):
        time.sleep(0.001) # just to get sure, wait 1ms
        tty.write(chr(byte))
-       tty.flush()
 
 def sendWord(word):
        sendByte(word & 0xFF)
@@ -194,6 +193,7 @@ for seq in flashseqs:
                continue
        print "RAMing", len(seq.data), "bytes at address", hex(addr)
        cmdWRITE(addr, len(seq.data), seq.data)
+       tty.flush()
 
 cmdCALL(0x30000);
 sys.exit(0)
index 159a570d08e5936d4fc25b9e627d7fb2e796a5a8..f1ce9d406dc001055bb9bb8bffd8ab756a55e0e7 100755 (executable)
--- a/kernel.py
+++ b/kernel.py
@@ -12,7 +12,6 @@ def recvByte():
        return ord(i)
 
 def sendByte(byte):
-       time.sleep(0.005) # just to get sure, wait 5ms
        tty.write(chr(byte))
        tty.flush()
 
@@ -33,7 +32,6 @@ def pkernCHIPERASE():
        print "wait..."
        if (recvByte() != 0x23):
                raise Exception
-       print "Chip erasing done."
 
 def pkernERASE(address, size):
        sendByte(0x12)
@@ -43,11 +41,10 @@ def pkernERASE(address, size):
        sendWord(size)
        if (recvByte() != 0x18):
                raise Exception
-       print "Erasing done."
+       #print "Erasing done."
 
 
 def pkernWRITE(address, size, data):
-       print "address:", hex(address), "size:", size
        # send WRITE command
        sendByte(0x13)
        if (recvByte() != 0x37):
@@ -62,7 +59,7 @@ def pkernWRITE(address, size, data):
 
        if (recvByte() != 0x28):
                raise Exception
-       print "Flashing done."
+       #print "Flashing done."
 
 
 class FlashSequence(object):
@@ -117,9 +114,9 @@ for line in fp:
                # add flash sequence to our list
                flashseqs.append(FlashSequence(address, data))
 
-print "The following flash sequences have been read in:"
-for seq in flashseqs:
-       print hex(seq.address) + ":", [hex(x) for x in seq.data]
+#print "The following flash sequences have been read in:"
+#for seq in flashseqs:
+#      print hex(seq.address) + ":", [hex(x) for x in seq.data]
 
 
 # let the fun begin!
@@ -130,11 +127,20 @@ for seq in flashseqs:
 """
 print "ChipErase..."
 pkernCHIPERASE()
+print "Chip erasing done."
 
 
+print "Flashing",
 for seq in flashseqs:
-       print "Flashing", len(seq.data), "bytes at address", hex(seq.address)
+       sys.stdout.write(".")
+       sys.stdout.flush()
+       # skip seqs only consisting of 0xffs
+       seqset = list(set(seq.data))
+       if len(seqset) == 1 and seqset[0] == 0xff:
+               continue
+       #print "Flashing", len(seq.data), "bytes at address", hex(seq.address)
        pkernWRITE(seq.address, len(seq.data), seq.data)
+print
 
 """
 sendByte(0x99) #exit and wait