- while i<=stop:
- try:
- data=client.ARMreadChunk(i, 48, verbose=0)
- print "Dumped %06x."%i
- for dword in data:
- if i<=stop and dword != 0xdeadbeef:
- h.puts( i, struct.pack("<I", dword) )
- err_cnt = 0
- i+=4
- # FIXME: get mcu state and return it to that state
- except:
- # Handle exceptions by counting errors after pausing to let ARM settle
- err_cnt = 1
- fail = 0
- while err_cnt:
- time.sleep(.25)
- if err_cnt == 100:
- print "Unknown error occurred at least 100 times. Resync did not work. Writing incomplete data to file."
- fail = 1
+ while base<=stop:
+ confirmed = False
+ while not confirmed:
+ i = base
+ try:
+ data=client.ARMreadChunk(i, BLOCK_DWORDS, verbose=0)
+ print "Dumped %06x."%i
+ for dword in data:
+ if i<=stop:# and dword != 0xdeadbeef:
+ h.puts( i, struct.pack("<I", dword) )
+ err_cnt = 0
+ i += 4
+
+ confirmed=True
+
+ # FIXME: get mcu state and return it to that state
+ except:
+ # Handle exceptions by counting errors after pausing to let ARM settle
+ err_cnt = 1
+ fail = 0
+ while err_cnt:
+ time.sleep(.25)
+ if err_cnt == 100:
+ print "Unknown error occurred at least 100 times. Resync did not work. Writing incomplete data to file."
+ fail = 1
+ break
+ else:
+ try:
+ print "Unknown error during read. Resync and retry."
+ err_list.append("0x%06x"%i)
+
+ # If we error out several times then reset the chip and restart
+ # This uses a special register value from a Chip Select Register
+ # to test that the chip is in the operation state we expect
+ if not ((err_cnt+1) % 2):
+ while True:
+ print " Reset:",reset_cnt
+ check_addr = client.getChipSelectReg(special_reg_num)
+ print " Special Addr:",hex(special_addr)
+ print " Check Addr:",hex(check_addr)
+ if (special_addr == check_addr):
+ break
+ if reset_cnt == 10:
+ reset_cnt = 0
+ print " Resetting Target"
+ client.ARMresettarget(1000)
+ client.halt()
+ reset_cnt += 1
+ time.sleep(.25)
+ else:
+ #Resync ARM and Watch Dog
+ client.resume()
+ client.halt()
+
+ err_cnt = 0
+ except:
+ err_cnt += 1
+ pass
+ if fail: