freemyipod r864 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r863‎ | r864 | r865 >
Date:15:05, 27 May 2012
Author:user890104
Status:new
Tags:
Comment:
ipoddfu: add N5G and N6G PIDs, group PIDs by mode
Modified paths:
  • /tools/ipoddfu/libipoddfu.py (modified) (history)
  • /tools/ipoddfu_c/usb.c (modified) (history)

Diff [purge]

Index: tools/ipoddfu/libipoddfu.py
@@ -29,6 +29,7 @@
3030
3131 class ipoddfu:
3232 def __init__(self, generation = 0, type = 0):
 33+ # iPod Nano 2G, Bootrom DFU
3334 try:
3435 self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1220)
3536 if self.dev and generation in [0, 2] and type in [0, 1]:
@@ -38,17 +39,19 @@
3940 print("Connected to S5L8701 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
4041 return
4142 except usb.core.USBError: pass
 43+ # iPod Nano 3G and iPod Classic 1G/2G/3G, Bootrom DFU
4244 try:
43 - self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1240)
44 - if self.dev and generation in [0, 2] and type in [0, 2]:
 45+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1223)
 46+ if self.dev and generation in [0, 3] and type in [0, 1]:
4547 self.dev.set_configuration(1)
46 - self.generation = 2;
47 - self.type = 2;
48 - print("Connected to iPod Nano 2G NOR DFU mode, USB version %s" % self.dev.bcdDevice)
 48+ self.generation = 3;
 49+ self.type = 1;
 50+ print("Connected to S5L8702 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
4951 return
5052 except usb.core.USBError: pass
 53+ # iPod Nano 3G, Bootrom DFU
5154 try:
52 - self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1223)
 55+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1224)
5356 if self.dev and generation in [0, 3] and type in [0, 1]:
5457 self.dev.set_configuration(1)
5558 self.generation = 3;
@@ -56,7 +59,49 @@
5760 print("Connected to S5L8702 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
5861 return
5962 except usb.core.USBError: pass
 63+ # iPod Nano 4G, Bootrom DFU
6064 try:
 65+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
 66+ if self.dev and generation in [0, 4] and type in [0, 1]:
 67+ self.dev.set_configuration(1)
 68+ self.generation = 4;
 69+ self.type = 1;
 70+ print("Connected to S5L8720 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
 71+ return
 72+ except usb.core.USBError: pass
 73+ # iPod Nano 5G, Bootrom DFU
 74+ try:
 75+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1231)
 76+ if self.dev and generation in [0, 5] and type in [0, 1]:
 77+ self.dev.set_configuration(1)
 78+ self.generation = 5;
 79+ self.type = 1;
 80+ print("Connected to S5L8730 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
 81+ return
 82+ except usb.core.USBError: pass
 83+ # iPod Nano 6G, Bootrom DFU
 84+ try:
 85+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
 86+ if self.dev and generation in [0, 6] and type in [0, 1]:
 87+ self.dev.set_configuration(1)
 88+ self.generation = 6;
 89+ self.type = 1;
 90+ print("Connected to S5L8723 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
 91+ return
 92+ except usb.core.USBError: pass
 93+
 94+ # iPod Nano 2G, NOR DFU
 95+ try:
 96+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1240)
 97+ if self.dev and generation in [0, 2] and type in [0, 2]:
 98+ self.dev.set_configuration(1)
 99+ self.generation = 2;
 100+ self.type = 2;
 101+ print("Connected to iPod Nano 2G NOR DFU mode, USB version %s" % self.dev.bcdDevice)
 102+ return
 103+ except usb.core.USBError: pass
 104+ # iPod Nano 3G, WTF
 105+ try:
61106 self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1242)
62107 if self.dev and generation in [0, 3] and type in [0, 2]:
63108 self.dev.set_configuration(1)
@@ -65,6 +110,7 @@
66111 print("Connected to iPod Nano 3G WTF mode, USB version %s" % self.dev.bcdDevice)
67112 return
68113 except usb.core.USBError: pass
 114+ # iPod Classic 1G, WTF
69115 try:
70116 self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1241)
71117 if self.dev and generation in [0, 11] and type in [0, 2]:
@@ -74,6 +120,7 @@
75121 print("Connected to iPod Classic 1G WTF mode, USB version %s" % self.dev.bcdDevice)
76122 return
77123 except usb.core.USBError: pass
 124+ # iPod Classic 2G, WTF
78125 try:
79126 self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1245)
80127 if self.dev and generation in [0, 12] and type in [0, 2]:
@@ -83,6 +130,7 @@
84131 print("Connected to iPod Classic 2G WTF mode, USB version %s" % self.dev.bcdDevice)
85132 return
86133 except usb.core.USBError: pass
 134+ # iPod Classic 3G, WTF
87135 try:
88136 self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1247)
89137 if self.dev and generation in [0, 13] and type in [0, 2]:
@@ -92,24 +140,36 @@
93141 print("Connected to iPod Classic 3G WTF mode, USB version %s" % self.dev.bcdDevice)
94142 return
95143 except usb.core.USBError: pass
 144+ # iPod Nano 4G, WTF
96145 try:
97 - self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1225)
98 - if self.dev and generation in [0, 4] and type in [0, 1]:
 146+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
 147+ if self.dev and generation in [0, 4] and type in [0, 2]:
99148 self.dev.set_configuration(1)
100149 self.generation = 4;
101 - self.type = 1;
102 - print("Connected to S5L8720 Bootrom DFU mode, USB version %s" % self.dev.bcdDevice)
 150+ self.type = 2;
 151+ print("Connected to iPod Nano 4G WTF mode, USB version %s" % self.dev.bcdDevice)
103152 return
104153 except usb.core.USBError: pass
 154+ # iPod Nano 5G, WTF
105155 try:
106156 self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
107 - if self.dev and generation in [0, 4] and type in [0, 2]:
 157+ if self.dev and generation in [0, 5] and type in [0, 2]:
108158 self.dev.set_configuration(1)
109 - self.generation = 4;
 159+ self.generation = 5;
110160 self.type = 2;
111 - print("Connected to iPod Nano 4G WTF mode, USB version %s" % self.dev.bcdDevice)
 161+ print("Connected to iPod Nano 5G WTF mode, USB version %s" % self.dev.bcdDevice)
112162 return
113163 except usb.core.USBError: pass
 164+ # iPod Nano 6G, WTF
 165+ try:
 166+ self.dev = usb.core.find(idVendor=0x05ac, idProduct=0x1243)
 167+ if self.dev and generation in [0, 6] and type in [0, 2]:
 168+ self.dev.set_configuration(1)
 169+ self.generation = 6;
 170+ self.type = 2;
 171+ print("Connected to iPod Nano 6G WTF mode, USB version %s" % self.dev.bcdDevice)
 172+ return
 173+ except usb.core.USBError: pass
114174
115175 raise Exception("Could not find specified DFU device (generation = %d, type = %d)" % (generation, type))
116176
Index: tools/ipoddfu_c/usb.c
@@ -97,7 +97,7 @@
9898 if (0x05ac == dev_desc.idVendor && (
9999 // DFU
100100 0x1220 == dev_desc.idProduct || // iPod Nano 2G
101 - 0x1223 == dev_desc.idProduct || // iPod Classic 1G
 101+ 0x1223 == dev_desc.idProduct || // iPod Nano 3G and iPod Classic 1G/2G/3G
102102 0x1224 == dev_desc.idProduct || // iPod Nano 3G
103103 0x1225 == dev_desc.idProduct || // iPod Nano 4G
104104 0x1231 == dev_desc.idProduct || // iPod Nano 5G