1
0
Fork 0
forked from len0rd/rockbox

Add iPod Nano 2G post-mortem memory dumper by Michael Sparmann

The files are downloaded from https://www.rockbox.org/tracker/task/11701

Change-Id: Ic6415f76207868661c231cb534cb179160eb60e0
This commit is contained in:
Vencislav Atanasov 2025-08-13 19:29:50 +03:00 committed by Solomon Peachy
parent bf2320d23b
commit 0781195c22
2 changed files with 86 additions and 0 deletions

55
utils/rbpms/librbpms.py Normal file
View file

@ -0,0 +1,55 @@
#!/usr/bin/env python
import sys
import struct
import usb
class rbpms:
def __init__(self):
self.handle = usb.core.find(idVendor=0xffff, idProduct=0xa112)
if self.handle is None:
raise Exception("Could not find specified device")
self.handle.set_configuration()
print("Connected to Rockbox Post-Mortem Stub on iPod Nano 2G")
@staticmethod
def __myprint(data):
sys.stdout.write(data)
sys.stdout.flush()
def read(self, offset, size):
if offset & 15 != 0:
raise Exception("Unaligned data read!")
data = ""
while True:
blocklen = size
if blocklen == 0: break
if blocklen > 256 * 1024: blocklen = 256 * 1024
self.handle.write(4, struct.pack("<II", offset, blocklen), 0, 100)
block = struct.unpack("%ds" % blocklen, self.handle.read(0x83, blocklen, 0, 1000))[0]
offset += blocklen
data += block
size -= blocklen
return data
def download(self, offset, size, file):
self.__myprint("Downloading 0x%x bytes from 0x%8x to %s..." % (size, offset, file))
f = open(file, "wb")
while True:
blocklen = size
if blocklen == 0: break
if blocklen > 2048 * 1024: blocklen = 2048 * 1024
f.write(self.read(offset, blocklen))
offset += blocklen
size -= blocklen
self.__myprint(".")
self.__myprint(" done\n")

31
utils/rbpms/rbpms.py Normal file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env python
import sys
import librbpms
def usage():
print ""
print "Please provide a command and (if needed) parameters as command line arguments"
print ""
print "Available commands:"
print ""
print " download <address> <size> <file>"
print " Downloads <size> bytes of data from the specified address on the device,"
print " and stores it in the specified file."
print ""
print "All numbers are hexadecimal!"
exit(2)
def parsecommand(dev, argv):
if len(argv) < 2: usage()
elif argv[1] == "download":
if len(argv) != 5: usage()
dev.download(int(argv[2], 16), int(argv[3], 16), argv[4])
else: usage()
dev = librbpms.rbpms()
parsecommand(dev, sys.argv)