USB Protection correction (#90)

This commit is contained in:
devdl11
2021-12-14 20:51:53 +00:00
committed by GitHub
parent 0bd30ed2e6
commit dd48235721
6 changed files with 174 additions and 118 deletions

View File

@@ -47,6 +47,7 @@ __DFU_GETSTATUS = 3
__DFU_CLRSTATUS = 4
__DFU_GETSTATE = 5
__DFU_ABORT = 6
__DFU_UNLOCK = 11
# DFU status
__DFU_STATE_APP_IDLE = 0x00
@@ -145,6 +146,10 @@ def abort_request():
__dev.ctrl_transfer(0x21, __DFU_ABORT, 0, __DFU_INTERFACE, None, __TIMEOUT)
def unlock_request():
"""Deactivate the protection"""
__dev.ctrl_transfer(0x21, __DFU_UNLOCK, 0, __DFU_INTERFACE, None, __TIMEOUT)
def clr_status():
"""Clears any error status (perhaps left over from a previous session)."""
__dev.ctrl_transfer(0x21, __DFU_CLRSTATUS, 0, __DFU_INTERFACE,
@@ -587,6 +592,7 @@ def main():
elements = read_dfu_file(args.path)
if not elements:
return
unlock_request()
print("Writing memory...")
write_elements(elements, args.mass_erase, progress=cli_progress)