only flush once for a sequence, detect 0xffs seqs
[pyfrprog.git] / frprog.py
index f6a741846fe4bcd2798e1225edae2a4abd61eca2..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)
@@ -118,6 +117,7 @@ class FlashSequence(object):
                self.address = address
                self.data = data
 
+# list of all our address/data pairs to flash
 flashseqs = []
 
 # check command line arguments
@@ -164,6 +164,7 @@ print "The following flash sequences have been read in:"
 for seq in flashseqs:
        print hex(seq.address) + ":", seq.data
 
+
 print "Initializing serial port..."
 tty = SerialPort(DEVICE, 100, INIT_BAUDRATE)
 
@@ -184,7 +185,21 @@ print "OK, trying to set baudrate..."
 cmdBAUDRATE(REAL_BAUDRATE)
 tty = SerialPort(DEVICE, 100, REAL_BAUDRATE)
 
+# let the fun begin!
+for seq in flashseqs:
+       if(seq.address <= 0x40000):
+               addr = seq.address
+       else:
+               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)
+
 
+# some tests here.......
 """
 # execute (existing) program in ram
 cmdCALL(0x00033ffc)
@@ -262,7 +277,7 @@ print "Received Checksum:", last_checksum
 print
 """
 
-
+"""
 # write some data in the iram and try to execute it
 data_wr =[
                0x9B,0x00,
@@ -286,3 +301,4 @@ cmdWRITE(0x00030000, len(data_wr), data_wr)
 print "Received Checksum:", last_checksum
 print
 cmdCALL(0x00030000)
+"""