cleaned up cmdBAUDRATE
[pyfrprog.git] / frprog.py
index cc250050eebeb2af08cab80ad151c12712badda8..e14eb94ba8aab2fc7ef3afeea7a3735adb51060f 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)
@@ -98,8 +97,6 @@ def cmdCHECKSUM():
        recvChecksum()
 
 def cmdBAUDRATE(baudrate):
-       global last_checksum
-
        # send BAUDRATE command
        sendByte(0x01)
        if (recvByte() != 0xF1):
@@ -108,10 +105,7 @@ def cmdBAUDRATE(baudrate):
        if (recvByte() != 0x86):
                raise Exception
        # send desired baudrate
-       sendByte(baudrate & 0xFF)
-       sendByte((baudrate >> 8) & 0xFF)
-       sendByte((baudrate >> 16) & 0xFF)
-       sendByte((baudrate >> 24) & 0xFF)
+       sendDWord(baudrate)
 
 class FlashSequence(object):
        def __init__(self, address, data):
@@ -188,8 +182,15 @@ tty = SerialPort(DEVICE, 100, REAL_BAUDRATE)
 
 # let the fun begin!
 for seq in flashseqs:
-       print "Flashing", len(seq.data), "bytes at address", hex(seq.address)
-       cmdWRITE(seq.address, len(seq.data), seq.data)
+       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)
 
 
@@ -271,7 +272,7 @@ print "Received Checksum:", last_checksum
 print
 """
 
-
+"""
 # write some data in the iram and try to execute it
 data_wr =[
                0x9B,0x00,
@@ -295,3 +296,4 @@ cmdWRITE(0x00030000, len(data_wr), data_wr)
 print "Received Checksum:", last_checksum
 print
 cmdCALL(0x00030000)
+"""