Implement wipe fds command used to factory reset

This commit is contained in:
Augusto Zanellato
2023-08-18 22:13:06 +02:00
parent 8de6a31196
commit 4ab131d10a
7 changed files with 108 additions and 13 deletions
+1
View File
@@ -99,6 +99,7 @@ class ChameleonCLI:
'reset': new_uint(chameleon_cli_unit.HWSettingsReset, "Reset settings to default values"),
'help': "Chameleon settings management"
},
'factory_reset': new_uint(chameleon_cli_unit.HWFactoryReset, "Wipe all data and return to factory settings"),
'help': "hardware controller",
},
'hf': {
+26
View File
@@ -1066,3 +1066,29 @@ class HWSettingsReset(DeviceRequiredUnit):
print(" - Reset success @.@~")
else:
print(" - Reset failed")
class HWFactoryReset(DeviceRequiredUnit):
def args_parser(self) -> ArgumentParserNoExit:
parser = ArgumentParserNoExit()
parser.description = "Permanently wipes Chameleon to factory settings. " \
"This will delete all your slot data and custom settings. " \
"There's no going back."
parser.add_argument(
"--i-know-what-im-doing",
default=False,
action="store_true",
help="Just to be sure :)"
)
return parser
def on_exec(self, args: argparse.Namespace):
if not args.i_know_what_im_doing:
print("This time your data's safe. Read the command documentation next time.")
return
try:
resp = self.cmd_positive.factory_reset()
if resp.status != chameleon_status.Device.STATUS_DEVICE_SUCCESS:
print(" - Reset failed!")
return
except KeyError:
print(" - A Serial Error above is normal, please ignore it")
print(" - Reset successful! Please reconnect.")
+8
View File
@@ -30,6 +30,8 @@ DATA_CMD_GET_GIT_VERSION = 1017
DATA_CMD_GET_ACTIVE_SLOT = 1018
DATA_CMD_GET_SLOT_INFO = 1019
DATA_CMD_WIPE_FDS = 1020
DATA_CMD_SCAN_14A_TAG = 2000
DATA_CMD_MF1_SUPPORT_DETECT = 2001
DATA_CMD_MF1_NT_LEVEL_DETECT = 2002
@@ -495,6 +497,12 @@ class BaseChameleonCMD:
Store settings to flash memory
"""
return self.device.send_cmd_sync(DATA_CMD_SAVE_SETTINGS, 0x00)
def factory_reset(self):
"""
Reset to factory settings
"""
return self.device.send_cmd_sync(DATA_CMD_WIPE_FDS, 0x00)
class NegativeResponseError(Exception):