mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
A FAT12 dump script that got left behing in some old master branch (was used in #1793)
This commit is contained in:
parent
18e36657f8
commit
edab80e6af
1 changed files with 52 additions and 0 deletions
52
radio/util/fat12decode.py
Executable file
52
radio/util/fat12decode.py
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
To dump FAT and prepare input for this program, one can use command like this:
|
||||||
|
# dd if=/dev/sde skip=1 count=1 | hexdump -v -e '/1 "%02X "' | tr -d ' '
|
||||||
|
|
||||||
|
Stock FAT is this:
|
||||||
|
F8FFFF03400005600007800009F0FF0BC0000DE0000F000111200113400115600117800119A0011BC0011DE0011F000221200223400225600227800229A0022BC0022DE0022F000331200333400335600337800339A0033BC0033DE0033F000441200443400445600447800449A0044BC0044DE0044F000551200553400555600557800559A0055BC0055DE0055F000661200663400665600667800669A0066BC0066DE0066F000771200773400775600777800779A0077BC0077DE0077F000881200883400885600887800889F0FF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
def displayCluster(cluster, hexfat):
|
||||||
|
decfat = int(hexfat, 16)
|
||||||
|
|
||||||
|
next = ""
|
||||||
|
if decfat == 0:
|
||||||
|
next = "-"
|
||||||
|
elif decfat == 1:
|
||||||
|
next = "invalid"
|
||||||
|
elif decfat <= 0xfef : # 002-fef: cluster in use
|
||||||
|
next = "next %03d" % decfat
|
||||||
|
elif decfat <= 0xff6: # reserved,
|
||||||
|
next = "reserved (0x%03x)" % decfat
|
||||||
|
elif decfat == 0xff7: #bad cluster
|
||||||
|
next = "bad"
|
||||||
|
elif decfat <= 0xfff: # cluster in use, the last one in this file
|
||||||
|
next = "last in this file (0x%03x)" % decfat
|
||||||
|
|
||||||
|
print "cluster %03d: %s" % (cluster, next)
|
||||||
|
|
||||||
|
|
||||||
|
data = sys.argv[1]
|
||||||
|
|
||||||
|
cluster = 0
|
||||||
|
while len(data) > 0:
|
||||||
|
twofats = data[0:6]
|
||||||
|
fat1 = twofats[3] + twofats[0:2]
|
||||||
|
fat2 = twofats[4:6] + twofats[2]
|
||||||
|
# print "fat1 %s, fat2 %s" % (fat1, fat2)
|
||||||
|
data = data[len(twofats):]
|
||||||
|
|
||||||
|
displayCluster(cluster, fat1)
|
||||||
|
displayCluster(cluster+1, fat2)
|
||||||
|
|
||||||
|
# print "cluster %03d: next %03d" % (cluster, int(fat1, 16))
|
||||||
|
# print "cluster %03d: next %03d" % (cluster+1, int(fat2, 16))
|
||||||
|
cluster = cluster + 2
|
Loading…
Add table
Add a link
Reference in a new issue