Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
s.adapter.set_tclk(0)
# Run target serial clock at 1.5MHz
s.adapter.set_sclk(127)
try:
code = args.code.decode('hex')
except TypeError:
logging.fatal("Code must be in hexadecimal format.")
return
if len(code) != 7:
logging.fatal("Code must be 7 bytes long.")
return
s.unlock(code)
status = s.unlock_status()
if status != serialio.UNLOCK_SUCCESSFUL:
logging.fatal("Target did not unlock.")
return
logging.info("Target unlocked.")
start = 0x0e00
end = 0x0fff
with open(args.output, 'w') as f:
logging.info("Writing pages {:x}-{:x} to {}...".format(start, end,
args.output))
for page in range(start, end+1):
logging.debug("Dumping {:x}00-{:x}ff...".format(page, page))
data = s.read_page(page)
f.write(data)