Send cmd to enter bootloader from application.

This commit is contained in:
dxl
2023-03-15 10:30:17 +08:00
parent 3cd24ca1a0
commit bebd1047fc
5 changed files with 39 additions and 1 deletions
+1
View File
@@ -75,6 +75,7 @@ class ChameleonCLI:
'openall': new_uint(chameleon_cli_unit.HWSlotOpenAll, "Open all slot and set to default data"),
'help': "Emulation tag slot.",
},
'dfu': new_uint(chameleon_cli_unit.HWDFU, "Restart application to bootloader mode(Not yet implement dfu)."),
'help': "hardware controller",
},
'hf': {
+15
View File
@@ -932,3 +932,18 @@ class HWSlotOpenAll(DeviceRequiredUnit):
# update config and save to flash
self.cmd_positive.update_slot_data_config()
print(f' - Open all slot and set data to default success.')
class HWDFU(DeviceRequiredUnit):
def args_parser(self) -> ArgumentParserNoExit or None:
return None
# hw dfu
def on_exec(self, args: argparse.Namespace):
print("Application restarting...")
self.cmd_standard.enter_dfu_mode()
# 理论上,上面的指令执行完成后,dfu模式会进入,然后USB会重启,
# 我们判断是否成功进入USB,只需要判断USB是否变成DFU设备的VID和PID即可,
# 同时我们记得确认设备的信息,一致时才是同一个设备。
print(" - Enter success @.@~")
+8
View File
@@ -15,6 +15,8 @@ DATA_CMD_GET_SLOT_TAG_NICK = 1008
DATA_CMD_SLOT_DATA_CONFIG_SAVE = 1009
DATA_CMD_ENTER_BOOTLOADER = 1010
DATA_CMD_SCAN_14A_TAG = 2000
DATA_CMD_MF1_SUPPORT_DETECT = 2001
DATA_CMD_MF1_NT_LEVEL_DETECT = 2002
@@ -391,6 +393,12 @@ class BaseChameleonCMD:
"""
return self.device.send_cmd_sync(DATA_CMD_SLOT_DATA_CONFIG_SAVE, 0x00, None)
def enter_dfu_mode(self):
"""
重启进入DFU模式(bootloader)
:return:
"""
return self.device.send_cmd_auto(DATA_CMD_ENTER_BOOTLOADER, 0x00, None)
class NegativeResponseError(Exception):