| Line 27... |
Line 27... |
| 27 |
import usb.core
|
27 |
import usb.core
|
| 28 |
|
28 |
|
| 29 |
|
29 |
|
| 30 |
class ipoddfu:
|
30 |
class ipoddfu:
|
| 31 |
def __init__(self, generation = 0, type = 0):
|
31 |
def __init__(self, generation = 0, type = 0):
|
| - |
|
32 |
try:
|
| 32 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1220)
|
33 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1220)
|
| 33 |
if self.dev and generation in [0, 2] and type in [0, 1]:
|
34 |
if self.dev and generation in [0, 2] and type in [0, 1]:
|
| 34 |
self.dev.set_configuration(1)
|
35 |
self.dev.set_configuration(1)
|
| 35 |
self.generation = 2;
|
36 |
self.generation = 2;
|
| 36 |
self.type = 1;
|
37 |
self.type = 1;
|
| 37 |
print("Connected to S5L8701 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
|
38 |
print("Connected to S5L8701 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
|
| 38 |
return
|
39 |
return
|
| - |
|
40 |
except usb.core.USBError: pass
|
| - |
|
41 |
try:
|
| 39 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1240)
|
42 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1240)
|
| 40 |
if self.dev and generation in [0, 2] and type in [0, 2]:
|
43 |
if self.dev and generation in [0, 2] and type in [0, 2]:
|
| 41 |
self.dev.set_configuration(1)
|
44 |
self.dev.set_configuration(1)
|
| 42 |
self.generation = 2;
|
45 |
self.generation = 2;
|
| 43 |
self.type = 2;
|
46 |
self.type = 2;
|
| 44 |
print("Connected to iPod Nano 2G NOR DFU mode, USB version %s" % self.dev.bcdDevice)
|
47 |
print("Connected to iPod Nano 2G NOR DFU mode, USB version %s" % self.dev.bcdDevice)
|
| 45 |
return
|
48 |
return
|
| - |
|
49 |
except usb.core.USBError: pass
|
| - |
|
50 |
try:
|
| 46 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1223)
|
51 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1223)
|
| 47 |
if self.dev and generation in [0, 3] and type in [0, 1]:
|
52 |
if self.dev and generation in [0, 3] and type in [0, 1]:
|
| 48 |
self.dev.set_configuration(1)
|
53 |
self.dev.set_configuration(1)
|
| 49 |
self.generation = 3;
|
54 |
self.generation = 3;
|
| 50 |
self.type = 1;
|
55 |
self.type = 1;
|
| 51 |
print("Connected to S5L8702 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
|
56 |
print("Connected to S5L8702 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
|
| 52 |
return
|
57 |
return
|
| - |
|
58 |
except usb.core.USBError: pass
|
| - |
|
59 |
try:
|
| 53 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1242)
|
60 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1242)
|
| 54 |
if self.dev and generation in [0, 3] and type in [0, 1]:
|
61 |
if self.dev and generation in [0, 3] and type in [0, 2]:
|
| 55 |
self.dev.set_configuration(1)
|
62 |
self.dev.set_configuration(1)
|
| 56 |
self.generation = 3;
|
63 |
self.generation = 3;
|
| 57 |
self.type = 2;
|
64 |
self.type = 2;
|
| 58 |
print("Connected to iPod Nano 3G WTF mode, USB version %s" % self.dev.bcdDevice)
|
65 |
print("Connected to iPod Nano 3G WTF mode, USB version %s" % self.dev.bcdDevice)
|
| 59 |
return
|
66 |
return
|
| - |
|
67 |
except usb.core.USBError: pass
|
| - |
|
68 |
try:
|
| 60 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
|
69 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
|
| 61 |
if self.dev and generation in [0, 4] and type in [0, 1]:
|
70 |
if self.dev and generation in [0, 4] and type in [0, 1]:
|
| 62 |
self.dev.set_configuration(1)
|
71 |
self.dev.set_configuration(1)
|
| 63 |
self.generation = 4;
|
72 |
self.generation = 4;
|
| 64 |
self.type = 1;
|
73 |
self.type = 1;
|
| 65 |
print("Connected to S5L8720 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
|
74 |
print("Connected to S5L8720 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
|
| 66 |
return
|
75 |
return
|
| - |
|
76 |
except usb.core.USBError: pass
|
| - |
|
77 |
try:
|
| 67 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
|
78 |
self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
|
| 68 |
if self.dev and generation in [0, 4] and type in [0, 1]:
|
79 |
if self.dev and generation in [0, 4] and type in [0, 2]:
|
| 69 |
self.dev.set_configuration(1)
|
80 |
self.dev.set_configuration(1)
|
| 70 |
self.generation = 4;
|
81 |
self.generation = 4;
|
| 71 |
self.type = 2;
|
82 |
self.type = 2;
|
| 72 |
print("Connected to iPod Nano 4G WTF mode, USB version %s" % self.dev.bcdDevice)
|
83 |
print("Connected to iPod Nano 4G WTF mode, USB version %s" % self.dev.bcdDevice)
|
| 73 |
return
|
84 |
return
|
| - |
|
85 |
except usb.core.USBError: pass
|
| 74 |
|
86 |
|
| 75 |
raise Exception("Could not find specified DFU device (generation = %d, type = %d)" % (generation, type))
|
87 |
raise Exception("Could not find specified DFU device (generation = %d, type = %d)" % (generation, type))
|
| 76 |
|
88 |
|
| 77 |
@staticmethod
|
89 |
@staticmethod
|
| 78 |
def crc32(data):
|
90 |
def crc32(data):
|