import struct import sys import os path = sys.argv[1:] bin_path = "./crashinfo.bin" format_path = "./crashinfo.txt" if len(path) >= 1: for i in path: if i.endswith("bin") and os.path.isfile(i): bin_path = i elif i.endswith("txt"): format_path = i else: print("invalid parameter: ", i) txt_path = "./crashinfo_bin.txt" ret = [] def exc_info_get_phase(phase): str = { 0 : "Init", 1 : "Task", 2 : "Irq", 3 : "Exc" } return str.get(phase, None) def task_info_get_status(status): if status & 0x10 == 0x10: return "Running" elif status & 0x4 == 0x4: return "Ready" elif status & 0x20 == 0x20: return "Delay" elif status & 0x82 == 0x82: return "SuspendTime" elif status & 0x88 == 0x88: return "PendTime" elif status & 0x8 == 0x8: return "Pend" elif status & 0x2 == 0x2: return "Suspend" elif status & 0x100 == 0x100: return "Zombie" else: return "Invalid" if __name__ == "__main__": with open(bin_path, 'rb') as file: data = file.read() for byte in data: ret.append(f"{byte:02x}") with open(txt_path,'w') as file: line_index = 0 for byte in ret: file.write(byte) line_index += 1 if line_index >= 16 : file.write('\n') line_index = 0 else: file.write(' ') file = open(bin_path, "rb") with open(format_path,'w') as write_file: flag = struct.unpack(' 0 else 96 task_info_cnt = struct.unpack('= len(task_name_arr): break file.seek(task_info_addr + i * task_info_size, 0) task_info_stackPointer = struct.unpack('