-print "Reading from the IRAM again..."
-data_re = cmdREAD(0x00030000, len(data_wr))
-print "Received data:", data_re, "Checksum:", last_checksum
-"""
-
-"""
-# see whats in the iram at the moment
-data_wr = []
-print "Reading from the IRAM..."
-data_re = cmdREAD(0x00030000, 0x10000-4)
-print "Received data:", data_re, "Checksum:", last_checksum
-"""
-
-"""
-# see whats in the dram at the moment
-data_wr = []
-print "Reading from the DRAM..."
-data_re = cmdREAD(0x0002C000, 0x10000-0xC000-4)
-print "Received data:", data_re, "Checksum:", last_checksum
-"""
-
-"""
-# blank the iram
-data_wr = []
-for i in range(0, 0x10000-4):
- value = 0
- data_wr.append(value)
-
-print "Writing", data_wr, "to the IRAM..."
-cmdWRITE(0x00030000, len(data_wr), data_wr)
-print "Received Checksum:", last_checksum
-print
-"""
-
-"""
-# blank the dram
-data_wr = []
-for i in range(0, 0x10000-0xC000-4):
- value = 0
- data_wr.append(value)
-
-print "Writing", data_wr, "to the DRAM..."
-cmdWRITE(0x0002C000, len(data_wr), data_wr)
-print "Received Checksum:", last_checksum
-print
-"""
-
-"""
-# write some data in the iram and try to execute it
-data_wr =[
- 0x9B,0x00,
- 0x0D,0x4e,
- 0xcf,0xf1,
- 0x16,0x01,
- 0x9b,0x05,
- 0x04,0xc7,
- 0xc1,0x06,
- 0x16,0x56,
- 0xe0,0xfb, #branch
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0, #nop
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0,
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0,
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0,
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0,
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0,
- 0x9f,0xa0,0x9f,0xa0,0x9f,0xa0]
-print "Writing", data_wr, "to the IRAM..."
-cmdWRITE(0x00030000, len(data_wr), data_wr)
-print "Received Checksum:", last_checksum
+# 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!
+del tty
+pkernelmode = True
+tty = SerialPort(DEVICE, None, KERNEL_BAUDRATE)
+
+print "Performing ChipErase..."
+pkernCHIPERASE()
+print "Chip erasing done."
+
+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()