Sat, 10 Jul 2021 16:35:26 +0200
Extended the list of known CircuitPython and UF2 capable devices.
8096 | 1 | # -*- coding: utf-8 -*- |
2 | ||
3 | # Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de> | |
4 | # | |
5 | ||
6 | """ | |
7 | Module implementing a dialog to flash any UF2 capable device. | |
8 | """ | |
9 | ||
10 | import os | |
11 | import shutil | |
8243
cc717c2ae956
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8222
diff
changeset
|
12 | import contextlib |
8096 | 13 | |
14 | from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication, QThread, QEventLoop | |
15 | from PyQt5.QtWidgets import QDialog | |
16 | ||
17 | from E5Gui.E5PathPicker import E5PathPickerModes | |
18 | ||
19 | from .Ui_UF2FlashDialog import Ui_UF2FlashDialog | |
20 | ||
21 | import UI.PixmapCache | |
22 | import Utilities | |
23 | ||
24 | from . import MicroPythonDevices | |
25 | ||
26 | SupportedUF2Boards = { | |
27 | "circuitpython": { | |
28 | "volumes": { | |
29 | (0x03EB, 0x2402): [ | |
30 | "SAMD21", # SAMD21 Board | |
31 | "SAME54", # SAME54 Board | |
32 | ], | |
33 | (0x04D8, 0xEC44): [ | |
34 | "PYCUBEDBOOT", # PyCubedv04 | |
35 | ], | |
36 | (0x04D8, 0xEC63): [ | |
37 | "BOOT", # CircuitBrains Basic | |
38 | ], | |
39 | (0x04D8, 0xEC64): [ | |
40 | "BOOT", # CircuitBrains Deluxe | |
41 | ], | |
42 | (0x04D8, 0xED5F): [ | |
43 | "UCHIPYBOOT", # uChip CircuitPython | |
44 | ], | |
45 | (0x04D8, 0xEDB3): [ | |
46 | "USBHUBBOOT", # Programmable USB Hub | |
47 | ], | |
48 | (0x04D8, 0xEDBE): [ | |
49 | "SAM32BOOT", # SAM32 | |
50 | ], | |
51 | (0x04D8, 0xEF66): [ | |
52 | "SENSEBOX", # senseBox MCU | |
53 | ], | |
54 | (0x1209, 0x2017): [ | |
55 | "MINISAMBOOT", # Mini SAM M4 | |
56 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
57 | (0x1209, 0x3252): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
58 | "MCBS2OMBOOT", # Module Clip w/Wroom |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
59 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
60 | (0x1209, 0x3253): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
61 | "MCBS2ERBOOT", # Module Clip w/Wrover |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
62 | ], |
8096 | 63 | (0x1209, 0x4D44): [ |
64 | "ROBOM0BOOT", # Robo HAT MM1 | |
65 | "ROBOM4BOOT", # Robo HAT MM1 M4 | |
66 | ], | |
67 | (0x1209, 0x4DDD): [ | |
68 | "SapBOOT", # CP Sapling | |
69 | ], | |
70 | (0x1209, 0x7102): [ | |
71 | "MINISAMBOOT", # Mini SAM M0 | |
72 | ], | |
73 | (0x1209, 0x805A): [ | |
74 | "BASTBLE", # Bast BLE | |
75 | ], | |
76 | (0x1209, 0xE3E2): [ | |
77 | "StackRduino", # StackRduino M0 PRO | |
78 | ], | |
79 | (0x1209, 0xF501): [ | |
80 | "M4SHIMBOOT", # M4-Shim | |
81 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
82 | (0x15BA, 0x28DC): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
83 | "OLMLIPOBOOT", # ESP32S2 DevKit Lipo |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
84 | ], |
8096 | 85 | (0x16D0, 0x0CDA): [ |
86 | "AUTOMAT", # automat | |
87 | ], | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
88 | (0x1B4F, 0x0022): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
89 | "SFMM852BOOT", # MicroMod nRF52840 |
8096 | 90 | ], |
91 | (0x1B4F, 0x0D22): [ | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
92 | "SPARKFUN", # SAMD21 Mini Breakout |
8096 | 93 | ], |
94 | (0x1B4F, 0x0D23): [ | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
95 | "SPARKFUN", # SAMD21 Dev Breakout |
8096 | 96 | ], |
97 | (0x1D50, 0x6110): [ | |
98 | "ROBOTICS", # Robotics | |
99 | ], | |
100 | (0x1D50, 0x6112): [ | |
101 | "RCBOOT", # Wattuino RC | |
102 | ], | |
103 | (0x1D50, 0x6160): [ | |
104 | "BLUEMICRO", # BlueMicro | |
105 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
106 | (0x1FC9, 0x0094): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
107 | "DblM33BOOT", # Double M33 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
108 | "LPC5528BOOT", # LPCXpresso 55s28 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
109 | "LPC5569BOOT", # LPCXpresso 55s69 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
110 | ], |
8096 | 111 | (0x230A, 0x00E9): [ |
112 | "TAU_BOOT", # Tau | |
113 | ], | |
114 | (0x2341, 0x0057): [ | |
115 | "NANOBOOT", # NANO 33 IoT | |
116 | ], | |
117 | (0x2341, 0x8053): [ | |
118 | "MKR1300", # MKR1300 | |
119 | ], | |
120 | (0x239A, 0x000F): [ | |
121 | "ITSYBOOT", # ItsyBitsy M0 Express | |
122 | ], | |
123 | (0x239A, 0x0013): [ | |
124 | "METROBOOT", # Metro M0 | |
125 | ], | |
126 | (0x239A, 0x0015): [ | |
127 | "FEATHERBOOT", # Feather M0 | |
128 | ], | |
129 | (0x239A, 0x0018): [ | |
130 | "CPLAYBOOT", # CPlay Express | |
131 | ], | |
132 | (0x239A, 0x001B): [ | |
133 | "FEATHERBOOT", # Feather M0 Express | |
134 | ], | |
135 | (0x239A, 0x001C): [ | |
136 | "GEMMABOOT", # Gemma M0 | |
137 | ], | |
138 | (0x239A, 0x001E): [ | |
139 | "TRINKETBOOT", # Trinket M0 | |
140 | ], | |
141 | (0x239A, 0x0021): [ | |
142 | "METROM4BOOT", # Metro M4 Express | |
143 | ], | |
144 | (0x239A, 0x0022): [ | |
145 | "ARCADE-D5", # Feather Arcade D51 | |
146 | "FEATHERBOOT", # Feather M4 Express | |
147 | ], | |
148 | (0x239A, 0x0024): [ | |
149 | "RADIOBOOT", # Radiofruit M0 | |
150 | ], | |
151 | (0x239A, 0x0027): [ | |
152 | "PIRKEYBOOT", # pIRKey M0 | |
153 | ], | |
154 | (0x239A, 0x0029): [ | |
155 | "ARGONBOOT ", # Argon | |
156 | "BORONBOOT ", # Boron | |
157 | "FTHR840BOOT", # Feather nRF52840 Express | |
158 | "MDK840DONGL", # MDK nRF52840 USB Dongle | |
159 | "WS52840EVK", # Waveshare nRF52840 Eval | |
160 | "XENONBOOT ", # Xenon | |
161 | ], | |
162 | (0x239A, 0x002B): [ | |
163 | "ARCADE-D5", # Itsy Arcade D51 | |
164 | "ITSYM4BOOT", # ItsyBitsy M4 Express | |
165 | ], | |
166 | (0x239A, 0x002D): [ | |
167 | "CRICKITBOOT", # crickit | |
168 | ], | |
169 | (0x239A, 0x002F): [ | |
170 | "TRELM4BOOT", # Trellis M4 Express | |
171 | ], | |
172 | (0x239A, 0x0031): [ | |
173 | "GCM4BOOT", # Grand Central M4 Express | |
174 | ], | |
175 | (0x239A, 0x0033): [ | |
176 | "PYBADGEBOOT", # PyBadge | |
177 | ], | |
178 | (0x239A, 0x0034): [ | |
179 | "BADGELCBOOT", # BadgeLC | |
180 | "PEWBOOT", # PewPew | |
181 | ], | |
182 | (0x239A, 0x0035): [ | |
183 | "MKRZEROBOOT", # MKRZero | |
184 | "PORTALBOOT", # PyPortal M4 Express | |
185 | ], | |
186 | (0x239A, 0x0037): [ | |
187 | "METROM4BOOT", # Metro M4 AirLift | |
188 | ], | |
189 | (0x239A, 0x003D): [ | |
190 | "PYGAMERBOOT", # PyGamer | |
191 | ], | |
192 | (0x239A, 0x003F): [ | |
193 | "METR840BOOT", # Metro nRF52840 Express | |
194 | ], | |
195 | (0x239A, 0x0045): [ | |
196 | "CPLAYBTBOOT", # Circuit Playground nRF52840 | |
197 | ], | |
198 | (0x239A, 0x0047): [ | |
199 | "MASKM4BOOT", # Hallowing Mask M4 | |
200 | ], | |
201 | (0x239A, 0x0049): [ | |
202 | "HALLOM4BOOT", # HalloWing M4 | |
203 | ], | |
204 | (0x239A, 0x004D): [ | |
205 | "SNEKBOOT", # snekboard | |
206 | ], | |
207 | (0x239A, 0x0051): [ | |
208 | "ITSY840BOOT", # ItsyBitsy nRF52840 Express | |
209 | ], | |
210 | (0x239A, 0x0057): [ | |
211 | "SERPENTBOOT", # Serpente | |
212 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
213 | (0x239A, 0x0059): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
214 | "FTHR405BOOT", # Feather STM32F405 Express |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
215 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
216 | (0x239A, 0x005D): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
217 | "BlackPill", # STM32F401CxUx |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
218 | "STMF411BOOT", # STM32F411 Discovery |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
219 | ], |
8096 | 220 | (0x239A, 0x0061): [ |
221 | "SOLBOOT", # Sol | |
222 | ], | |
223 | (0x239A, 0x0063): [ | |
224 | "NANO33BOOT", # Nano 33 BLE | |
225 | ], | |
226 | (0x239A, 0x0065): [ | |
227 | "ND6BOOT", # ndBit6 | |
228 | ], | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
229 | (0x239A, 0x0069): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
230 | "STMF411BOOT", # STM32F411 BlackPill |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
231 | ], |
8096 | 232 | (0x239A, 0x006B): [ |
233 | "shIRtty", # shIRtty | |
234 | ], | |
235 | (0x239A, 0x0071): [ | |
236 | "CLUEBOOT", # CLUE nRF52840 | |
237 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
238 | (0x239A, 0x0077): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
239 | "RT1010BOOT", # RT1010 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
240 | ], |
8096 | 241 | (0x239A, 0x0079): [ |
242 | "ARAMBOOT", # ARAMCON Badge 2019 | |
243 | ], | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
244 | (0x239A, 0x007B): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
245 | "ARAMBOOT", # ARAMCON2 Badge |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
246 | ], |
8096 | 247 | (0x239A, 0x007D): [ |
248 | "BOOKBOOT", # The Open Book Feather | |
249 | ], | |
250 | (0x239A, 0x007F): [ | |
251 | "BADGEBOOT", # OHS2020 Badge | |
252 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
253 | (0x239A, 0x0081): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
254 | "RT1020BOOT", # RT1020 EVK |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
255 | "RT1024BOOT", # RT1024 EVK |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
256 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
257 | (0x239A, 0x0083): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
258 | "RT1060BOOT", # RT1060 EVK |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
259 | "RT1064BOOT", # RT1064 EVK |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
260 | ], |
8096 | 261 | (0x239A, 0x0087): [ |
262 | "FTHRSNSBOOT", # Feather nRF52840 Sense | |
263 | ], | |
264 | (0x239A, 0x0093): [ | |
265 | "ISVITABoot", # IkigaiSense Vita nRF52840 | |
266 | ], | |
267 | (0x239A, 0x0095): [ | |
268 | "UARTLOGBOOT", # UARTLogger II | |
269 | ], | |
270 | (0x239A, 0x009F): [ | |
271 | "ADM840BOOT", # AtelierDuMaker NRF52840 Breakout | |
272 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
273 | (0x239A, 0x00A5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
274 | "SAOLA1RBOOT", # Saola 1R WROVER |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
275 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
276 | (0x239A, 0x00A7): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
277 | "SAOLA1MBOOT", # Saola 1M WROOM |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
278 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
279 | (0x239A, 0x00AB): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
280 | "UFTHRS2BOOT", # FeatherS2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
281 | ], |
8096 | 282 | (0x239A, 0x00AF): [ |
283 | "FLUFFBOOT", # Fluff M0 | |
284 | ], | |
285 | (0x239A, 0x00B3): [ | |
286 | "NICENANO", # nice!nano | |
287 | ], | |
288 | (0x239A, 0x00B5): [ | |
289 | "E54XBOOT", # SAME54 Xplained | |
290 | ], | |
291 | (0x239A, 0x00B9): [ | |
292 | "ND7BOOT", # ndBit7 | |
293 | ], | |
294 | (0x239A, 0x00BF): [ | |
295 | "BADGEBOOT", # BLM Badge | |
296 | ], | |
297 | (0x239A, 0x00C3): [ | |
298 | "GEMINIBOOT", # Gemini | |
299 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
300 | (0x239A, 0x00C5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
301 | "MICROS2BOOT", # microS2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
302 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
303 | (0x239A, 0x00C7): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
304 | "KALUGA1BOOT", # Kaluga 1 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
305 | ], |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
306 | (0x239A, 0x00C9): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
307 | "MATRIXBOOT", # Matrix Portal M4 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
308 | ], |
8096 | 309 | (0x239A, 0x00CB): [ |
310 | "QTPY_BOOT", # QT Py M0 | |
311 | ], | |
312 | (0x239A, 0x00CD): [ | |
313 | "FTHRCANBOOT", # Feather M4 CAN Express | |
314 | ], | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
315 | (0x239A, 0x00DE): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
316 | "NANOESPBOOT", # nanoESP32-S2 WROOM |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
317 | ], |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
318 | (0x239A, 0x00DF): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
319 | "METROS2BOOT", # Metro ESP32-S2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
320 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
321 | (0x239A, 0x00E1): [ |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
322 | "METROM7BOOT", # Metro M7 iMX RT1011 |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
323 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
324 | (0x239A, 0x00E5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
325 | "MAGTAGBOOT", # Metro MagTag 2.9 Grayscale |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
326 | "MAGTAGBOOT", # MagTag 2.9 Grayscale |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
327 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
328 | (0x239A, 0x00EB): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
329 | "FTHRS2BOOT", # Feather ESP32-S2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
330 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
331 | (0x239A, 0x00ED): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
332 | "FTHRS2BOOT", # Feather ESP32-S2 Reverse TFT |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
333 | ], |
8096 | 334 | (0x239A, 0x00EF): [ |
335 | "TRINKEYBOOT", # NeoPixel Trinkey M0 | |
336 | ], | |
337 | (0x239A, 0x00F5): [ | |
338 | "STARBOOT", # Binary Star | |
339 | ], | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
340 | (0x239A, 0x00F9): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
341 | "HOUSEBOOT", # FunHouse |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
342 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
343 | (0x239A, 0x00FB): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
344 | "TRINKEYBOOT", # Rotary Trinkey M0 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
345 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
346 | (0x239A, 0x00FF): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
347 | "TRINKEYBOOT", # NeoKey Trinkey M0 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
348 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
349 | (0x239A, 0x0101): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
350 | "TRINKEYBOOT", # Slide Trinkey M0 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
351 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
352 | (0x239A, 0x0103): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
353 | "TRINKEYBOOT", # ProxSense Trinkey M0 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
354 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
355 | (0x239A, 0x010B): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
356 | "MDBT50QBOOT", # Raytac MDBT50Q-RX |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
357 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
358 | (0x239A, 0x800B): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
359 | "ATMZBOOT", # ATMegaZero ESP32-S2 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
360 | ], |
8096 | 361 | (0x239A, 0xB000): [ |
362 | "HALLOWBOOT", # Hallowing M0 | |
363 | ], | |
364 | (0x239A, 0xE005): [ | |
365 | "HONKBOOT", # Big Honking Button | |
366 | ], | |
367 | (0x2886, 0x000D): [ | |
368 | "Grove Zero", # Grove Zero | |
369 | ], | |
370 | (0x2886, 0x002F): [ | |
371 | "Seeed XIAO", # Seeeduino XIAO | |
372 | ], | |
373 | (0x2886, 0xF00E): [ | |
374 | "PITAYAGO", # Pitaya Go | |
375 | ], | |
376 | (0x2886, 0xF00F): [ | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
377 | "M60KEYBOARD", # MakerDiary M60 Mechanical Keyboard |
8096 | 378 | "nRF52840M2", # MakerDiary nRF52840 M.2 Module |
379 | ], | |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
380 | (0x303A, 0x8005): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
381 | "TINYS2BOOT", # TinyS2 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
382 | ], |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
383 | (0x303A, 0x8008): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
384 | "TTGOS2BOOT", # TTGO_T8_S2_Display |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
385 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
386 | (0x303A, 0x800E): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
387 | "CCMBRISBOOT", # CucumberRIS v1.1 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
388 | ], |
8461
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
389 | (0x303A, 0x80B0): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
390 | "RD00RBOOT", # Reference Design RD00 |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
391 | ], |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
392 | (0x303A, 0x80B3): [ |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
393 | "NANOESPBOOT", # nanoESP32-S2 WROVER |
d9fb4a0f2460
Extended the list of known CircuitPython and UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
394 | ], |
8096 | 395 | (0x3171, 0x0100): [ |
396 | "CMDBOOT", # COMMANDER | |
397 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
398 | (0xCAFE, 0xFFFF): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
399 | "F303BOOT", # STM32F303 Discovery |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
400 | ], |
8096 | 401 | }, |
402 | "instructions": QCoreApplication.translate( | |
403 | "UF2FlashDialog", | |
404 | "<h3>CircuitPython Board</h3>" | |
405 | "<p>In order to prepare the board for flashing follow these" | |
406 | " steps:</p><ol>" | |
407 | "<li>Switch your device to 'bootloader' mode by double-pressing" | |
408 | " the reset button.</li>" | |
409 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
410 | "<li>(If this does not happen, then try shorter or longer" | |
411 | " pauses between presses.)</li>" | |
412 | "<li>Ensure the boot volume is available (this may require" | |
413 | " mounting it).</li>" | |
414 | "<li>Select the firmware file to be flashed and click the" | |
415 | " flash button.</li>" | |
416 | "</ol>" | |
417 | ), | |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
418 | "show_all": True, |
8096 | 419 | "firmware": "CircuitPython", |
420 | }, | |
421 | ||
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
422 | "circuitpython_rp2040": { |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
423 | "volumes": { |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
424 | (0x239A, 0x80F4): [ |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
425 | "RPI-RP2", # Raspberry Pi Pico loaded with CircuitPython |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
426 | ], |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
427 | }, |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
428 | "instructions": QCoreApplication.translate( |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
429 | "UF2FlashDialog", |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
430 | "<h3>Pi Pico (RP2040) Board</h3>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
431 | "<p>In order to prepare the board for flashing follow these" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
432 | " steps:</p><ol>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
433 | "<li>Enter 'bootloader' mode (board <b>without</b> RESET button):" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
434 | "<ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
435 | "<li>Plug in your board while holding the BOOTSEL button.</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
436 | "</ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
437 | "Enter 'bootloader' mode (board <b>with</b> RESET button):" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
438 | "<ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
439 | "<li>hold down RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
440 | "<li>hold down BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
441 | "<li>release RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
442 | "<li>release BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
443 | "</ul></li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
444 | "<li>Wait until the device has entered 'bootloader' mode.</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
445 | "<li>Ensure the boot volume is available (this may require" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
446 | " mounting it).</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
447 | "<li>Select the firmware file to be flashed and click the" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
448 | " flash button.</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
449 | "</ol>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
450 | ), |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
451 | "show_all": False, |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
452 | "firmware": "CircuitPython", |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
453 | }, |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
454 | |
8096 | 455 | "rp2040": { |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
456 | "volumes": { |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
457 | (0x0000, 0x0000): [ |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
458 | "RPI-RP2", # Raspberry Pi Pico does not present a TTY |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
459 | ], |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
460 | }, |
8096 | 461 | "instructions": QCoreApplication.translate( |
462 | "UF2FlashDialog", | |
463 | "<h3>Pi Pico (RP2040) Board</h3>" | |
464 | "<p>In order to prepare the board for flashing follow these" | |
465 | " steps:</p><ol>" | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
466 | "<li>Enter 'bootloader' mode (board <b>without</b> RESET button):" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
467 | "<ul>" |
8096 | 468 | "<li>Plug in your board while holding the BOOTSEL button.</li>" |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
469 | "</ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
470 | "Enter 'bootloader' mode (board <b>with</b> RESET button):" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
471 | "<ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
472 | "<li>hold down RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
473 | "<li>hold down BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
474 | "<li>release RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
475 | "<li>release BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
476 | "</ul></li>" |
8096 | 477 | "<li>Wait until the device has entered 'bootloader' mode.</li>" |
478 | "<li>Ensure the boot volume is available (this may require" | |
479 | " mounting it).</li>" | |
480 | "<li>Select the firmware file to be flashed and click the" | |
481 | " flash button.</li>" | |
482 | "</ol>" | |
483 | ), | |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
484 | "show_all": True, |
8120
84928e9f446f
UF2FlashDialog: updated a string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8111
diff
changeset
|
485 | "firmware": "MicroPython / CircuitPython", |
8096 | 486 | }, |
487 | } | |
488 | ||
489 | ||
490 | def getFoundDevices(boardType=""): | |
491 | """ | |
492 | Function to get the list of known serial devices supporting UF2. | |
493 | ||
494 | @param boardType specific board type to search for | |
495 | @type str | |
496 | @return list of tuples with the board type, the port description, the | |
497 | VID and PID | |
498 | @rtype list of tuple of (str, str, int, int) | |
499 | """ | |
500 | from PyQt5.QtSerialPort import QSerialPortInfo | |
501 | ||
502 | foundDevices = [] | |
503 | ||
504 | availablePorts = QSerialPortInfo.availablePorts() | |
505 | for port in availablePorts: | |
506 | vid = port.vendorIdentifier() | |
507 | pid = port.productIdentifier() | |
508 | ||
509 | if vid == 0 and pid == 0: | |
510 | # no device detected at port | |
511 | continue | |
512 | ||
513 | for board in SupportedUF2Boards: | |
8222
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
514 | if ( |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
515 | (not boardType or (board.startswith(boardType))) and |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
516 | (vid, pid) in SupportedUF2Boards[board]["volumes"] |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
517 | ): |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
518 | foundDevices.append(( |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
519 | board, |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
520 | port.description(), |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
521 | (vid, pid), |
5994b80b8760
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
522 | )) |
8096 | 523 | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
524 | # second run for boards needing special treatment (e.g. RP2040) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
525 | for board in SupportedUF2Boards: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
526 | if not boardType or (board == boardType): |
8243
cc717c2ae956
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8222
diff
changeset
|
527 | with contextlib.suppress(KeyError): |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
528 | # find mounted volume |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
529 | volumes = SupportedUF2Boards[board]["volumes"][(0, 0)] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
530 | foundVolumes = [] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
531 | for volume in volumes: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
532 | foundVolumes += Utilities.findVolume(volume, findAll=True) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
533 | if foundVolumes: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
534 | foundDevices.append(( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
535 | board, |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
536 | QCoreApplication.translate( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
537 | "UF2FlashDialog", "'{0}' Board").format(board), |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
538 | (0, 0), # VID/PID of (0, 0) is special |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
539 | )) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
540 | |
8096 | 541 | return foundDevices |
542 | ||
543 | ||
544 | class UF2FlashDialog(QDialog, Ui_UF2FlashDialog): | |
545 | """ | |
546 | Class implementing a dialog to flash any UF2 capable device. | |
547 | """ | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8120
diff
changeset
|
548 | DeviceTypeRole = Qt.ItemDataRole.UserRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8120
diff
changeset
|
549 | DeviceVidPidRole = Qt.ItemDataRole.UserRole + 1 |
8096 | 550 | |
551 | def __init__(self, boardType="", parent=None): | |
552 | """ | |
553 | Constructor | |
554 | ||
555 | @param boardType specific board type to show the dialog for | |
556 | @type str | |
557 | @param parent reference to the parent widget (defaults to None) | |
558 | @type QWidget (optional) | |
559 | """ | |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8170
diff
changeset
|
560 | super().__init__(parent) |
8096 | 561 | self.setupUi(self) |
562 | ||
563 | self.refreshButton.setIcon(UI.PixmapCache.getIcon("rescan")) | |
564 | ||
565 | self.firmwarePicker.setMode(E5PathPickerModes.OpenFileMode) | |
566 | self.firmwarePicker.setFilters( | |
567 | self.tr("MicroPython/CircuitPython Files (*.uf2);;" | |
568 | "All Files (*)")) | |
569 | ||
570 | self.bootPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode) | |
571 | self.bootPicker.setEnabled(False) | |
572 | ||
573 | self.__mandatoryStyleSheet = ( | |
574 | "QLineEdit {border: 2px solid;border-color: #800000}" | |
575 | ) | |
576 | self.__manualType = "<manual>" | |
577 | ||
578 | self.__boardType = boardType | |
579 | ||
580 | self.__populate() | |
581 | ||
582 | self.__updateFlashButton() | |
583 | ||
584 | def __populate(self): | |
585 | """ | |
586 | Private method to (re-)populate the dialog. | |
587 | """ | |
588 | # save the currently selected device | |
589 | currentDevice = self.devicesComboBox.currentText() | |
590 | firmwareFile = self.firmwarePicker.text() | |
591 | ||
592 | # clear the entries first | |
593 | self.devicesComboBox.clear() | |
594 | self.firmwarePicker.clear() | |
595 | self.bootPicker.clear() | |
596 | self.infoLabel.clear() | |
597 | self.infoEdit.clear() | |
598 | ||
599 | # now populate the entries with data | |
600 | devices = getFoundDevices(boardType=self.__boardType) | |
601 | if len(devices) == 0: | |
602 | # no device detected | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
603 | devices = list(filter( |
8096 | 604 | lambda x: x[0] in SupportedUF2Boards, |
605 | MicroPythonDevices.getFoundDevices()[0] | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
606 | )) |
8096 | 607 | if devices: |
608 | self.__showSpecificInstructions(list(devices)) | |
609 | else: | |
610 | self.__showAllInstructions() | |
611 | self.devicesComboBox.addItem("") | |
612 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
613 | self.devicesComboBox.setItemData(1, self.__manualType, | |
614 | self.DeviceTypeRole) | |
615 | elif len(devices) == 1: | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
616 | # set the board type to the found one |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
617 | self.__boardType = devices[0][0] |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
618 | |
8096 | 619 | self.devicesComboBox.addItem(devices[0][1]) |
620 | self.devicesComboBox.setItemData( | |
621 | 0, devices[0][0], self.DeviceTypeRole) | |
622 | self.devicesComboBox.setItemData( | |
623 | 0, devices[0][2], self.DeviceVidPidRole) | |
624 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
625 | self.devicesComboBox.setItemData(1, self.__manualType, | |
626 | self.DeviceTypeRole) | |
627 | self.on_devicesComboBox_currentIndexChanged(0) | |
628 | else: | |
629 | self.devicesComboBox.addItem("") | |
630 | for index, (boardType, description, | |
631 | vidpid) in enumerate(sorted(devices), 1): | |
632 | self.devicesComboBox.addItem(description) | |
633 | self.devicesComboBox.setItemData( | |
634 | index, boardType, self.DeviceTypeRole) | |
635 | self.devicesComboBox.setItemData( | |
636 | index, vidpid, self.DeviceVidPidRole) | |
637 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
638 | self.devicesComboBox.setItemData(index + 1, self.__manualType, | |
639 | self.DeviceTypeRole) | |
640 | ||
641 | # reselect the remembered device, if it is still there | |
642 | if currentDevice: | |
643 | self.devicesComboBox.setCurrentText(currentDevice) | |
644 | self.firmwarePicker.setText(firmwareFile) | |
645 | else: | |
646 | self.devicesComboBox.setCurrentIndex(0) | |
647 | ||
648 | def __updateFlashButton(self): | |
649 | """ | |
650 | Private method to update the state of the Flash button and the retest | |
651 | button. | |
652 | """ | |
653 | firmwareFile = self.firmwarePicker.text() | |
654 | if self.devicesComboBox.currentData(self.DeviceTypeRole) is not None: | |
655 | if bool(firmwareFile) and os.path.exists(firmwareFile): | |
656 | self.firmwarePicker.setStyleSheet("") | |
657 | else: | |
658 | self.firmwarePicker.setStyleSheet(self.__mandatoryStyleSheet) | |
659 | ||
660 | if bool(self.bootPicker.text()): | |
661 | self.bootPicker.setStyleSheet("") | |
662 | else: | |
663 | self.bootPicker.setStyleSheet(self.__mandatoryStyleSheet) | |
664 | else: | |
665 | self.firmwarePicker.setStyleSheet("") | |
666 | self.bootPicker.setStyleSheet("") | |
667 | ||
668 | enable = ( | |
669 | bool(self.bootPicker.text()) and | |
670 | bool(firmwareFile) and | |
671 | os.path.exists(firmwareFile) | |
672 | ) | |
673 | self.flashButton.setEnabled(enable) | |
674 | ||
675 | def __showAllInstructions(self): | |
676 | """ | |
677 | Private method to show instructions for resetting devices to bootloader | |
678 | mode. | |
679 | """ | |
680 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
681 | ||
682 | htmlText = self.tr( | |
683 | "<h4>No known devices detected.</h4>" | |
684 | "<p>Follow the appropriate instructions below to set <b>one</b>" | |
685 | " board into 'bootloader' mode. Press <b>Refresh</b> when ready." | |
686 | "</p>" | |
687 | ) | |
688 | for boardType in SupportedUF2Boards: | |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
689 | if SupportedUF2Boards[boardType]["show_all"]: |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
690 | htmlText += ( |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
691 | "<hr/>" + |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
692 | SupportedUF2Boards[boardType]["instructions"] |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
693 | ) |
8096 | 694 | self.infoEdit.setHtml(htmlText) |
695 | ||
696 | def __showSpecificInstructions(self, devices): | |
697 | """ | |
698 | Private method to show instructions for resetting devices to bootloader | |
699 | mode for a list of detected devices. | |
700 | ||
701 | @param devices list of detected devices | |
702 | @type list of str | |
703 | """ | |
8099
522946e53835
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8097
diff
changeset
|
704 | boardTypes = {x[0] for x in devices} |
8096 | 705 | |
706 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
707 | ||
708 | if self.__boardType: | |
709 | htmlText = self.tr( | |
710 | "<h4>Flash {0} Firmware</h4>" | |
711 | "<p>Follow the instructions below to set <b>one</b> board into" | |
712 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
713 | "<hr/>{1}" | |
714 | ).format( | |
715 | SupportedUF2Boards[self.__boardType]["firmware"], | |
716 | SupportedUF2Boards[self.__boardType]["instructions"], | |
717 | ) | |
718 | else: | |
719 | htmlText = self.tr( | |
720 | "<h4>Potentially UF2 capable devices found</h4>" | |
721 | "<p>Found these potentially UF2 capable devices:</p>" | |
722 | "<ul><li>{0}</li></ul>" | |
723 | "<p>Follow the instructions below to set <b>one</b> board into" | |
724 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
725 | ).format( | |
726 | "</li><li>".join(sorted(x[1] for x in devices)) | |
727 | ) | |
728 | for boardType in sorted(boardTypes): | |
729 | htmlText += ( | |
730 | "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
731 | ) | |
732 | self.infoEdit.setHtml(htmlText) | |
733 | ||
734 | def __showTypedInstructions(self, boardType): | |
735 | """ | |
736 | Private method to show instructions for resetting devices to bootloader | |
737 | mode for a specific board type. | |
738 | ||
739 | @param boardType type of the board to show instructions for | |
740 | @type str | |
741 | """ | |
742 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
743 | ||
744 | htmlText = self.tr( | |
745 | "<h4>No known devices detected.</h4>" | |
746 | "<p>Follow the instructions below to set <b>one</b> board into" | |
747 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
748 | ) | |
749 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
750 | self.infoEdit.setHtml(htmlText) | |
751 | ||
752 | def __showManualInstructions(self): | |
753 | """ | |
754 | Private method to show instructions for flashing devices manually. | |
755 | """ | |
756 | self.infoLabel.setText(self.tr("Flash Instructions:")) | |
757 | ||
758 | htmlText = self.tr( | |
759 | "<h4>Flash method 'manual' selected.</h4>" | |
760 | "<p>Follow the instructions below to flash a device by entering" | |
8097
5af9c426c46b
Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8096
diff
changeset
|
761 | " the data manually.</p><ol>" |
8096 | 762 | "<li>Change the device to 'bootloader' mode.</li>" |
763 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
764 | "<li>Ensure the boot volume is available (this may require" | |
765 | " mounting it) and select its path.</li>" | |
766 | "<li>Select the firmware file to be flashed and click the" | |
767 | " flash button.</li>" | |
768 | "</ol>" | |
769 | ) | |
770 | for boardType in SupportedUF2Boards: | |
771 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
772 | self.infoEdit.setHtml(htmlText) | |
773 | ||
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
774 | def __showNoVolumeInformation(self, volumes, boardType): |
8096 | 775 | """ |
776 | Private method to show information about the expected boot volume(s). | |
777 | ||
778 | @param volumes list of expected volume names | |
779 | @type list of str | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
780 | @param boardType type of the board to show instructions for |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
781 | @type str |
8096 | 782 | """ |
783 | self.infoLabel.setText(self.tr("Boot Volume not found:")) | |
784 | ||
785 | htmlText = self.tr( | |
786 | "<h4>No Boot Volume detected.</h4>" | |
787 | "<p>Please ensure that the boot volume of the device to be flashed" | |
788 | " is available. " | |
789 | ) | |
790 | if len(volumes) == 1: | |
791 | htmlText += self.tr( | |
792 | "This volume should be named <b>{0}</b>." | |
793 | " Press <b>Refresh</b> when ready.</p>" | |
794 | ).format(volumes[0]) | |
795 | else: | |
796 | htmlText += self.tr( | |
797 | "This volume should have one of these names.</p>" | |
798 | "<ul><li>{0}</li></ul>" | |
799 | "<p>Press <b>Refresh</b> when ready.</p>" | |
800 | ).format("</li><li>".join(sorted(volumes))) | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
801 | |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
802 | if boardType: |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
803 | htmlText += self.tr( |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
804 | "<h4>Reset Instructions</h4>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
805 | "<p>Follow the instructions below to set the board into" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
806 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
807 | ) |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
808 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
809 | |
8096 | 810 | self.infoEdit.setHtml(htmlText) |
811 | ||
812 | def __showMultipleVolumesInformation(self, volumePaths): | |
813 | """ | |
814 | Private method to show information because multiple devices of the | |
815 | same type are ready for flashing. | |
816 | ||
817 | Note: This is a dangerous situation! | |
818 | ||
819 | @param volumePaths list of volume paths | |
820 | @type list of str | |
821 | """ | |
822 | self.infoLabel.setText(self.tr("Multiple Boot Volumes found:")) | |
823 | ||
824 | htmlText = self.tr( | |
825 | "<h4>Multiple Boot Volumes were found</h4>" | |
826 | "<p>These volume paths were found.</p><ul><li>{0}</li></ul>" | |
827 | "<p>Please ensure that only one device of a type is ready for" | |
828 | " flashing. Press <b>Refresh</b> when ready.</p>" | |
829 | ).format("</li><li>".join(sorted(volumePaths))) | |
830 | self.infoEdit.setHtml(htmlText) | |
831 | ||
832 | @pyqtSlot() | |
833 | def on_flashButton_clicked(self): | |
834 | """ | |
835 | Private slot to flash the selected MicroPython or CircuitPython | |
836 | firmware onto the device. | |
837 | """ | |
838 | boardType = self.devicesComboBox.currentData(self.DeviceTypeRole) | |
839 | firmwarePath = self.firmwarePicker.text() | |
840 | volumePath = self.bootPicker.text() | |
841 | if os.path.exists(firmwarePath) and os.path.exists(volumePath): | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
842 | if boardType == self.__manualType: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
843 | self.infoLabel.setText(self.tr("Flashing Firmware")) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
844 | self.infoEdit.setHtml(self.tr( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
845 | "<p>Flashing the selected firmware to the device. Please" |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
846 | " wait until the device resets automatically.</p>") |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
847 | ) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
848 | else: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
849 | firmwareType = SupportedUF2Boards[boardType]["firmware"] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
850 | self.infoLabel.setText( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
851 | self.tr("Flashing {0}").format(firmwareType)) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
852 | self.infoEdit.setHtml(self.tr( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
853 | "<p>Flashing the {0} firmware to the device. Please wait" |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
854 | " until the device resets automatically.</p>" |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
855 | ).format(firmwareType)) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8120
diff
changeset
|
856 | QCoreApplication.processEvents( |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8120
diff
changeset
|
857 | QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) |
8096 | 858 | shutil.copy2(firmwarePath, volumePath) |
859 | QThread.sleep(1) | |
860 | self.on_refreshButton_clicked() | |
861 | ||
862 | @pyqtSlot() | |
863 | def on_refreshButton_clicked(self): | |
864 | """ | |
865 | Private slot to refresh the dialog. | |
866 | """ | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
867 | # special treatment for RPi Pico |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
868 | if self.__boardType == "circuitpython_rp2040": |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
869 | self.__boardType = "rp2040" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
870 | |
8096 | 871 | self.__populate() |
872 | ||
873 | @pyqtSlot(int) | |
874 | def on_devicesComboBox_currentIndexChanged(self, index): | |
875 | """ | |
876 | Private slot to handle the selection of a board. | |
877 | ||
878 | @param index selected index | |
879 | @type int | |
880 | """ | |
881 | vidpid = self.devicesComboBox.itemData(index, self.DeviceVidPidRole) | |
882 | boardType = self.devicesComboBox.itemData(index, self.DeviceTypeRole) | |
883 | ||
884 | self.bootPicker.setEnabled(boardType == self.__manualType) | |
885 | if boardType == self.__manualType: | |
886 | self.__showManualInstructions() | |
887 | ||
888 | if vidpid is None: | |
889 | if boardType is None: | |
890 | self.bootPicker.clear() | |
891 | else: | |
892 | volumes = SupportedUF2Boards[boardType]["volumes"][vidpid] | |
893 | foundVolumes = [] | |
894 | for volume in volumes: | |
895 | foundVolumes += Utilities.findVolume(volume, findAll=True) | |
896 | ||
897 | if len(foundVolumes) == 0: | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
898 | self.__showNoVolumeInformation(volumes, boardType) |
8096 | 899 | self.bootPicker.clear() |
900 | elif len(foundVolumes) == 1: | |
901 | self.bootPicker.setText(foundVolumes[0]) | |
902 | else: | |
903 | self.__showMultipleVolumesInformation() | |
904 | self.bootPicker.clear() | |
905 | ||
906 | self.__updateFlashButton() | |
907 | ||
908 | @pyqtSlot(str) | |
909 | def on_firmwarePicker_textChanged(self, text): | |
910 | """ | |
911 | Private slot handling a change of the firmware file. | |
912 | ||
913 | @param text current text of the firmware edit | |
914 | @type str | |
915 | """ | |
916 | self.__updateFlashButton() | |
917 | ||
918 | @pyqtSlot(str) | |
919 | def on_bootPicker_textChanged(self, text): | |
920 | """ | |
921 | Private slot handling a change of the boot volume. | |
922 | ||
923 | @param text current text of the boot volume edit | |
924 | @type str | |
925 | """ | |
926 | self.__updateFlashButton() |