Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728import sys, struct, hashlib
TYPES = {0: "app", 1: "data"}APP = {0: "factory", 0x10: "ota_0", 0x11: "ota_1", 0x20: "test"}DATA = {0: "ota", 1: "phy", 2: "nvs", 3: "coredump", 4: "nvs_keys", 5: "efuse", 6: "undefined", 0x80: "esphttpd", 0x81: "fat", 0x82: "spiffs", 0x83: "littlefs"}
data = open(sys.argv[1], "rb").read()if data[:2] != b"\xaa\x50": print("no partition table magic:", data[:16].hex()) sys.exit(1)
rows = []for i in range(0, len(data) - 32, 32): e = data[i:i + 32] if e[:2] != b"\xaa\x50": break magic, ptype, subtype, off, size = struct.unpack("<HBBII", e[:12]) name = e[12:28].rstrip(b"\x00").decode("utf-8", "replace") rows.append((name, ptype, subtype, off, size))
print(f"{'name':<12}{'type':<7}{'subtype':<12}{'offset':<12}{'size':<12}{'flags'}")for name, ptype, subtype, off, size in rows: t = TYPES.get(ptype, hex(ptype)) st = APP.get(subtype) if ptype == 0 else DATA.get(subtype, hex(subtype)) print(f"{name:<12}{t:<7}{str(st):<12}0x{off:<10x}{size/1024:>8.0f} KB")print(f"\n{len(rows)} entries")