projects
/
pyfrprog.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add time measurement for performance comparisons
[pyfrprog.git]
/
frprog.py
diff --git
a/frprog.py
b/frprog.py
index 4959ea201a145074df46bf20f67b0c6de35d3e62..b9432a85c2a67f698ced568193561155cb65fb9e 100755
(executable)
--- a/
frprog.py
+++ b/
frprog.py
@@
-13,12
+13,8
@@
KERNEL_BAUDRATE=115200
# contains the last received checksum from a READ, WRITE or CHECKSUM command
last_checksum = 0
# contains the last received checksum from a READ, WRITE or CHECKSUM command
last_checksum = 0
-# is set to True if we are already communicating with the pkernel
-pkernelmode = False
def sendByte(byte):
def sendByte(byte):
- if pkernelmode == False:
- time.sleep(0.001) # just to get sure, wait 1ms
tty.write(chr(byte))
def sendWord(word):
tty.write(chr(byte))
def sendWord(word):
@@
-39,7
+35,7
@@
def recvChecksum():
last_checksum = recvByte()
last_checksum |= (recvByte() << 8)
last_checksum = recvByte()
last_checksum |= (recvByte() << 8)
-def
cmd
READ(address, size):
+def
bootrom
READ(address, size):
# send READ command
sendByte(0x01)
if (recvByte() != 0xF1):
# send READ command
sendByte(0x01)
if (recvByte() != 0xF1):
@@
-58,7
+54,7
@@
def cmdREAD(address, size):
recvChecksum()
return data
recvChecksum()
return data
-def
cmd
WRITE(address, size, data):
+def
bootrom
WRITE(address, size, data):
# send WRITE command
sendByte(0x01)
if (recvByte() != 0xF1):
# send WRITE command
sendByte(0x01)
if (recvByte() != 0xF1):
@@
-76,7
+72,7
@@
def cmdWRITE(address, size, data):
recvChecksum()
# TODO: test this function!
recvChecksum()
# TODO: test this function!
-def
cmd
CALL(address):
+def
bootrom
CALL(address):
# send CALL command
sendByte(0x01)
if (recvByte() != 0xF1):
# send CALL command
sendByte(0x01)
if (recvByte() != 0xF1):
@@
-90,7
+86,7
@@
def cmdCALL(address):
#return recvByte()
# TODO: test this function!
#return recvByte()
# TODO: test this function!
-def
cmd
CHECKSUM():
+def
bootrom
CHECKSUM():
# call CHECKSUM command
sendByte(0x01)
if (recvByte() != 0xF1):
# call CHECKSUM command
sendByte(0x01)
if (recvByte() != 0xF1):
@@
-101,7
+97,7
@@
def cmdCHECKSUM():
# get checksum
recvChecksum()
# get checksum
recvChecksum()
-def
cmd
BAUDRATE(baudrate):
+def
bootrom
BAUDRATE(baudrate):
# send BAUDRATE command
sendByte(0x01)
if (recvByte() != 0xF1):
# send BAUDRATE command
sendByte(0x01)
if (recvByte() != 0xF1):
@@
-214,9
+210,13
@@
while True:
# timeout happened, who cares ;-)
pass
# timeout happened, who cares ;-)
pass
+starttime = time.time() # save time at this point for evaluating the duration at the end
+
print "OK, trying to set baudrate..."
# set baudrate
print "OK, trying to set baudrate..."
# set baudrate
-cmdBAUDRATE(BOOTLOADER_BAUDRATE)
+bootromBAUDRATE(BOOTLOADER_BAUDRATE)
+time.sleep(0.1) # just to get sure that the bootloader is really running in new baudrate mode!
+del tty
tty = SerialPort(DEVICE, 100, BOOTLOADER_BAUDRATE)
print "Transfering pkernel program to IRAM",
tty = SerialPort(DEVICE, 100, BOOTLOADER_BAUDRATE)
print "Transfering pkernel program to IRAM",
@@
-227,22
+227,20
@@
for seq in bootloaderseqs:
else:
continue
#print "RAMing", len(seq.data), "bytes at address", hex(addr)
else:
continue
#print "RAMing", len(seq.data), "bytes at address", hex(addr)
-
cmd
WRITE(addr, len(seq.data), seq.data)
+
bootrom
WRITE(addr, len(seq.data), seq.data)
tty.flush()
sys.stdout.write(".")
sys.stdout.flush()
print
# execute our pkernel finally and set pkernel conform baudrate
tty.flush()
sys.stdout.write(".")
sys.stdout.flush()
print
# execute our pkernel finally and set pkernel conform baudrate
-
cmd
CALL(0x30000)
-time.sleep(0.
5
) # just to get sure that the pkernel is really running!
+
bootrom
CALL(0x30000)
+time.sleep(0.
1
) # just to get sure that the pkernel is really running!
del tty
del tty
-pkernelmode = True
tty = SerialPort(DEVICE, None, KERNEL_BAUDRATE)
print "Performing ChipErase..."
pkernCHIPERASE()
tty = SerialPort(DEVICE, None, KERNEL_BAUDRATE)
print "Performing ChipErase..."
pkernCHIPERASE()
-print "Chip erasing done."
print "Flashing",
for seq in pkernelseqs:
print "Flashing",
for seq in pkernelseqs:
@@
-256,7
+254,9
@@
for seq in pkernelseqs:
sys.stdout.write(".")
sys.stdout.flush()
print
sys.stdout.write(".")
sys.stdout.flush()
print
-print "Flashing done."
+
+duration = time.time() - starttime
+print "Procedure complete, took", round(duration, 2), "seconds."
sendByte(0x97) # exit and restart
print "Program was started. Have fun!"
sendByte(0x97) # exit and restart
print "Program was started. Have fun!"