- bootloaderseqs = readMHXFile("pkernel/pkernel.mhx")
- except IOError as error1:
- bootloaderseqs = readMHXFile("%PREFIX%/share/frprog/pkernel.mhx")
- pkernelseqs = readMHXFile(sys.argv[1])
-except IOError as error:
- print sys.argv[0] + ": Error - couldn't open file " + error.filename + "!"
- sys.exit(1)
-
-print "Initializing serial port..."
-tty = SerialPort(DEVICE, 100, INIT_BAUDRATE)
-
-print "Please press RESET on your board..."
-
-while True:
- tty.write('V')
- tty.flush()
- try:
- if tty.read() == 'F':
- break
- except SerialPortException:
- # 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
-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",
-# let the fun begin!
-for seq in bootloaderseqs:
- if(seq.address <= 0x40000):
- addr = seq.address
- else:
- continue
- #print "RAMing", len(seq.data), "bytes at address", hex(addr)
- 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
-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 "Flashing",
-for seq in pkernelseqs:
- # 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)
- tty.flush()
- sys.stdout.write(".")
- sys.stdout.flush()
-print
-
-duration = time.time() - starttime
-print "Procedure complete, took", round(duration, 2), "seconds."
-
-sendByte(0x97) # exit and restart
-print "Program was started. Have fun!"
+ bootrombaudrate(BOOTLOADER_BAUDRATE)
+ except SerialPortException:
+ print "timeout exception: try again ->"
+ bootrombaudrate(BOOTLOADER_BAUDRATE)
+ # just to get sure that the bootloader is really running in new baudrate mode!
+ time.sleep(0.1)
+ del tty
+ tty = SerialPort(device, 100, BOOTLOADER_BAUDRATE)
+
+ sdots = SPLIT
+ print "Transfering pkernel program to IRAM",
+ # let the fun begin!
+ for seq in bootloaderseqs:
+ if(seq.address <= 0x40000):
+ addr = seq.address
+ else:
+ continue
+ #print "RAMing", len(seq.data), "bytes at address", hex(addr)
+ bootromwrite(addr, len(seq.data), seq.data)
+ tty.flush()
+
+ sdots = sdots - 1
+ if sdots == 0:
+ sys.stdout.write(".")
+ sys.stdout.flush()
+ sdots = SPLIT
+ print
+
+ # execute our pkernel finally and set pkernel conform baudrate
+ 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()
+
+ sdots = SPLIT
+ print "Flashing",
+ for seq in pkernelseqs:
+ # 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)
+ tty.flush()
+
+ sdots = sdots - 1
+ if sdots == 0:
+ sys.stdout.write(".")
+ sys.stdout.flush()
+ sdots = SPLIT
+ print
+
+ duration = time.time() - starttime
+ print "Procedure complete, took", round(duration, 2), "seconds."
+
+ sendbyte(0x97) # exit and restart
+ print "Program was started. Have fun!"
+
+
+if __name__ == '__main__':
+ sys.exit(main())