Subversion Repositories freemyipod

Rev

Rev 809 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 809 Rev 864
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
    # iPod Nano 2G, Bootrom DFU
32
    try:
33
    try:
33
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1220)
34
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1220)
34
      if self.dev and generation in [0, 2] and type in [0, 1]:
35
      if self.dev and generation in [0, 2] and type in [0, 1]:
35
        self.dev.set_configuration(1)
36
        self.dev.set_configuration(1)
36
        self.generation = 2;
37
        self.generation = 2;
37
        self.type = 1;
38
        self.type = 1;
38
        print("Connected to S5L8701 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
39
        print("Connected to S5L8701 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
39
        return
40
        return
40
    except usb.core.USBError: pass
41
    except usb.core.USBError: pass
-
 
42
    # iPod Nano 3G and iPod Classic 1G/2G/3G, Bootrom DFU
41
    try:
43
    try:
42
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1240)
44
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1223)
43
      if self.dev and generation in [0, 2] and type in [0, 2]:
45
      if self.dev and generation in [0, 3] and type in [0, 1]:
44
        self.dev.set_configuration(1)
46
        self.dev.set_configuration(1)
45
        self.generation = 2;
47
        self.generation = 3;
46
        self.type = 2;
48
        self.type = 1;
47
        print("Connected to iPod Nano 2G NOR DFU mode, USB version %s"  % self.dev.bcdDevice)
49
        print("Connected to S5L8702 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
48
        return
50
        return
49
    except usb.core.USBError: pass
51
    except usb.core.USBError: pass
-
 
52
    # iPod Nano 3G, Bootrom DFU
50
    try:
53
    try:
51
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1223)
54
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1224)
52
      if self.dev and generation in [0, 3] and type in [0, 1]:
55
      if self.dev and generation in [0, 3] and type in [0, 1]:
53
        self.dev.set_configuration(1)
56
        self.dev.set_configuration(1)
54
        self.generation = 3;
57
        self.generation = 3;
55
        self.type = 1;
58
        self.type = 1;
56
        print("Connected to S5L8702 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
59
        print("Connected to S5L8702 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
57
        return
60
        return
58
    except usb.core.USBError: pass
61
    except usb.core.USBError: pass
-
 
62
    # iPod Nano 4G, Bootrom DFU
-
 
63
    try:
-
 
64
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
-
 
65
      if self.dev and generation in [0, 4] and type in [0, 1]:
-
 
66
        self.dev.set_configuration(1)
-
 
67
        self.generation = 4;
-
 
68
        self.type = 1;
-
 
69
        print("Connected to S5L8720 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
-
 
70
        return
-
 
71
    except usb.core.USBError: pass
-
 
72
    # iPod Nano 5G, Bootrom DFU
-
 
73
    try:
-
 
74
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1231)
-
 
75
      if self.dev and generation in [0, 5] and type in [0, 1]:
-
 
76
        self.dev.set_configuration(1)
-
 
77
        self.generation = 5;
-
 
78
        self.type = 1;
-
 
79
        print("Connected to S5L8730 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
-
 
80
        return
-
 
81
    except usb.core.USBError: pass
-
 
82
    # iPod Nano 6G, Bootrom DFU
-
 
83
    try:
-
 
84
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
-
 
85
      if self.dev and generation in [0, 6] and type in [0, 1]:
-
 
86
        self.dev.set_configuration(1)
-
 
87
        self.generation = 6;
-
 
88
        self.type = 1;
-
 
89
        print("Connected to S5L8723 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
-
 
90
        return
-
 
91
    except usb.core.USBError: pass
-
 
92
    
-
 
93
    # iPod Nano 2G, NOR DFU
-
 
94
    try:
-
 
95
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1240)
-
 
96
      if self.dev and generation in [0, 2] and type in [0, 2]:
-
 
97
        self.dev.set_configuration(1)
-
 
98
        self.generation = 2;
-
 
99
        self.type = 2;
-
 
100
        print("Connected to iPod Nano 2G NOR DFU mode, USB version %s"  % self.dev.bcdDevice)
-
 
101
        return
-
 
102
    except usb.core.USBError: pass
-
 
103
    # iPod Nano 3G, WTF
59
    try:
104
    try:
60
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1242)
105
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1242)
61
      if self.dev and generation in [0, 3] and type in [0, 2]:
106
      if self.dev and generation in [0, 3] and type in [0, 2]:
62
        self.dev.set_configuration(1)
107
        self.dev.set_configuration(1)
63
        self.generation = 3;
108
        self.generation = 3;
64
        self.type = 2;
109
        self.type = 2;
65
        print("Connected to iPod Nano 3G WTF mode, USB version %s"  % self.dev.bcdDevice)
110
        print("Connected to iPod Nano 3G WTF mode, USB version %s"  % self.dev.bcdDevice)
66
        return
111
        return
67
    except usb.core.USBError: pass
112
    except usb.core.USBError: pass
-
 
113
    # iPod Classic 1G, WTF
68
    try:
114
    try:
69
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1241)
115
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1241)
70
      if self.dev and generation in [0, 11] and type in [0, 2]:
116
      if self.dev and generation in [0, 11] and type in [0, 2]:
71
        self.dev.set_configuration(1)
117
        self.dev.set_configuration(1)
72
        self.generation = 11;
118
        self.generation = 11;
73
        self.type = 2;
119
        self.type = 2;
74
        print("Connected to iPod Classic 1G WTF mode, USB version %s"  % self.dev.bcdDevice)
120
        print("Connected to iPod Classic 1G WTF mode, USB version %s"  % self.dev.bcdDevice)
75
        return
121
        return
76
    except usb.core.USBError: pass
122
    except usb.core.USBError: pass
-
 
123
    # iPod Classic 2G, WTF
77
    try:
124
    try:
78
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1245)
125
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1245)
79
      if self.dev and generation in [0, 12] and type in [0, 2]:
126
      if self.dev and generation in [0, 12] and type in [0, 2]:
80
        self.dev.set_configuration(1)
127
        self.dev.set_configuration(1)
81
        self.generation = 12;
128
        self.generation = 12;
82
        self.type = 2;
129
        self.type = 2;
83
        print("Connected to iPod Classic 2G WTF mode, USB version %s"  % self.dev.bcdDevice)
130
        print("Connected to iPod Classic 2G WTF mode, USB version %s"  % self.dev.bcdDevice)
84
        return
131
        return
85
    except usb.core.USBError: pass
132
    except usb.core.USBError: pass
-
 
133
    # iPod Classic 3G, WTF
86
    try:
134
    try:
87
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1247)
135
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1247)
88
      if self.dev and generation in [0, 13] and type in [0, 2]:
136
      if self.dev and generation in [0, 13] and type in [0, 2]:
89
        self.dev.set_configuration(1)
137
        self.dev.set_configuration(1)
90
        self.generation = 13;
138
        self.generation = 13;
91
        self.type = 2;
139
        self.type = 2;
92
        print("Connected to iPod Classic 3G WTF mode, USB version %s"  % self.dev.bcdDevice)
140
        print("Connected to iPod Classic 3G WTF mode, USB version %s"  % self.dev.bcdDevice)
93
        return
141
        return
94
    except usb.core.USBError: pass
142
    except usb.core.USBError: pass
-
 
143
    # iPod Nano 4G, WTF
95
    try:
144
    try:
96
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
145
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
97
      if self.dev and generation in [0, 4] and type in [0, 1]:
146
      if self.dev and generation in [0, 4] and type in [0, 2]:
98
        self.dev.set_configuration(1)
147
        self.dev.set_configuration(1)
99
        self.generation = 4;
148
        self.generation = 4;
100
        self.type = 1;
149
        self.type = 2;
101
        print("Connected to S5L8720 Bootrom DFU mode, USB version %s"  % self.dev.bcdDevice)
150
        print("Connected to iPod Nano 4G WTF mode, USB version %s"  % self.dev.bcdDevice)
102
        return
151
        return
103
    except usb.core.USBError: pass
152
    except usb.core.USBError: pass
-
 
153
    # iPod Nano 5G, WTF
104
    try:
154
    try:
105
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
155
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
106
      if self.dev and generation in [0, 4] and type in [0, 2]:
156
      if self.dev and generation in [0, 5] and type in [0, 2]:
107
        self.dev.set_configuration(1)
157
        self.dev.set_configuration(1)
108
        self.generation = 4;
158
        self.generation = 5;
109
        self.type = 2;
159
        self.type = 2;
110
        print("Connected to iPod Nano 4G WTF mode, USB version %s"  % self.dev.bcdDevice)
160
        print("Connected to iPod Nano 5G WTF mode, USB version %s"  % self.dev.bcdDevice)
-
 
161
        return
-
 
162
    except usb.core.USBError: pass
-
 
163
    # iPod Nano 6G, WTF
-
 
164
    try:
-
 
165
      self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
-
 
166
      if self.dev and generation in [0, 6] and type in [0, 2]:
-
 
167
        self.dev.set_configuration(1)
-
 
168
        self.generation = 6;
-
 
169
        self.type = 2;
-
 
170
        print("Connected to iPod Nano 6G WTF mode, USB version %s"  % self.dev.bcdDevice)
111
        return
171
        return
112
    except usb.core.USBError: pass
172
    except usb.core.USBError: pass
113
 
173
 
114
    raise Exception("Could not find specified DFU device (generation = %d, type = %d)" % (generation, type))
174
    raise Exception("Could not find specified DFU device (generation = %d, type = %d)" % (generation, type))
115
 
175