From 20c2f615555e5e7ddc03a2a22e225f75dff1c320 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 23 Dec 2022 10:12:30 +0100 Subject: [PATCH 1/3] update fac reset cmd --- eive_tmtc/tmtc/payload/ploc_supervisor.py | 48 +++++++++++------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 6c45477..cefad97 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -64,6 +64,23 @@ event_buffer_path_dict = { } +FactoryResetOp = { + 0x00: "CLEAR_MRAM_EVENT_BUF", + 0x01: "CLEAR_MRAM_ADC_BUF", + 0x02: "FACTORY_DEFAULT_MRAM_SYS_CFG", + 0x03: "FACTORY_DEFAULT_MRAM_DBG_CFG", + 0x04: "FACTORY_DEFAULT_BOOTMAN_CFG", + 0x05: "FACTORY_DEFAULT_DATA_LOGGER", + 0x06: "DATA_LOGGER_OP_DATA_TO_ZERO", + 0x07: "FACTORY_DEFAULT_MRAM_LATCHUP_MON", + 0x08: "FACTORY_DEFAULT_ADC_MON_CFG", + 0x09: "FACTORY_DEFAULT_WATCHDOG_MON_CFG", + 0x0A: "FACTORY_DEFAULT_HK_CFG", + 0x0B: "FACTORY_DEFAULT_MEM_MAN_CFG", + 0x10: "REDWIRE_TASK_1", + 0x11: "REDWIRE_TASK_2", + 0x12: "REDWIRE_TASK_3", +} class SupvActionIds: HK_REPORT = 1 START_MPSOC = 3 @@ -92,11 +109,8 @@ class SupvActionIds: SET_GPIO = 34 READ_GPIO = 35 RESTART_SUPERVISOR = 36 - FACTORY_RESET_CLEAR_ALL = 37 LOGGING_REQUEST_COUNTERS = 38 - UPDATE_IMAGE_DATA = 39 - FACTORY_RESET_CLEAR_MIRROR = 40 - FACTORY_RESET_CLEAR_CIRCULAR = 41 + FACTORY_RESET = 39 START_MPSOC_QUIET = 45 SET_SHUTDOWN_TIMEOUT = 46 FACTORY_FLASH = 47 @@ -133,6 +147,7 @@ class OpCodes: REQ_BOOT_STATUS_REPORT = ["13", "boot_report"] START_UPDATE = ["42", "start_update"] PERFORM_UPDATE = ["update"] + FACTORY_RESET = ["factory_reset"] MEM_CHECK = ["mem_check"] @@ -147,6 +162,7 @@ class Info(str, enum.Enum): FACTORY_FLASH = "Factory Flash Mode" PERFORM_UPDATE = "Start or continue MPSoC SW update at starting bytes" START_UPDATE = "Start new MPSoC SW update" + FACTORY_RESET = "Factory Reset of loggers" REQ_BOOT_STATUS_REPORT = "Request boot status report and HK" MEM_CHECK = "Memory Check" SEL_NVM = "Select NVM" @@ -165,6 +181,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add(OpCodes.SHUTDOWN_MPSOC, "PLOC Supervisor: Shutdown MPSoC") oce.add(OpCodes.SEL_NVM, Info.SEL_NVM) oce.add(OpCodes.SET_TIME_REF, Info.SET_TIME_REF) + oce.add(OpCodes.FACTORY_RESET, Info.FACTORY_RESET) oce.add("8", "PLOC Supervisor: Set max restart tries") oce.add("9", "PLOC Supervisor: Reset MPSoC") oce.add("11", "PLOC Supervisor: Set boot timeout") @@ -183,9 +200,6 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add("35", "PLOC Supervisor: Set GPIO") oce.add("36", "PLOC Supervisor: Read GPIO") oce.add("37", "PLOC Supervisor: Restart supervisor") - oce.add("38", "PLOC Supervisor: Factory reset clear all") - oce.add("39", "PLOC Supervisor: Factory reset clear mirror entries") - oce.add("40", "PLOC Supervisor: Factory reset clear circular entries") oce.add(OpCodes.PERFORM_UPDATE, Info.PERFORM_UPDATE) oce.add(OpCodes.START_UPDATE, Info.START_UPDATE) oce.add("43", "PLOC Supervisor: Terminate supervisor process") @@ -251,6 +265,8 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): bp2 = int(input("BP2 (0 or 1): ")) command = pack_sel_boot_image_cmd(object_id.as_bytes, mem, bp0, bp1, bp2) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) + if op_code in OpCodes.FACTORY_RESET: + q.add_log_cmd(f"{prefix}: {Info.FACTORY_RESET}") if op_code == "8": q.add_log_cmd("PLOC Supervisor: Set max restart tries") restart_tries = int(input("Specify maximum restart tries: ")) @@ -349,24 +365,6 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): "!I", SupvActionIds.RESTART_SUPERVISOR ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "38": - q.add_log_cmd("PLOC Supervisor: Factory reset clear all") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionIds.FACTORY_RESET_CLEAR_ALL - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "39": - q.add_log_cmd("PLOC Supervisor: Factory reset clear mirror entries") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionIds.FACTORY_RESET_CLEAR_MIRROR - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "40": - q.add_log_cmd("PLOC Supervisor: Factory reset clear circular entries") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionIds.FACTORY_RESET_CLEAR_CIRCULAR - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code in OpCodes.START_UPDATE: q.add_log_cmd("PLOC Supversior: Start new MPSoC SW update") command = pack_update_command(object_id.as_bytes, True) From 825a1972c4ca63f8044eff582a97b4221d513fec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 23 Dec 2022 10:17:44 +0100 Subject: [PATCH 2/3] implement PLOC SUPV fac reset cmd --- eive_tmtc/tmtc/payload/ploc_supervisor.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index cefad97..49dea9d 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -64,7 +64,7 @@ event_buffer_path_dict = { } -FactoryResetOp = { +FACTORY_RESET_OPS = { 0x00: "CLEAR_MRAM_EVENT_BUF", 0x01: "CLEAR_MRAM_ADC_BUF", 0x02: "FACTORY_DEFAULT_MRAM_SYS_CFG", @@ -81,6 +81,8 @@ FactoryResetOp = { 0x11: "REDWIRE_TASK_2", 0x12: "REDWIRE_TASK_3", } + + class SupvActionIds: HK_REPORT = 1 START_MPSOC = 3 @@ -267,6 +269,16 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code in OpCodes.FACTORY_RESET: q.add_log_cmd(f"{prefix}: {Info.FACTORY_RESET}") + key = -1 + while True: + print("Please select the key for a factory reset operation") + for key, val in FACTORY_RESET_OPS: + print(f"{key}: {val}") + key = int(input("Key Select: ")) + if key not in FACTORY_RESET_OPS: + print("Key invalid!") + break + q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=bytes([key]))) if op_code == "8": q.add_log_cmd("PLOC Supervisor: Set max restart tries") restart_tries = int(input("Specify maximum restart tries: ")) From 5c675560eadadfbb5e674d9be87c206df09d1771 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 23 Dec 2022 11:00:19 +0100 Subject: [PATCH 3/3] minor fixes --- eive_tmtc/tmtc/payload/ploc_supervisor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 49dea9d..d6f2892 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -272,13 +272,13 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): key = -1 while True: print("Please select the key for a factory reset operation") - for key, val in FACTORY_RESET_OPS: + for key, val in FACTORY_RESET_OPS.items(): print(f"{key}: {val}") key = int(input("Key Select: ")) if key not in FACTORY_RESET_OPS: print("Key invalid!") break - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=bytes([key]))) + q.add_pus_tc(make_fsfw_action_cmd(object_id=PLOC_SUPV_ID, action_id=SupvActionIds.FACTORY_RESET, user_data=bytes([key]))) if op_code == "8": q.add_log_cmd("PLOC Supervisor: Set max restart tries") restart_tries = int(input("Specify maximum restart tries: "))