Example #1
0
hexFile.set( dbg.flashSize-25, [ binfo['hwver'] ])
hexFile.set( dbg.flashSize-22, [ int(binfo['btaddr'][x:x+2],16) for x in range(0,len(binfo['btaddr']),3) ] )

# Confirm
print "This is going to ERASE and REPROGRAM the chip. Are you sure? <y/N>: ", 
ans = sys.stdin.readline()[0:-1]
if (ans != "y") and (ans != "Y"):
	print "Aborted"
	sys.exit(2)


# Get BLE info page
print "\nFlashing:"

# Check for PStore
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)