Sat, 22 May 2021 18:51:46 +0200
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
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 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
14 | from PyQt6.QtCore import pyqtSlot, Qt, QCoreApplication, QThread, QEventLoop |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
15 | from PyQt6.QtWidgets import QDialog |
8096 | 16 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
17 | from E5Gui.EricPathPicker import EricPathPickerModes |
8096 | 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 | ], | |
88 | (0x1B4F, 0x0019): [ | |
89 | "QwiicMicro", # Sparkfun Qwiic Micro | |
90 | ], | |
91 | (0x1B4F, 0x0D22): [ | |
92 | "SPARKFUN", # Sparkfun SAMD21 Mini Breakout | |
93 | ], | |
94 | (0x1B4F, 0x0D23): [ | |
95 | "SPARKFUN", # Sparkfun SAMD21 Dev Breakout | |
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 | "MDBT50QBOOT", # Raytac MDBT50Q-RX | |
159 | "MDK840DONGL", # MDK nRF52840 USB Dongle | |
160 | "WS52840EVK", # Waveshare nRF52840 Eval | |
161 | "XENONBOOT ", # Xenon | |
162 | ], | |
163 | (0x239A, 0x002B): [ | |
164 | "ARCADE-D5", # Itsy Arcade D51 | |
165 | "ITSYM4BOOT", # ItsyBitsy M4 Express | |
166 | ], | |
167 | (0x239A, 0x002D): [ | |
168 | "CRICKITBOOT", # crickit | |
169 | ], | |
170 | (0x239A, 0x002F): [ | |
171 | "TRELM4BOOT", # Trellis M4 Express | |
172 | ], | |
173 | (0x239A, 0x0031): [ | |
174 | "GCM4BOOT", # Grand Central M4 Express | |
175 | ], | |
176 | (0x239A, 0x0033): [ | |
177 | "PYBADGEBOOT", # PyBadge | |
178 | ], | |
179 | (0x239A, 0x0034): [ | |
180 | "BADGELCBOOT", # BadgeLC | |
181 | "PEWBOOT", # PewPew | |
182 | ], | |
183 | (0x239A, 0x0035): [ | |
184 | "MKRZEROBOOT", # MKRZero | |
185 | "PORTALBOOT", # PyPortal M4 Express | |
186 | ], | |
187 | (0x239A, 0x0037): [ | |
188 | "METROM4BOOT", # Metro M4 AirLift | |
189 | ], | |
190 | (0x239A, 0x003D): [ | |
191 | "PYGAMERBOOT", # PyGamer | |
192 | ], | |
193 | (0x239A, 0x003F): [ | |
194 | "METR840BOOT", # Metro nRF52840 Express | |
195 | ], | |
196 | (0x239A, 0x0045): [ | |
197 | "CPLAYBTBOOT", # Circuit Playground nRF52840 | |
198 | ], | |
199 | (0x239A, 0x0047): [ | |
200 | "MASKM4BOOT", # Hallowing Mask M4 | |
201 | ], | |
202 | (0x239A, 0x0049): [ | |
203 | "HALLOM4BOOT", # HalloWing M4 | |
204 | ], | |
205 | (0x239A, 0x004D): [ | |
206 | "SNEKBOOT", # snekboard | |
207 | ], | |
208 | (0x239A, 0x0051): [ | |
209 | "ITSY840BOOT", # ItsyBitsy nRF52840 Express | |
210 | ], | |
211 | (0x239A, 0x0057): [ | |
212 | "SERPENTBOOT", # Serpente | |
213 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
214 | (0x239A, 0x0059): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
215 | "FTHR405BOOT", # Feather STM32F405 Express |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
216 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
217 | (0x239A, 0x005D): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
218 | "BlackPill", # STM32F401CxUx |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
219 | "STMF411BOOT", # STM32F411 Discovery |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
220 | ], |
8096 | 221 | (0x239A, 0x0061): [ |
222 | "SOLBOOT", # Sol | |
223 | ], | |
224 | (0x239A, 0x0063): [ | |
225 | "NANO33BOOT", # Nano 33 BLE | |
226 | ], | |
227 | (0x239A, 0x0065): [ | |
228 | "ND6BOOT", # ndBit6 | |
229 | ], | |
230 | (0x239A, 0x006B): [ | |
231 | "shIRtty", # shIRtty | |
232 | ], | |
233 | (0x239A, 0x0071): [ | |
234 | "CLUEBOOT", # CLUE nRF52840 | |
235 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
236 | (0x239A, 0x0077): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
237 | "RT1010BOOT", # RT1010 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
238 | ], |
8096 | 239 | (0x239A, 0x0079): [ |
240 | "ARAMBOOT", # ARAMCON Badge 2019 | |
241 | ], | |
242 | (0x239A, 0x007D): [ | |
243 | "BOOKBOOT", # The Open Book Feather | |
244 | ], | |
245 | (0x239A, 0x007F): [ | |
246 | "BADGEBOOT", # OHS2020 Badge | |
247 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
248 | (0x239A, 0x0081): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
249 | "RT1020BOOT", # RT1020 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
250 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
251 | (0x239A, 0x0083): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
252 | "RT1060BOOT", # RT1060 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
253 | ], |
8096 | 254 | (0x239A, 0x0087): [ |
255 | "FTHRSNSBOOT", # Feather nRF52840 Sense | |
256 | ], | |
257 | (0x239A, 0x0093): [ | |
258 | "ISVITABoot", # IkigaiSense Vita nRF52840 | |
259 | ], | |
260 | (0x239A, 0x0095): [ | |
261 | "UARTLOGBOOT", # UARTLogger II | |
262 | ], | |
263 | (0x239A, 0x009F): [ | |
264 | "ADM840BOOT", # AtelierDuMaker NRF52840 Breakout | |
265 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
266 | (0x239A, 0x00A5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
267 | "SAOLA1RBOOT", # Saola 1R WROVER |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
268 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
269 | (0x239A, 0x00A7): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
270 | "SAOLA1MBOOT", # Saola 1M WROOM |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
271 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
272 | (0x239A, 0x00AB): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
273 | "UFTHRS2BOOT", # FeatherS2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
274 | ], |
8096 | 275 | (0x239A, 0x00AF): [ |
276 | "FLUFFBOOT", # Fluff M0 | |
277 | ], | |
278 | (0x239A, 0x00B3): [ | |
279 | "NICENANO", # nice!nano | |
280 | ], | |
281 | (0x239A, 0x00B5): [ | |
282 | "E54XBOOT", # SAME54 Xplained | |
283 | ], | |
284 | (0x239A, 0x00B9): [ | |
285 | "ND7BOOT", # ndBit7 | |
286 | ], | |
287 | (0x239A, 0x00BF): [ | |
288 | "BADGEBOOT", # BLM Badge | |
289 | ], | |
290 | (0x239A, 0x00C3): [ | |
291 | "GEMINIBOOT", # Gemini | |
292 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
293 | (0x239A, 0x00C5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
294 | "MICROS2BOOT", # microS2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
295 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
296 | (0x239A, 0x00C7): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
297 | "KALUGA1BOOT", # Kaluga 1 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
298 | ], |
8096 | 299 | (0x239A, 0x00CB): [ |
300 | "QTPY_BOOT", # QT Py M0 | |
301 | ], | |
302 | (0x239A, 0x00CD): [ | |
303 | "FTHRCANBOOT", # Feather M4 CAN Express | |
304 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
305 | (0x239A, 0x00DF): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
306 | "METROS2BOOT", # Metro ESP32-S2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
307 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
308 | (0x239A, 0x00E1): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
309 | "METROM7BOOT", # Metro M7 1011 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
310 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
311 | (0x239A, 0x00E5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
312 | "MAGTAGBOOT", # Metro MagTag 2.9 Grayscale |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
313 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
314 | (0x239A, 0x00EB): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
315 | "FTHRS2BOOT", # Feather ESP32-S2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
316 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
317 | (0x239A, 0x00ED): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
318 | "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
|
319 | ], |
8096 | 320 | (0x239A, 0x00EF): [ |
321 | "TRINKEYBOOT", # NeoPixel Trinkey M0 | |
322 | ], | |
323 | (0x239A, 0x00F5): [ | |
324 | "STARBOOT", # Binary Star | |
325 | ], | |
326 | (0x239A, 0xB000): [ | |
327 | "HALLOWBOOT", # Hallowing M0 | |
328 | ], | |
329 | (0x239A, 0xE005): [ | |
330 | "HONKBOOT", # Big Honking Button | |
331 | ], | |
332 | (0x2886, 0x000D): [ | |
333 | "Grove Zero", # Grove Zero | |
334 | ], | |
335 | (0x2886, 0x002F): [ | |
336 | "Seeed XIAO", # Seeeduino XIAO | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
337 | "Arduino", # Seeeduino XIAO (old bootloader) |
8096 | 338 | ], |
339 | (0x2886, 0xF00E): [ | |
340 | "PITAYAGO", # Pitaya Go | |
341 | ], | |
342 | (0x2886, 0xF00F): [ | |
343 | "nRF52840M2", # MakerDiary nRF52840 M.2 Module | |
344 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
345 | (0x303A, 0x8008): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
346 | "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
|
347 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
348 | (0x303A, 0x800E): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
349 | "CCMBRISBOOT", # CucumberRIS v1.1 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
350 | ], |
8096 | 351 | (0x3171, 0x0100): [ |
352 | "CMDBOOT", # COMMANDER | |
353 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
354 | (0xCAFE, 0xFFFF): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
355 | "F303BOOT", # STM32F303 Discovery |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
356 | ], |
8096 | 357 | }, |
358 | "instructions": QCoreApplication.translate( | |
359 | "UF2FlashDialog", | |
360 | "<h3>CircuitPython Board</h3>" | |
361 | "<p>In order to prepare the board for flashing follow these" | |
362 | " steps:</p><ol>" | |
363 | "<li>Switch your device to 'bootloader' mode by double-pressing" | |
364 | " the reset button.</li>" | |
365 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
366 | "<li>(If this does not happen, then try shorter or longer" | |
367 | " pauses between presses.)</li>" | |
368 | "<li>Ensure the boot volume is available (this may require" | |
369 | " mounting it).</li>" | |
370 | "<li>Select the firmware file to be flashed and click the" | |
371 | " flash button.</li>" | |
372 | "</ol>" | |
373 | ), | |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
374 | "show_all": True, |
8096 | 375 | "firmware": "CircuitPython", |
376 | }, | |
377 | ||
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
378 | "circuitpython_rp2040": { |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
379 | "volumes": { |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
380 | (0x239A, 0x80F4): [ |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
381 | "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
|
382 | ], |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
383 | }, |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
384 | "instructions": QCoreApplication.translate( |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
385 | "UF2FlashDialog", |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
386 | "<h3>Pi Pico (RP2040) Board</h3>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
387 | "<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
|
388 | " steps:</p><ol>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
389 | "<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
|
390 | "<ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
391 | "<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
|
392 | "</ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
393 | "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
|
394 | "<ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
395 | "<li>hold down RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
396 | "<li>hold down BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
397 | "<li>release RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
398 | "<li>release BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
399 | "</ul></li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
400 | "<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
|
401 | "<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
|
402 | " mounting it).</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
403 | "<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
|
404 | " flash button.</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
405 | "</ol>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
406 | ), |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
407 | "show_all": False, |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
408 | "firmware": "CircuitPython", |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
409 | }, |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
410 | |
8096 | 411 | "rp2040": { |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
412 | "volumes": { |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
413 | (0x0000, 0x0000): [ |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
414 | "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
|
415 | ], |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
416 | }, |
8096 | 417 | "instructions": QCoreApplication.translate( |
418 | "UF2FlashDialog", | |
419 | "<h3>Pi Pico (RP2040) Board</h3>" | |
420 | "<p>In order to prepare the board for flashing follow these" | |
421 | " steps:</p><ol>" | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
422 | "<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
|
423 | "<ul>" |
8096 | 424 | "<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
|
425 | "</ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
426 | "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
|
427 | "<ul>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
428 | "<li>hold down RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
429 | "<li>hold down BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
430 | "<li>release RESET</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
431 | "<li>release BOOTSEL</li>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
432 | "</ul></li>" |
8096 | 433 | "<li>Wait until the device has entered 'bootloader' mode.</li>" |
434 | "<li>Ensure the boot volume is available (this may require" | |
435 | " mounting it).</li>" | |
436 | "<li>Select the firmware file to be flashed and click the" | |
437 | " flash button.</li>" | |
438 | "</ol>" | |
439 | ), | |
8170
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
440 | "show_all": True, |
8120
84928e9f446f
UF2FlashDialog: updated a string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8111
diff
changeset
|
441 | "firmware": "MicroPython / CircuitPython", |
8096 | 442 | }, |
443 | } | |
444 | ||
445 | ||
446 | def getFoundDevices(boardType=""): | |
447 | """ | |
448 | Function to get the list of known serial devices supporting UF2. | |
449 | ||
450 | @param boardType specific board type to search for | |
451 | @type str | |
452 | @return list of tuples with the board type, the port description, the | |
453 | VID and PID | |
454 | @rtype list of tuple of (str, str, int, int) | |
455 | """ | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
456 | from PyQt6.QtSerialPort import QSerialPortInfo |
8096 | 457 | |
458 | foundDevices = [] | |
459 | ||
460 | availablePorts = QSerialPortInfo.availablePorts() | |
461 | for port in availablePorts: | |
462 | vid = port.vendorIdentifier() | |
463 | pid = port.productIdentifier() | |
464 | ||
465 | if vid == 0 and pid == 0: | |
466 | # no device detected at port | |
467 | continue | |
468 | ||
469 | 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
|
470 | 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
|
471 | (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
|
472 | (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
|
473 | ): |
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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | (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
|
478 | )) |
8096 | 479 | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
480 | # 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
|
481 | for board in SupportedUF2Boards: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
482 | 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
|
483 | with contextlib.suppress(KeyError): |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
484 | # find mounted volume |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
485 | volumes = SupportedUF2Boards[board]["volumes"][(0, 0)] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
486 | foundVolumes = [] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
487 | for volume in volumes: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
488 | foundVolumes += Utilities.findVolume(volume, findAll=True) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
489 | if foundVolumes: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
490 | foundDevices.append(( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
491 | board, |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
492 | QCoreApplication.translate( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
493 | "UF2FlashDialog", "'{0}' Board").format(board), |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
494 | (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
|
495 | )) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
496 | |
8096 | 497 | return foundDevices |
498 | ||
499 | ||
500 | class UF2FlashDialog(QDialog, Ui_UF2FlashDialog): | |
501 | """ | |
502 | Class implementing a dialog to flash any UF2 capable device. | |
503 | """ | |
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
|
504 | 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
|
505 | DeviceVidPidRole = Qt.ItemDataRole.UserRole + 1 |
8096 | 506 | |
507 | def __init__(self, boardType="", parent=None): | |
508 | """ | |
509 | Constructor | |
510 | ||
511 | @param boardType specific board type to show the dialog for | |
512 | @type str | |
513 | @param parent reference to the parent widget (defaults to None) | |
514 | @type QWidget (optional) | |
515 | """ | |
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
|
516 | super().__init__(parent) |
8096 | 517 | self.setupUi(self) |
518 | ||
519 | self.refreshButton.setIcon(UI.PixmapCache.getIcon("rescan")) | |
520 | ||
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
521 | self.firmwarePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
8096 | 522 | self.firmwarePicker.setFilters( |
523 | self.tr("MicroPython/CircuitPython Files (*.uf2);;" | |
524 | "All Files (*)")) | |
525 | ||
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8327
diff
changeset
|
526 | self.bootPicker.setMode(EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) |
8096 | 527 | self.bootPicker.setEnabled(False) |
528 | ||
529 | self.__mandatoryStyleSheet = ( | |
530 | "QLineEdit {border: 2px solid;border-color: #800000}" | |
531 | ) | |
532 | self.__manualType = "<manual>" | |
533 | ||
534 | self.__boardType = boardType | |
535 | ||
536 | self.__populate() | |
537 | ||
538 | self.__updateFlashButton() | |
539 | ||
540 | def __populate(self): | |
541 | """ | |
542 | Private method to (re-)populate the dialog. | |
543 | """ | |
544 | # save the currently selected device | |
545 | currentDevice = self.devicesComboBox.currentText() | |
546 | firmwareFile = self.firmwarePicker.text() | |
547 | ||
548 | # clear the entries first | |
549 | self.devicesComboBox.clear() | |
550 | self.firmwarePicker.clear() | |
551 | self.bootPicker.clear() | |
552 | self.infoLabel.clear() | |
553 | self.infoEdit.clear() | |
554 | ||
555 | # now populate the entries with data | |
556 | devices = getFoundDevices(boardType=self.__boardType) | |
557 | if len(devices) == 0: | |
558 | # no device detected | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
559 | devices = list(filter( |
8096 | 560 | lambda x: x[0] in SupportedUF2Boards, |
561 | MicroPythonDevices.getFoundDevices()[0] | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
562 | )) |
8096 | 563 | if devices: |
564 | self.__showSpecificInstructions(list(devices)) | |
565 | else: | |
566 | self.__showAllInstructions() | |
567 | self.devicesComboBox.addItem("") | |
568 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
569 | self.devicesComboBox.setItemData(1, self.__manualType, | |
570 | self.DeviceTypeRole) | |
571 | elif len(devices) == 1: | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
572 | # 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
|
573 | self.__boardType = devices[0][0] |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
574 | |
8096 | 575 | self.devicesComboBox.addItem(devices[0][1]) |
576 | self.devicesComboBox.setItemData( | |
577 | 0, devices[0][0], self.DeviceTypeRole) | |
578 | self.devicesComboBox.setItemData( | |
579 | 0, devices[0][2], self.DeviceVidPidRole) | |
580 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
581 | self.devicesComboBox.setItemData(1, self.__manualType, | |
582 | self.DeviceTypeRole) | |
583 | self.on_devicesComboBox_currentIndexChanged(0) | |
584 | else: | |
585 | self.devicesComboBox.addItem("") | |
586 | for index, (boardType, description, | |
587 | vidpid) in enumerate(sorted(devices), 1): | |
588 | self.devicesComboBox.addItem(description) | |
589 | self.devicesComboBox.setItemData( | |
590 | index, boardType, self.DeviceTypeRole) | |
591 | self.devicesComboBox.setItemData( | |
592 | index, vidpid, self.DeviceVidPidRole) | |
593 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
594 | self.devicesComboBox.setItemData(index + 1, self.__manualType, | |
595 | self.DeviceTypeRole) | |
596 | ||
597 | # reselect the remembered device, if it is still there | |
598 | if currentDevice: | |
599 | self.devicesComboBox.setCurrentText(currentDevice) | |
600 | self.firmwarePicker.setText(firmwareFile) | |
601 | else: | |
602 | self.devicesComboBox.setCurrentIndex(0) | |
603 | ||
604 | def __updateFlashButton(self): | |
605 | """ | |
606 | Private method to update the state of the Flash button and the retest | |
607 | button. | |
608 | """ | |
609 | firmwareFile = self.firmwarePicker.text() | |
610 | if self.devicesComboBox.currentData(self.DeviceTypeRole) is not None: | |
611 | if bool(firmwareFile) and os.path.exists(firmwareFile): | |
612 | self.firmwarePicker.setStyleSheet("") | |
613 | else: | |
614 | self.firmwarePicker.setStyleSheet(self.__mandatoryStyleSheet) | |
615 | ||
616 | if bool(self.bootPicker.text()): | |
617 | self.bootPicker.setStyleSheet("") | |
618 | else: | |
619 | self.bootPicker.setStyleSheet(self.__mandatoryStyleSheet) | |
620 | else: | |
621 | self.firmwarePicker.setStyleSheet("") | |
622 | self.bootPicker.setStyleSheet("") | |
623 | ||
624 | enable = ( | |
625 | bool(self.bootPicker.text()) and | |
626 | bool(firmwareFile) and | |
627 | os.path.exists(firmwareFile) | |
628 | ) | |
629 | self.flashButton.setEnabled(enable) | |
630 | ||
631 | def __showAllInstructions(self): | |
632 | """ | |
633 | Private method to show instructions for resetting devices to bootloader | |
634 | mode. | |
635 | """ | |
636 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
637 | ||
638 | htmlText = self.tr( | |
639 | "<h4>No known devices detected.</h4>" | |
640 | "<p>Follow the appropriate instructions below to set <b>one</b>" | |
641 | " board into 'bootloader' mode. Press <b>Refresh</b> when ready." | |
642 | "</p>" | |
643 | ) | |
644 | 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
|
645 | 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
|
646 | htmlText += ( |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
647 | "<hr/>" + |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
648 | SupportedUF2Boards[boardType]["instructions"] |
fb77bff32621
MicroPython: corrected a glitch in the UF2 flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8167
diff
changeset
|
649 | ) |
8096 | 650 | self.infoEdit.setHtml(htmlText) |
651 | ||
652 | def __showSpecificInstructions(self, devices): | |
653 | """ | |
654 | Private method to show instructions for resetting devices to bootloader | |
655 | mode for a list of detected devices. | |
656 | ||
657 | @param devices list of detected devices | |
658 | @type list of str | |
659 | """ | |
8099
522946e53835
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8097
diff
changeset
|
660 | boardTypes = {x[0] for x in devices} |
8096 | 661 | |
662 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
663 | ||
664 | if self.__boardType: | |
665 | htmlText = self.tr( | |
666 | "<h4>Flash {0} Firmware</h4>" | |
667 | "<p>Follow the instructions below to set <b>one</b> board into" | |
668 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
669 | "<hr/>{1}" | |
670 | ).format( | |
671 | SupportedUF2Boards[self.__boardType]["firmware"], | |
672 | SupportedUF2Boards[self.__boardType]["instructions"], | |
673 | ) | |
674 | else: | |
675 | htmlText = self.tr( | |
676 | "<h4>Potentially UF2 capable devices found</h4>" | |
677 | "<p>Found these potentially UF2 capable devices:</p>" | |
678 | "<ul><li>{0}</li></ul>" | |
679 | "<p>Follow the instructions below to set <b>one</b> board into" | |
680 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
681 | ).format( | |
682 | "</li><li>".join(sorted(x[1] for x in devices)) | |
683 | ) | |
684 | for boardType in sorted(boardTypes): | |
685 | htmlText += ( | |
686 | "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
687 | ) | |
688 | self.infoEdit.setHtml(htmlText) | |
689 | ||
690 | def __showTypedInstructions(self, boardType): | |
691 | """ | |
692 | Private method to show instructions for resetting devices to bootloader | |
693 | mode for a specific board type. | |
694 | ||
695 | @param boardType type of the board to show instructions for | |
696 | @type str | |
697 | """ | |
698 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
699 | ||
700 | htmlText = self.tr( | |
701 | "<h4>No known devices detected.</h4>" | |
702 | "<p>Follow the instructions below to set <b>one</b> board into" | |
703 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
704 | ) | |
705 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
706 | self.infoEdit.setHtml(htmlText) | |
707 | ||
708 | def __showManualInstructions(self): | |
709 | """ | |
710 | Private method to show instructions for flashing devices manually. | |
711 | """ | |
712 | self.infoLabel.setText(self.tr("Flash Instructions:")) | |
713 | ||
714 | htmlText = self.tr( | |
715 | "<h4>Flash method 'manual' selected.</h4>" | |
716 | "<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
|
717 | " the data manually.</p><ol>" |
8096 | 718 | "<li>Change the device to 'bootloader' mode.</li>" |
719 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
720 | "<li>Ensure the boot volume is available (this may require" | |
721 | " mounting it) and select its path.</li>" | |
722 | "<li>Select the firmware file to be flashed and click the" | |
723 | " flash button.</li>" | |
724 | "</ol>" | |
725 | ) | |
726 | for boardType in SupportedUF2Boards: | |
727 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
728 | self.infoEdit.setHtml(htmlText) | |
729 | ||
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
730 | def __showNoVolumeInformation(self, volumes, boardType): |
8096 | 731 | """ |
732 | Private method to show information about the expected boot volume(s). | |
733 | ||
734 | @param volumes list of expected volume names | |
735 | @type list of str | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
736 | @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
|
737 | @type str |
8096 | 738 | """ |
739 | self.infoLabel.setText(self.tr("Boot Volume not found:")) | |
740 | ||
741 | htmlText = self.tr( | |
742 | "<h4>No Boot Volume detected.</h4>" | |
743 | "<p>Please ensure that the boot volume of the device to be flashed" | |
744 | " is available. " | |
745 | ) | |
746 | if len(volumes) == 1: | |
747 | htmlText += self.tr( | |
748 | "This volume should be named <b>{0}</b>." | |
749 | " Press <b>Refresh</b> when ready.</p>" | |
750 | ).format(volumes[0]) | |
751 | else: | |
752 | htmlText += self.tr( | |
753 | "This volume should have one of these names.</p>" | |
754 | "<ul><li>{0}</li></ul>" | |
755 | "<p>Press <b>Refresh</b> when ready.</p>" | |
756 | ).format("</li><li>".join(sorted(volumes))) | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
757 | |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
758 | if boardType: |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
759 | htmlText += self.tr( |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
760 | "<h4>Reset Instructions</h4>" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
761 | "<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
|
762 | " '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
|
763 | ) |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
764 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
765 | |
8096 | 766 | self.infoEdit.setHtml(htmlText) |
767 | ||
768 | def __showMultipleVolumesInformation(self, volumePaths): | |
769 | """ | |
770 | Private method to show information because multiple devices of the | |
771 | same type are ready for flashing. | |
772 | ||
773 | Note: This is a dangerous situation! | |
774 | ||
775 | @param volumePaths list of volume paths | |
776 | @type list of str | |
777 | """ | |
778 | self.infoLabel.setText(self.tr("Multiple Boot Volumes found:")) | |
779 | ||
780 | htmlText = self.tr( | |
781 | "<h4>Multiple Boot Volumes were found</h4>" | |
782 | "<p>These volume paths were found.</p><ul><li>{0}</li></ul>" | |
783 | "<p>Please ensure that only one device of a type is ready for" | |
784 | " flashing. Press <b>Refresh</b> when ready.</p>" | |
785 | ).format("</li><li>".join(sorted(volumePaths))) | |
786 | self.infoEdit.setHtml(htmlText) | |
787 | ||
788 | @pyqtSlot() | |
789 | def on_flashButton_clicked(self): | |
790 | """ | |
791 | Private slot to flash the selected MicroPython or CircuitPython | |
792 | firmware onto the device. | |
793 | """ | |
794 | boardType = self.devicesComboBox.currentData(self.DeviceTypeRole) | |
795 | firmwarePath = self.firmwarePicker.text() | |
796 | volumePath = self.bootPicker.text() | |
797 | 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
|
798 | if boardType == self.__manualType: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
799 | 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
|
800 | self.infoEdit.setHtml(self.tr( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
801 | "<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
|
802 | " 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
|
803 | ) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
804 | else: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
805 | firmwareType = SupportedUF2Boards[boardType]["firmware"] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
806 | self.infoLabel.setText( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
807 | self.tr("Flashing {0}").format(firmwareType)) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
808 | self.infoEdit.setHtml(self.tr( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
809 | "<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
|
810 | " until the device resets automatically.</p>" |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
811 | ).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
|
812 | 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
|
813 | QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents) |
8096 | 814 | shutil.copy2(firmwarePath, volumePath) |
815 | QThread.sleep(1) | |
816 | self.on_refreshButton_clicked() | |
817 | ||
818 | @pyqtSlot() | |
819 | def on_refreshButton_clicked(self): | |
820 | """ | |
821 | Private slot to refresh the dialog. | |
822 | """ | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
823 | # special treatment for RPi Pico |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
824 | if self.__boardType == "circuitpython_rp2040": |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
825 | self.__boardType = "rp2040" |
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
826 | |
8096 | 827 | self.__populate() |
828 | ||
829 | @pyqtSlot(int) | |
830 | def on_devicesComboBox_currentIndexChanged(self, index): | |
831 | """ | |
832 | Private slot to handle the selection of a board. | |
833 | ||
834 | @param index selected index | |
835 | @type int | |
836 | """ | |
837 | vidpid = self.devicesComboBox.itemData(index, self.DeviceVidPidRole) | |
838 | boardType = self.devicesComboBox.itemData(index, self.DeviceTypeRole) | |
839 | ||
840 | self.bootPicker.setEnabled(boardType == self.__manualType) | |
841 | if boardType == self.__manualType: | |
842 | self.__showManualInstructions() | |
843 | ||
844 | if vidpid is None: | |
845 | if boardType is None: | |
846 | self.bootPicker.clear() | |
847 | else: | |
848 | volumes = SupportedUF2Boards[boardType]["volumes"][vidpid] | |
849 | foundVolumes = [] | |
850 | for volume in volumes: | |
851 | foundVolumes += Utilities.findVolume(volume, findAll=True) | |
852 | ||
853 | if len(foundVolumes) == 0: | |
8167
cdc1b6692766
MicroPython: improved the UF2 Flash dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
854 | self.__showNoVolumeInformation(volumes, boardType) |
8096 | 855 | self.bootPicker.clear() |
856 | elif len(foundVolumes) == 1: | |
857 | self.bootPicker.setText(foundVolumes[0]) | |
858 | else: | |
859 | self.__showMultipleVolumesInformation() | |
860 | self.bootPicker.clear() | |
861 | ||
862 | self.__updateFlashButton() | |
863 | ||
864 | @pyqtSlot(str) | |
865 | def on_firmwarePicker_textChanged(self, text): | |
866 | """ | |
867 | Private slot handling a change of the firmware file. | |
868 | ||
869 | @param text current text of the firmware edit | |
870 | @type str | |
871 | """ | |
872 | self.__updateFlashButton() | |
873 | ||
874 | @pyqtSlot(str) | |
875 | def on_bootPicker_textChanged(self, text): | |
876 | """ | |
877 | Private slot handling a change of the boot volume. | |
878 | ||
879 | @param text current text of the boot volume edit | |
880 | @type str | |
881 | """ | |
882 | self.__updateFlashButton() |