pssize = dbg.getBLEPStoreSize() if pssize > 0: print " - Backing-up PS Store (%i Bytes)..." % pssize pstoreData = dbg.readCODE( 0x18000, pssize ) hexFile.set( 0x18000, pstoreData ) # Send chip erase print " - Chip erase..." try: dbg.chipErase() except Exception as e: print "ERROR: %s" % str(e) sys.exit(3) # Flash memory dbg.pauseDMA(False) print " - Flashing %i memory blocks..." % len(hexFile.memBlocks) for mb in hexFile.memBlocks: # Flash memory block print " -> 0x%04x : %i bytes " % (mb.addr, mb.size), try: dbg.writeCODE( mb.addr, mb.bytes, verify=True, showProgress=True ) except Exception as e: print "ERROR: %s" % str(e) sys.exit(3) # Done print "\nCompleted" print ""