mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Send cmd to enter bootloader from application.
This commit is contained in:
@@ -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': {
|
||||
|
||||
@@ -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 @.@~")
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user