Skip to content

Instantly share code, notes, and snippets.

@florianl
Created September 20, 2025 10:22
Show Gist options
  • Select an option

  • Save florianl/eabc75b9098998d233a8cb07370ec4e9 to your computer and use it in GitHub Desktop.

Select an option

Save florianl/eabc75b9098998d233a8cb07370ec4e9 to your computer and use it in GitHub Desktop.
dump partition table
python3 -c "
import struct
import sys
def parse_partition_table(filename):
with open(filename, 'rb') as f:
data = f.read()
partitions = []
offset = 0
while offset < len(data):
entry = data[offset:offset+32]
if len(entry) < 32:
break
# Check for partition table end marker
if entry[:2] == b'\\xEB\\xEB':
break
# Parse partition entry
magic, part_type, subtype, part_offset, part_size = struct.unpack('<HBB2I', entry[:12])
if magic != 0x50AA: # Partition table magic
offset += 32
continue
# Extract label (null-terminated string)
label = entry[12:28].rstrip(b'\\x00').decode('utf-8', errors='ignore')
if label: # Only show named partitions
print(f'{label:16} Type: {part_type:02x} SubType: {subtype:02x} Offset: 0x{part_offset:06x} Size: 0x{part_size:06x} ({part_size//1024}KB)')
partitions.append((label, part_offset, part_size))
offset += 32
return partitions
partitions = parse_partition_table('firmware_dump/partition_table.bin')
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment