last_checksum = 0
def sendByte(byte):
- time.sleep(0.001) # just to get sure, wait 1ms
tty.write(chr(byte))
def sendWord(word):
last_checksum = recvByte()
last_checksum |= (recvByte() << 8)
-def cmdREAD(address, size):
+def bootromREAD(address, size):
# send READ command
sendByte(0x01)
if (recvByte() != 0xF1):
recvChecksum()
return data
-def cmdWRITE(address, size, data):
+def bootromWRITE(address, size, data):
# send WRITE command
sendByte(0x01)
if (recvByte() != 0xF1):
recvChecksum()
# TODO: test this function!
-def cmdCALL(address):
+def bootromCALL(address):
# send CALL command
sendByte(0x01)
if (recvByte() != 0xF1):
#return recvByte()
# TODO: test this function!
-def cmdCHECKSUM():
+def bootromCHECKSUM():
# call CHECKSUM command
sendByte(0x01)
if (recvByte() != 0xF1):
# get checksum
recvChecksum()
-def cmdBAUDRATE(baudrate):
+def bootromBAUDRATE(baudrate):
# send BAUDRATE command
sendByte(0x01)
if (recvByte() != 0xF1):
# 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
-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",
else:
continue
#print "RAMing", len(seq.data), "bytes at address", hex(addr)
- cmdWRITE(addr, len(seq.data), seq.data)
+ bootromWRITE(addr, len(seq.data), seq.data)
tty.flush()
sys.stdout.write(".")
sys.stdout.flush()
print
# execute our pkernel finally and set pkernel conform baudrate
-cmdCALL(0x30000)
-time.sleep(0.5) # just to get sure that the pkernel is really running!
+bootromCALL(0x30000)
+time.sleep(0.1) # just to get sure that the pkernel is really running!
del tty
tty = SerialPort(DEVICE, None, KERNEL_BAUDRATE)
print "Performing ChipErase..."
pkernCHIPERASE()
-print "Chip erasing done."
print "Flashing",
for seq in pkernelseqs:
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!"