Skip to content

Commit b3bdc75

Browse files
committed
Fix #1099
This change provides much friendler error messages in event of device id mismatches
1 parent e23abb4 commit b3bdc75

3 files changed

Lines changed: 128 additions & 133 deletions

File tree

Lines changed: 120 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,123 @@
11
avrid_to_name = {
2-
2003235 : "tn202",
3-
2003234 : "tn204",
4-
2003233 : "tn212",
5-
2003232 : "tn214",
6-
2003495 : "tn402",
7-
2003494 : "tn404",
8-
2003493 : "tn406",
9-
2003491 : "tn412",
10-
2003490 : "tn414",
11-
2003489 : "tn416",
12-
2003488 : "tn417",
13-
2003500 : "tn424",
14-
2003499 : "tn426",
15-
2003498 : "tn427",
16-
2003749 : "tn804",
17-
2003748 : "tn806",
18-
2003747 : "tn807",
19-
2003746 : "tn814",
20-
2003745 : "tn816",
21-
2003744 : "tn817",
22-
2003753 : "tn824",
23-
2003752 : "tn826",
24-
2003751 : "tn827",
25-
2004005 : "tn1604",
26-
2004004 : "tn1606",
27-
2004003 : "tn1607",
28-
2004002 : "tn1614",
29-
2004001 : "tn1616",
30-
2004000 : "tn1617",
31-
2004010 : "tn1624",
32-
2004009 : "tn1626",
33-
2004008 : "tn1627",
34-
2004257 : "tn3216",
35-
2004258 : "tn3217",
36-
2004264 : "tn3224",
37-
2004263 : "tn3226",
38-
2004262 : "tn3227",
39-
2003750 : "m808",
40-
2003754 : "m809",
41-
2004007 : "m1608",
42-
2004006 : "m1609",
43-
2004272 : "m3208",
44-
2004273 : "m3209",
45-
2004560 : "m4808",
46-
2004561 : "m4809",
47-
2004276 : "avr32da28",
48-
2004275 : "avr32da32",
49-
2004274 : "avr32da48",
50-
2004279 : "avr32db28",
51-
2004278 : "avr32db32",
52-
2004277 : "avr32db48",
53-
2004501 : "avr64da28",
54-
2004500 : "avr64da32",
55-
2004499 : "avr64da48",
56-
2004498 : "avr64da64",
57-
2004505 : "avr64db28",
58-
2004504 : "avr64db32",
59-
2004503 : "avr64db48",
60-
2004502 : "avr64db64",
61-
2004746 : "avr128da28",
62-
2004745 : "avr128da32",
63-
2004744 : "avr128da48",
64-
2004743 : "avr128da64",
65-
2004750 : "avr128db28",
66-
2004749 : "avr128db32",
67-
2004748 : "avr128db48",
68-
2004747 : "avr128db64",
69-
2004017 : "avr16dd32",
70-
2004018 : "avr16dd28",
71-
2004019 : "avr16dd20",
72-
2004020 : "avr16dd14",
73-
2004509 : "avr64dd14",
74-
2004508 : "avr64dd20",
75-
2004507 : "avr64dd28",
76-
2004506 : "avr64dd32",
77-
2004283 : "avr32dd14",
78-
2004282 : "avr32dd20",
79-
2004281 : "avr32dd28",
80-
2004280 : "avr32dd32",
81-
2003967 : "avr8ea28",
82-
2003967 : "avr8ea32",
83-
2003967 : "avr8ea48",
84-
2004023 : "avr16ea28",
85-
2004022 : "avr16ea32",
86-
2004021 : "avr16ea48",
87-
2004286 : "avr32ea28",
88-
2004285 : "avr32ea32",
89-
2004284 : "avr32ea48",
90-
2004512 : "avr64ea28",
91-
2004511 : "avr64ea32",
92-
2004510 : "avr64ea48",
93-
2004027 : "avr16du14",
94-
2004026 : "avr16du20",
95-
2004025 : "avr16du28",
96-
2004024 : "avr16du32",
97-
2004290 : "avr32du14",
98-
2004289 : "avr32du20",
99-
2004288 : "avr32du28",
100-
2004287 : "avr32du32",
101-
2004514 : "avr64du28",
102-
2004513 : "avr64du32",
103-
2003771 : "avr8eb14",
104-
2003770 : "avr8eb20",
105-
2003769 : "avr8eb28",
106-
2003768 : "avr8eb32",
107-
2004038 : "avr16eb14",
108-
2004037 : "avr16eb20",
109-
2004036 : "avr16eb28",
110-
2004035 : "avr16eb32",
111-
2004262 : "avr32eb14",
112-
2004261 : "avr32eb20",
113-
2004260 : "avr32eb28",
114-
2004259 : "avr32eb32",
115-
2004276 : "avr32da28s",
116-
2004275 : "avr32da32s",
117-
2004274 : "avr32da48s",
118-
2004526 : "avr64da28s",
119-
2004525 : "avr64da32s",
120-
2004524 : "avr64da48s",
121-
2004523 : "avr64da64s",
122-
2004751 : "avr128da64s",
123-
2004752 : "avr128da48s",
124-
2004753 : "avr128da32s",
125-
2004754 : "avr128da28s",
126-
2004306 : "avr32sd32",
127-
2004307 : "avr32sd28",
128-
2004308 : "avr32sd20"
2+
2003235 : "ATtiny202",
3+
2003234 : "ATtiny204",
4+
2003233 : "ATtiny212",
5+
2003232 : "ATtiny214",
6+
2003495 : "ATtiny402",
7+
2003494 : "ATtiny404",
8+
2003493 : "ATtiny406",
9+
2003491 : "ATtiny412",
10+
2003490 : "ATtiny414",
11+
2003489 : "ATtiny416",
12+
2003488 : "ATtiny417",
13+
2003500 : "ATtiny424",
14+
2003499 : "ATtiny426",
15+
2003498 : "ATtiny427",
16+
2003749 : "ATtiny804",
17+
2003748 : "ATtiny806",
18+
2003747 : "ATtiny807",
19+
2003746 : "ATtiny814",
20+
2003745 : "ATtiny816",
21+
2003744 : "ATtiny817",
22+
2003753 : "ATtiny824",
23+
2003752 : "ATtiny826",
24+
2003751 : "ATtiny827",
25+
2004005 : "ATtiny1604",
26+
2004004 : "ATtiny1606",
27+
2004003 : "ATtiny1607",
28+
2004002 : "ATtiny1614",
29+
2004001 : "ATtiny1616",
30+
2004000 : "ATtiny1617",
31+
2004010 : "ATtiny1624",
32+
2004009 : "ATtiny1626",
33+
2004008 : "ATtiny1627",
34+
2004257 : "ATtiny3216",
35+
2004258 : "ATtiny3217",
36+
2004264 : "ATtiny3224",
37+
2004263 : "ATtiny3226",
38+
2004262 : "ATtiny3227",
39+
2003750 : "ATmegA808",
40+
2003754 : "ATmegA809",
41+
2004007 : "ATmegA1608",
42+
2004006 : "ATmegA1609",
43+
2004272 : "ATmegA3208",
44+
2004273 : "ATmegA3209",
45+
2004560 : "ATmegA4808",
46+
2004561 : "ATmegA4809",
47+
2004276 : "AVR32DA28",
48+
2004275 : "AVR32DA32",
49+
2004274 : "AVR32DA48",
50+
2004279 : "AVR32DB28",
51+
2004278 : "AVR32DB32",
52+
2004277 : "AVR32DB48",
53+
2004501 : "AVR64DA28",
54+
2004500 : "AVR64DA32",
55+
2004499 : "AVR64DA48",
56+
2004498 : "AVR64DA64",
57+
2004505 : "AVR64DB28",
58+
2004504 : "AVR64DB32",
59+
2004503 : "AVR64DB48",
60+
2004502 : "AVR64DB64",
61+
2004746 : "AVR128DA28",
62+
2004745 : "AVR128DA32",
63+
2004744 : "AVR128DA48",
64+
2004743 : "AVR128DA64",
65+
2004750 : "AVR128DB28",
66+
2004749 : "AVR128DB32",
67+
2004748 : "AVR128DB48",
68+
2004747 : "AVR128DB64",
69+
2004017 : "AVR16Dd32",
70+
2004018 : "AVR16Dd28",
71+
2004019 : "AVR16Dd20",
72+
2004020 : "AVR16Dd14",
73+
2004509 : "AVR64Dd14",
74+
2004508 : "AVR64Dd20",
75+
2004507 : "AVR64Dd28",
76+
2004506 : "AVR64Dd32",
77+
2004283 : "AVR32Dd14",
78+
2004282 : "AVR32Dd20",
79+
2004281 : "AVR32Dd28",
80+
2004280 : "AVR32Dd32",
81+
2004023 : "AVR16EA28",
82+
2004022 : "AVR16EA32",
83+
2004021 : "AVR16EA48",
84+
2004286 : "AVR32EA28",
85+
2004285 : "AVR32EA32",
86+
2004284 : "AVR32EA48",
87+
2004512 : "AVR64EA28",
88+
2004511 : "AVR64EA32",
89+
2004510 : "AVR64EA48",
90+
2004027 : "AVR16DU14",
91+
2004026 : "AVR16DU20",
92+
2004025 : "AVR16DU28",
93+
2004024 : "AVR16DU32",
94+
2004290 : "AVR32DU14",
95+
2004289 : "AVR32DU20",
96+
2004288 : "AVR32DU28",
97+
2004287 : "AVR32DU32",
98+
2004514 : "AVR64DU28",
99+
2004513 : "AVR64DU32",
100+
2004038 : "AVR16EB14",
101+
2004037 : "AVR16EB20",
102+
2004036 : "AVR16EB28",
103+
2004035 : "AVR16EB32",
104+
2004262 : "AVR32EB14",
105+
2004261 : "AVR32EB20",
106+
2004260 : "AVR32EB28",
107+
2004259 : "AVR32EB32",
108+
2004276 : "AVR32DA28S",
109+
2004275 : "AVR32DA32S",
110+
2004274 : "AVR32DA48S",
111+
2004526 : "AVR64DA28S",
112+
2004525 : "AVR64DA32S",
113+
2004524 : "AVR64DA48S",
114+
2004523 : "AVR64DA64S",
115+
2004751 : "AVR128DA64S",
116+
2004752 : "AVR128DA48S",
117+
2004753 : "AVR128DA32S",
118+
2004754 : "AVR128DA28S",
119+
2004306 : "AVR32SD32",
120+
2004307 : "AVR32SD28",
121+
2004308 : "AVR32SD20"
129122

130123
}

megaavr/tools/libs/pymcuprog/nvmserialupdi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,22 @@ def read_device_id(self):
8282
self.logger.error("ID read ('%06X') does not match expected device id! ('%06X')", device_id_read, self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID))
8383
if device_id_read in avrid_to_name:
8484
if self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID) in avrid_to_name:
85-
raise ValueError("Device ID does not match - Expected: "+avrid_to_name[self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID)]+"Found: "+avrid_to_name(device_id_read))
85+
raise ValueError("Expected: "+avrid_to_name[self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID)]+" Instead, found: "+avrid_to_name[device_id_read]+". Check tools -> chip selection & identity of part")
8686
else:
87-
raise ValueError("Device ID does not match - Expected part cannot be identified by SerialUPDI, this is a bug, please report it. Found: "+avrid_to_name(device_id_read))
87+
raise ValueError("Internal error determining expected part name. This is a bug, please report it. Found: "+avrid_to_name[device_id_read])
8888
else:
8989
if self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID) in avrid_to_name:
90-
raise ValueError("Device ID does not match - Expected: "+avrid_to_name[self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID)]+"Found: Unrecognized ID")
90+
raise ValueError("Expected: "+avrid_to_name[self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID)]+" ID returned by part unknown to SerailUPDI")
9191
else:
92-
raise ValueError("Device ID does not match - Additionally, the SerialUPDI hackjob to get human readable part names isn't working")
92+
raise ValueError("Neither expected nor found part IDs are recognized by SeralUPDI, yet the number above was returned")
9393

9494
"""
9595
Jesus that is hideous!
9696
9797
Yeah, we imported a list culled from the IO headers (find in files in sublime to get the line with the signature bytes in it, copy results to a new file, use regexes to snip out everything except the file name (subliume includes this in fine in files output)
9898
More regexe to get only the six hex characters of the sig in a row and the name, with a comma between it. Save as .txt
9999
Open with excel, delimited, comma. Before exiting the import dialog, the format for the column containing hexadecimal values had to be set to "text" to prevent it from trashing them. complete the import dialog, hex2dec() in a third column, to get numeric valies
100-
copy/paste back into sublime to postprocess with regexes to yield the proper syntax for a python dictionary, indexed by the numeric representation. They're all around 2 million
100+
copy/paste back into sublime to postprocess with regexes to yield the proper syntax for a python dictionary, indexed by the numeric representation. They're all around 2 million
101101
"""
102102
revision = self.avr.read_data(self.device_info.get(DeviceInfoKeysAvr.SYSCFG_BASE) + 1, 1)
103103
self.logger.info("Device revision: '%s'", chr(revision[0] + ord('A')))

megaavr/tools/prog.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ def pymcuprog_basic(args, fuses_dict):
214214

215215
try:
216216
pymcu._action_ping(backend)
217-
except ValueError:
217+
except ValueError as e:
218+
# Print the error message
219+
print(f"Error: {e}")
218220
print("Device ID mismatch! Stopping.")
219221
backend.end_session()
220222
backend.disconnect_from_tool()

0 commit comments

Comments
 (0)