Thu, 18 Feb 2021 17:29:53 +0100
UF2FlashDialog: added support for Raspberry Pi Pico.
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 | |
12 | ||
13 | from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication, QThread, QEventLoop | |
14 | from PyQt5.QtWidgets import QDialog | |
15 | ||
16 | from E5Gui.E5PathPicker import E5PathPickerModes | |
17 | ||
18 | from .Ui_UF2FlashDialog import Ui_UF2FlashDialog | |
19 | ||
20 | import UI.PixmapCache | |
21 | import Utilities | |
22 | ||
23 | from . import MicroPythonDevices | |
24 | ||
25 | SupportedUF2Boards = { | |
26 | "circuitpython": { | |
27 | "volumes": { | |
28 | (0x03EB, 0x2402): [ | |
29 | "SAMD21", # SAMD21 Board | |
30 | "SAME54", # SAME54 Board | |
31 | ], | |
32 | (0x04D8, 0xEC44): [ | |
33 | "PYCUBEDBOOT", # PyCubedv04 | |
34 | ], | |
35 | (0x04D8, 0xEC63): [ | |
36 | "BOOT", # CircuitBrains Basic | |
37 | ], | |
38 | (0x04D8, 0xEC64): [ | |
39 | "BOOT", # CircuitBrains Deluxe | |
40 | ], | |
41 | (0x04D8, 0xED5F): [ | |
42 | "UCHIPYBOOT", # uChip CircuitPython | |
43 | ], | |
44 | (0x04D8, 0xEDB3): [ | |
45 | "USBHUBBOOT", # Programmable USB Hub | |
46 | ], | |
47 | (0x04D8, 0xEDBE): [ | |
48 | "SAM32BOOT", # SAM32 | |
49 | ], | |
50 | (0x04D8, 0xEF66): [ | |
51 | "SENSEBOX", # senseBox MCU | |
52 | ], | |
53 | (0x1209, 0x2017): [ | |
54 | "MINISAMBOOT", # Mini SAM M4 | |
55 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
56 | (0x1209, 0x3252): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
57 | "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
|
58 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
59 | (0x1209, 0x3253): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
60 | "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
|
61 | ], |
8096 | 62 | (0x1209, 0x4D44): [ |
63 | "ROBOM0BOOT", # Robo HAT MM1 | |
64 | "ROBOM4BOOT", # Robo HAT MM1 M4 | |
65 | ], | |
66 | (0x1209, 0x4DDD): [ | |
67 | "SapBOOT", # CP Sapling | |
68 | ], | |
69 | (0x1209, 0x7102): [ | |
70 | "MINISAMBOOT", # Mini SAM M0 | |
71 | ], | |
72 | (0x1209, 0x805A): [ | |
73 | "BASTBLE", # Bast BLE | |
74 | ], | |
75 | (0x1209, 0xE3E2): [ | |
76 | "StackRduino", # StackRduino M0 PRO | |
77 | ], | |
78 | (0x1209, 0xF501): [ | |
79 | "M4SHIMBOOT", # M4-Shim | |
80 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
81 | (0x15BA, 0x28DC): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
82 | "OLMLIPOBOOT", # ESP32S2 DevKit Lipo |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
83 | ], |
8096 | 84 | (0x16D0, 0x0CDA): [ |
85 | "AUTOMAT", # automat | |
86 | ], | |
87 | (0x1B4F, 0x0019): [ | |
88 | "QwiicMicro", # Sparkfun Qwiic Micro | |
89 | ], | |
90 | (0x1B4F, 0x0D22): [ | |
91 | "SPARKFUN", # Sparkfun SAMD21 Mini Breakout | |
92 | ], | |
93 | (0x1B4F, 0x0D23): [ | |
94 | "SPARKFUN", # Sparkfun SAMD21 Dev Breakout | |
95 | ], | |
96 | (0x1D50, 0x6110): [ | |
97 | "ROBOTICS", # Robotics | |
98 | ], | |
99 | (0x1D50, 0x6112): [ | |
100 | "RCBOOT", # Wattuino RC | |
101 | ], | |
102 | (0x1D50, 0x6160): [ | |
103 | "BLUEMICRO", # BlueMicro | |
104 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
105 | (0x1FC9, 0x0094): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
106 | "DblM33BOOT", # Double M33 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
107 | "LPC5528BOOT", # LPCXpresso 55s28 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
108 | "LPC5569BOOT", # LPCXpresso 55s69 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
109 | ], |
8096 | 110 | (0x230A, 0x00E9): [ |
111 | "TAU_BOOT", # Tau | |
112 | ], | |
113 | (0x2341, 0x0057): [ | |
114 | "NANOBOOT", # NANO 33 IoT | |
115 | ], | |
116 | (0x2341, 0x8053): [ | |
117 | "MKR1300", # MKR1300 | |
118 | ], | |
119 | (0x239A, 0x000F): [ | |
120 | "ITSYBOOT", # ItsyBitsy M0 Express | |
121 | ], | |
122 | (0x239A, 0x0013): [ | |
123 | "METROBOOT", # Metro M0 | |
124 | ], | |
125 | (0x239A, 0x0015): [ | |
126 | "FEATHERBOOT", # Feather M0 | |
127 | ], | |
128 | (0x239A, 0x0018): [ | |
129 | "CPLAYBOOT", # CPlay Express | |
130 | ], | |
131 | (0x239A, 0x001B): [ | |
132 | "FEATHERBOOT", # Feather M0 Express | |
133 | ], | |
134 | (0x239A, 0x001C): [ | |
135 | "GEMMABOOT", # Gemma M0 | |
136 | ], | |
137 | (0x239A, 0x001E): [ | |
138 | "TRINKETBOOT", # Trinket M0 | |
139 | ], | |
140 | (0x239A, 0x0021): [ | |
141 | "METROM4BOOT", # Metro M4 Express | |
142 | ], | |
143 | (0x239A, 0x0022): [ | |
144 | "ARCADE-D5", # Feather Arcade D51 | |
145 | "FEATHERBOOT", # Feather M4 Express | |
146 | ], | |
147 | (0x239A, 0x0024): [ | |
148 | "RADIOBOOT", # Radiofruit M0 | |
149 | ], | |
150 | (0x239A, 0x0027): [ | |
151 | "PIRKEYBOOT", # pIRKey M0 | |
152 | ], | |
153 | (0x239A, 0x0029): [ | |
154 | "ARGONBOOT ", # Argon | |
155 | "BORONBOOT ", # Boron | |
156 | "FTHR840BOOT", # Feather nRF52840 Express | |
157 | "MDBT50QBOOT", # Raytac MDBT50Q-RX | |
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 | ], | |
229 | (0x239A, 0x006B): [ | |
230 | "shIRtty", # shIRtty | |
231 | ], | |
232 | (0x239A, 0x0071): [ | |
233 | "CLUEBOOT", # CLUE nRF52840 | |
234 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
235 | (0x239A, 0x0077): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
236 | "RT1010BOOT", # RT1010 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
237 | ], |
8096 | 238 | (0x239A, 0x0079): [ |
239 | "ARAMBOOT", # ARAMCON Badge 2019 | |
240 | ], | |
241 | (0x239A, 0x007D): [ | |
242 | "BOOKBOOT", # The Open Book Feather | |
243 | ], | |
244 | (0x239A, 0x007F): [ | |
245 | "BADGEBOOT", # OHS2020 Badge | |
246 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
247 | (0x239A, 0x0081): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
248 | "RT1020BOOT", # RT1020 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
249 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
250 | (0x239A, 0x0083): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
251 | "RT1060BOOT", # RT1060 EVK |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
252 | ], |
8096 | 253 | (0x239A, 0x0087): [ |
254 | "FTHRSNSBOOT", # Feather nRF52840 Sense | |
255 | ], | |
256 | (0x239A, 0x0093): [ | |
257 | "ISVITABoot", # IkigaiSense Vita nRF52840 | |
258 | ], | |
259 | (0x239A, 0x0095): [ | |
260 | "UARTLOGBOOT", # UARTLogger II | |
261 | ], | |
262 | (0x239A, 0x009F): [ | |
263 | "ADM840BOOT", # AtelierDuMaker NRF52840 Breakout | |
264 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
265 | (0x239A, 0x00A5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
266 | "SAOLA1RBOOT", # Saola 1R WROVER |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
267 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
268 | (0x239A, 0x00A7): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
269 | "SAOLA1MBOOT", # Saola 1M WROOM |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
270 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
271 | (0x239A, 0x00AB): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
272 | "UFTHRS2BOOT", # FeatherS2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
273 | ], |
8096 | 274 | (0x239A, 0x00AF): [ |
275 | "FLUFFBOOT", # Fluff M0 | |
276 | ], | |
277 | (0x239A, 0x00B3): [ | |
278 | "NICENANO", # nice!nano | |
279 | ], | |
280 | (0x239A, 0x00B5): [ | |
281 | "E54XBOOT", # SAME54 Xplained | |
282 | ], | |
283 | (0x239A, 0x00B9): [ | |
284 | "ND7BOOT", # ndBit7 | |
285 | ], | |
286 | (0x239A, 0x00BF): [ | |
287 | "BADGEBOOT", # BLM Badge | |
288 | ], | |
289 | (0x239A, 0x00C3): [ | |
290 | "GEMINIBOOT", # Gemini | |
291 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
292 | (0x239A, 0x00C5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
293 | "MICROS2BOOT", # microS2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
294 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
295 | (0x239A, 0x00C7): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
296 | "KALUGA1BOOT", # Kaluga 1 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
297 | ], |
8096 | 298 | (0x239A, 0x00CB): [ |
299 | "QTPY_BOOT", # QT Py M0 | |
300 | ], | |
301 | (0x239A, 0x00CD): [ | |
302 | "FTHRCANBOOT", # Feather M4 CAN Express | |
303 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
304 | (0x239A, 0x00DF): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
305 | "METROS2BOOT", # Metro ESP32-S2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
306 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
307 | (0x239A, 0x00E1): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
308 | "METROM7BOOT", # Metro M7 1011 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
309 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
310 | (0x239A, 0x00E5): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
311 | "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
|
312 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
313 | (0x239A, 0x00EB): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
314 | "FTHRS2BOOT", # Feather ESP32-S2 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
315 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
316 | (0x239A, 0x00ED): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
317 | "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
|
318 | ], |
8096 | 319 | (0x239A, 0x00EF): [ |
320 | "TRINKEYBOOT", # NeoPixel Trinkey M0 | |
321 | ], | |
322 | (0x239A, 0x00F5): [ | |
323 | "STARBOOT", # Binary Star | |
324 | ], | |
325 | (0x239A, 0xB000): [ | |
326 | "HALLOWBOOT", # Hallowing M0 | |
327 | ], | |
328 | (0x239A, 0xE005): [ | |
329 | "HONKBOOT", # Big Honking Button | |
330 | ], | |
331 | (0x2886, 0x000D): [ | |
332 | "Grove Zero", # Grove Zero | |
333 | ], | |
334 | (0x2886, 0x002F): [ | |
335 | "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
|
336 | "Arduino", # Seeeduino XIAO (old bootloader) |
8096 | 337 | ], |
338 | (0x2886, 0xF00E): [ | |
339 | "PITAYAGO", # Pitaya Go | |
340 | ], | |
341 | (0x2886, 0xF00F): [ | |
342 | "nRF52840M2", # MakerDiary nRF52840 M.2 Module | |
343 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
344 | (0x303A, 0x8008): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
345 | "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
|
346 | ], |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
347 | (0x303A, 0x800E): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
348 | "CCMBRISBOOT", # CucumberRIS v1.1 |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
349 | ], |
8096 | 350 | (0x3171, 0x0100): [ |
351 | "CMDBOOT", # COMMANDER | |
352 | ], | |
8101
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
353 | (0xCAFE, 0xFFFF): [ |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
354 | "F303BOOT", # STM32F303 Discovery |
dee984e05647
UF2FlashDialog: extended the list of known UF2 capable devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8099
diff
changeset
|
355 | ], |
8096 | 356 | }, |
357 | "instructions": QCoreApplication.translate( | |
358 | "UF2FlashDialog", | |
359 | "<h3>CircuitPython Board</h3>" | |
360 | "<p>In order to prepare the board for flashing follow these" | |
361 | " steps:</p><ol>" | |
362 | "<li>Switch your device to 'bootloader' mode by double-pressing" | |
363 | " the reset button.</li>" | |
364 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
365 | "<li>(If this does not happen, then try shorter or longer" | |
366 | " pauses between presses.)</li>" | |
367 | "<li>Ensure the boot volume is available (this may require" | |
368 | " mounting it).</li>" | |
369 | "<li>Select the firmware file to be flashed and click the" | |
370 | " flash button.</li>" | |
371 | "</ol>" | |
372 | ), | |
373 | "firmware": "CircuitPython", | |
374 | }, | |
375 | ||
376 | "rp2040": { | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
377 | "volumes": { |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
378 | (0x0000, 0x0000): [ |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
379 | "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
|
380 | ], |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
381 | }, |
8096 | 382 | "instructions": QCoreApplication.translate( |
383 | "UF2FlashDialog", | |
384 | "<h3>Pi Pico (RP2040) Board</h3>" | |
385 | "<p>In order to prepare the board for flashing follow these" | |
386 | " steps:</p><ol>" | |
387 | "<li>Plug in your board while holding the BOOTSEL button.</li>" | |
388 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
389 | "<li>Ensure the boot volume is available (this may require" | |
390 | " mounting it).</li>" | |
391 | "<li>Select the firmware file to be flashed and click the" | |
392 | " flash button.</li>" | |
393 | "</ol>" | |
394 | ), | |
395 | "firmware": "MicroPython", | |
396 | }, | |
397 | } | |
398 | ||
399 | ||
400 | def getFoundDevices(boardType=""): | |
401 | """ | |
402 | Function to get the list of known serial devices supporting UF2. | |
403 | ||
404 | @param boardType specific board type to search for | |
405 | @type str | |
406 | @return list of tuples with the board type, the port description, the | |
407 | VID and PID | |
408 | @rtype list of tuple of (str, str, int, int) | |
409 | """ | |
410 | from PyQt5.QtSerialPort import QSerialPortInfo | |
411 | ||
412 | foundDevices = [] | |
413 | ||
414 | availablePorts = QSerialPortInfo.availablePorts() | |
415 | for port in availablePorts: | |
416 | vid = port.vendorIdentifier() | |
417 | pid = port.productIdentifier() | |
418 | ||
419 | if vid == 0 and pid == 0: | |
420 | # no device detected at port | |
421 | continue | |
422 | ||
423 | for board in SupportedUF2Boards: | |
424 | if not boardType or (board == boardType): | |
425 | if (vid, pid) in SupportedUF2Boards[board]["volumes"]: | |
426 | foundDevices.append(( | |
427 | board, | |
428 | port.description(), | |
429 | (vid, pid), | |
430 | )) | |
431 | ||
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
432 | # 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
|
433 | for board in SupportedUF2Boards: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
434 | if not boardType or (board == boardType): |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
435 | try: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
436 | # find mounted volume |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
437 | volumes = SupportedUF2Boards[board]["volumes"][(0, 0)] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
438 | foundVolumes = [] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
439 | for volume in volumes: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
440 | foundVolumes += Utilities.findVolume(volume, findAll=True) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
441 | if foundVolumes: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
442 | foundDevices.append(( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
443 | board, |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
444 | QCoreApplication.translate( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
445 | "UF2FlashDialog", "'{0}' Board").format(board), |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
446 | (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
|
447 | )) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
448 | except KeyError: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
449 | # no special treatment required, carry on |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
450 | pass |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
451 | |
8096 | 452 | return foundDevices |
453 | ||
454 | ||
455 | class UF2FlashDialog(QDialog, Ui_UF2FlashDialog): | |
456 | """ | |
457 | Class implementing a dialog to flash any UF2 capable device. | |
458 | """ | |
459 | DeviceTypeRole = Qt.UserRole | |
460 | DeviceVidPidRole = Qt.UserRole + 1 | |
461 | ||
462 | def __init__(self, boardType="", parent=None): | |
463 | """ | |
464 | Constructor | |
465 | ||
466 | @param boardType specific board type to show the dialog for | |
467 | @type str | |
468 | @param parent reference to the parent widget (defaults to None) | |
469 | @type QWidget (optional) | |
470 | """ | |
471 | super(UF2FlashDialog, self).__init__(parent) | |
472 | self.setupUi(self) | |
473 | ||
474 | self.refreshButton.setIcon(UI.PixmapCache.getIcon("rescan")) | |
475 | ||
476 | self.firmwarePicker.setMode(E5PathPickerModes.OpenFileMode) | |
477 | self.firmwarePicker.setFilters( | |
478 | self.tr("MicroPython/CircuitPython Files (*.uf2);;" | |
479 | "All Files (*)")) | |
480 | ||
481 | self.bootPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode) | |
482 | self.bootPicker.setEnabled(False) | |
483 | ||
484 | self.__mandatoryStyleSheet = ( | |
485 | "QLineEdit {border: 2px solid;border-color: #800000}" | |
486 | ) | |
487 | self.__manualType = "<manual>" | |
488 | ||
489 | self.__boardType = boardType | |
490 | ||
491 | self.__populate() | |
492 | ||
493 | self.__updateFlashButton() | |
494 | ||
495 | def __populate(self): | |
496 | """ | |
497 | Private method to (re-)populate the dialog. | |
498 | """ | |
499 | # save the currently selected device | |
500 | currentDevice = self.devicesComboBox.currentText() | |
501 | firmwareFile = self.firmwarePicker.text() | |
502 | ||
503 | # clear the entries first | |
504 | self.devicesComboBox.clear() | |
505 | self.firmwarePicker.clear() | |
506 | self.bootPicker.clear() | |
507 | self.infoLabel.clear() | |
508 | self.infoEdit.clear() | |
509 | ||
510 | # now populate the entries with data | |
511 | devices = getFoundDevices(boardType=self.__boardType) | |
512 | if len(devices) == 0: | |
513 | # no device detected | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
514 | devices = list(filter( |
8096 | 515 | lambda x: x[0] in SupportedUF2Boards, |
516 | MicroPythonDevices.getFoundDevices()[0] | |
8111
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
517 | )) |
8096 | 518 | if devices: |
519 | self.__showSpecificInstructions(list(devices)) | |
520 | else: | |
521 | self.__showAllInstructions() | |
522 | self.devicesComboBox.addItem("") | |
523 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
524 | self.devicesComboBox.setItemData(1, self.__manualType, | |
525 | self.DeviceTypeRole) | |
526 | elif len(devices) == 1: | |
527 | self.devicesComboBox.addItem(devices[0][1]) | |
528 | self.devicesComboBox.setItemData( | |
529 | 0, devices[0][0], self.DeviceTypeRole) | |
530 | self.devicesComboBox.setItemData( | |
531 | 0, devices[0][2], self.DeviceVidPidRole) | |
532 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
533 | self.devicesComboBox.setItemData(1, self.__manualType, | |
534 | self.DeviceTypeRole) | |
535 | self.on_devicesComboBox_currentIndexChanged(0) | |
536 | else: | |
537 | self.devicesComboBox.addItem("") | |
538 | for index, (boardType, description, | |
539 | vidpid) in enumerate(sorted(devices), 1): | |
540 | self.devicesComboBox.addItem(description) | |
541 | self.devicesComboBox.setItemData( | |
542 | index, boardType, self.DeviceTypeRole) | |
543 | self.devicesComboBox.setItemData( | |
544 | index, vidpid, self.DeviceVidPidRole) | |
545 | self.devicesComboBox.addItem(self.tr("Manual Select")) | |
546 | self.devicesComboBox.setItemData(index + 1, self.__manualType, | |
547 | self.DeviceTypeRole) | |
548 | ||
549 | # reselect the remembered device, if it is still there | |
550 | if currentDevice: | |
551 | self.devicesComboBox.setCurrentText(currentDevice) | |
552 | self.firmwarePicker.setText(firmwareFile) | |
553 | else: | |
554 | self.devicesComboBox.setCurrentIndex(0) | |
555 | ||
556 | def __updateFlashButton(self): | |
557 | """ | |
558 | Private method to update the state of the Flash button and the retest | |
559 | button. | |
560 | """ | |
561 | firmwareFile = self.firmwarePicker.text() | |
562 | if self.devicesComboBox.currentData(self.DeviceTypeRole) is not None: | |
563 | if bool(firmwareFile) and os.path.exists(firmwareFile): | |
564 | self.firmwarePicker.setStyleSheet("") | |
565 | else: | |
566 | self.firmwarePicker.setStyleSheet(self.__mandatoryStyleSheet) | |
567 | ||
568 | if bool(self.bootPicker.text()): | |
569 | self.bootPicker.setStyleSheet("") | |
570 | else: | |
571 | self.bootPicker.setStyleSheet(self.__mandatoryStyleSheet) | |
572 | else: | |
573 | self.firmwarePicker.setStyleSheet("") | |
574 | self.bootPicker.setStyleSheet("") | |
575 | ||
576 | enable = ( | |
577 | bool(self.bootPicker.text()) and | |
578 | bool(firmwareFile) and | |
579 | os.path.exists(firmwareFile) | |
580 | ) | |
581 | self.flashButton.setEnabled(enable) | |
582 | ||
583 | def __showAllInstructions(self): | |
584 | """ | |
585 | Private method to show instructions for resetting devices to bootloader | |
586 | mode. | |
587 | """ | |
588 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
589 | ||
590 | htmlText = self.tr( | |
591 | "<h4>No known devices detected.</h4>" | |
592 | "<p>Follow the appropriate instructions below to set <b>one</b>" | |
593 | " board into 'bootloader' mode. Press <b>Refresh</b> when ready." | |
594 | "</p>" | |
595 | ) | |
596 | for boardType in SupportedUF2Boards: | |
597 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
598 | self.infoEdit.setHtml(htmlText) | |
599 | ||
600 | def __showSpecificInstructions(self, devices): | |
601 | """ | |
602 | Private method to show instructions for resetting devices to bootloader | |
603 | mode for a list of detected devices. | |
604 | ||
605 | @param devices list of detected devices | |
606 | @type list of str | |
607 | """ | |
8099
522946e53835
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8097
diff
changeset
|
608 | boardTypes = {x[0] for x in devices} |
8096 | 609 | |
610 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
611 | ||
612 | if self.__boardType: | |
613 | htmlText = self.tr( | |
614 | "<h4>Flash {0} Firmware</h4>" | |
615 | "<p>Follow the instructions below to set <b>one</b> board into" | |
616 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
617 | "<hr/>{1}" | |
618 | ).format( | |
619 | SupportedUF2Boards[self.__boardType]["firmware"], | |
620 | SupportedUF2Boards[self.__boardType]["instructions"], | |
621 | ) | |
622 | else: | |
623 | htmlText = self.tr( | |
624 | "<h4>Potentially UF2 capable devices found</h4>" | |
625 | "<p>Found these potentially UF2 capable devices:</p>" | |
626 | "<ul><li>{0}</li></ul>" | |
627 | "<p>Follow the instructions below to set <b>one</b> board into" | |
628 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
629 | ).format( | |
630 | "</li><li>".join(sorted(x[1] for x in devices)) | |
631 | ) | |
632 | for boardType in sorted(boardTypes): | |
633 | htmlText += ( | |
634 | "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
635 | ) | |
636 | self.infoEdit.setHtml(htmlText) | |
637 | ||
638 | def __showTypedInstructions(self, boardType): | |
639 | """ | |
640 | Private method to show instructions for resetting devices to bootloader | |
641 | mode for a specific board type. | |
642 | ||
643 | @param boardType type of the board to show instructions for | |
644 | @type str | |
645 | """ | |
646 | self.infoLabel.setText(self.tr("Reset Instructions:")) | |
647 | ||
648 | htmlText = self.tr( | |
649 | "<h4>No known devices detected.</h4>" | |
650 | "<p>Follow the instructions below to set <b>one</b> board into" | |
651 | " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" | |
652 | ) | |
653 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
654 | self.infoEdit.setHtml(htmlText) | |
655 | ||
656 | def __showManualInstructions(self): | |
657 | """ | |
658 | Private method to show instructions for flashing devices manually. | |
659 | """ | |
660 | self.infoLabel.setText(self.tr("Flash Instructions:")) | |
661 | ||
662 | htmlText = self.tr( | |
663 | "<h4>Flash method 'manual' selected.</h4>" | |
664 | "<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
|
665 | " the data manually.</p><ol>" |
8096 | 666 | "<li>Change the device to 'bootloader' mode.</li>" |
667 | "<li>Wait until the device has entered 'bootloader' mode.</li>" | |
668 | "<li>Ensure the boot volume is available (this may require" | |
669 | " mounting it) and select its path.</li>" | |
670 | "<li>Select the firmware file to be flashed and click the" | |
671 | " flash button.</li>" | |
672 | "</ol>" | |
673 | ) | |
674 | for boardType in SupportedUF2Boards: | |
675 | htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"] | |
676 | self.infoEdit.setHtml(htmlText) | |
677 | ||
678 | def __showNoVolumeInformation(self, volumes): | |
679 | """ | |
680 | Private method to show information about the expected boot volume(s). | |
681 | ||
682 | @param volumes list of expected volume names | |
683 | @type list of str | |
684 | """ | |
685 | self.infoLabel.setText(self.tr("Boot Volume not found:")) | |
686 | ||
687 | htmlText = self.tr( | |
688 | "<h4>No Boot Volume detected.</h4>" | |
689 | "<p>Please ensure that the boot volume of the device to be flashed" | |
690 | " is available. " | |
691 | ) | |
692 | if len(volumes) == 1: | |
693 | htmlText += self.tr( | |
694 | "This volume should be named <b>{0}</b>." | |
695 | " Press <b>Refresh</b> when ready.</p>" | |
696 | ).format(volumes[0]) | |
697 | else: | |
698 | htmlText += self.tr( | |
699 | "This volume should have one of these names.</p>" | |
700 | "<ul><li>{0}</li></ul>" | |
701 | "<p>Press <b>Refresh</b> when ready.</p>" | |
702 | ).format("</li><li>".join(sorted(volumes))) | |
703 | self.infoEdit.setHtml(htmlText) | |
704 | ||
705 | def __showMultipleVolumesInformation(self, volumePaths): | |
706 | """ | |
707 | Private method to show information because multiple devices of the | |
708 | same type are ready for flashing. | |
709 | ||
710 | Note: This is a dangerous situation! | |
711 | ||
712 | @param volumePaths list of volume paths | |
713 | @type list of str | |
714 | """ | |
715 | self.infoLabel.setText(self.tr("Multiple Boot Volumes found:")) | |
716 | ||
717 | htmlText = self.tr( | |
718 | "<h4>Multiple Boot Volumes were found</h4>" | |
719 | "<p>These volume paths were found.</p><ul><li>{0}</li></ul>" | |
720 | "<p>Please ensure that only one device of a type is ready for" | |
721 | " flashing. Press <b>Refresh</b> when ready.</p>" | |
722 | ).format("</li><li>".join(sorted(volumePaths))) | |
723 | self.infoEdit.setHtml(htmlText) | |
724 | ||
725 | @pyqtSlot() | |
726 | def on_flashButton_clicked(self): | |
727 | """ | |
728 | Private slot to flash the selected MicroPython or CircuitPython | |
729 | firmware onto the device. | |
730 | """ | |
731 | boardType = self.devicesComboBox.currentData(self.DeviceTypeRole) | |
732 | firmwarePath = self.firmwarePicker.text() | |
733 | volumePath = self.bootPicker.text() | |
734 | 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
|
735 | if boardType == self.__manualType: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
736 | 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
|
737 | self.infoEdit.setHtml(self.tr( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
738 | "<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
|
739 | " 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
|
740 | ) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
741 | else: |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
742 | firmwareType = SupportedUF2Boards[boardType]["firmware"] |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
743 | self.infoLabel.setText( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
744 | self.tr("Flashing {0}").format(firmwareType)) |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
745 | self.infoEdit.setHtml(self.tr( |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
746 | "<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
|
747 | " until the device resets automatically.</p>" |
a8e9b387f701
UF2FlashDialog: added support for Raspberry Pi Pico.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8101
diff
changeset
|
748 | ).format(firmwareType)) |
8096 | 749 | QCoreApplication.processEvents(QEventLoop.ExcludeUserInputEvents) |
750 | shutil.copy2(firmwarePath, volumePath) | |
751 | QThread.sleep(1) | |
752 | self.on_refreshButton_clicked() | |
753 | ||
754 | @pyqtSlot() | |
755 | def on_refreshButton_clicked(self): | |
756 | """ | |
757 | Private slot to refresh the dialog. | |
758 | """ | |
759 | self.__populate() | |
760 | ||
761 | @pyqtSlot(int) | |
762 | def on_devicesComboBox_currentIndexChanged(self, index): | |
763 | """ | |
764 | Private slot to handle the selection of a board. | |
765 | ||
766 | @param index selected index | |
767 | @type int | |
768 | """ | |
769 | vidpid = self.devicesComboBox.itemData(index, self.DeviceVidPidRole) | |
770 | boardType = self.devicesComboBox.itemData(index, self.DeviceTypeRole) | |
771 | ||
772 | self.bootPicker.setEnabled(boardType == self.__manualType) | |
773 | if boardType == self.__manualType: | |
774 | self.__showManualInstructions() | |
775 | ||
776 | if vidpid is None: | |
777 | if boardType is None: | |
778 | self.bootPicker.clear() | |
779 | else: | |
780 | volumes = SupportedUF2Boards[boardType]["volumes"][vidpid] | |
781 | foundVolumes = [] | |
782 | for volume in volumes: | |
783 | foundVolumes += Utilities.findVolume(volume, findAll=True) | |
784 | ||
785 | if len(foundVolumes) == 0: | |
786 | self.__showNoVolumeInformation(volumes) | |
787 | self.bootPicker.clear() | |
788 | elif len(foundVolumes) == 1: | |
789 | self.bootPicker.setText(foundVolumes[0]) | |
790 | else: | |
791 | self.__showMultipleVolumesInformation() | |
792 | self.bootPicker.clear() | |
793 | ||
794 | self.__updateFlashButton() | |
795 | ||
796 | @pyqtSlot(str) | |
797 | def on_firmwarePicker_textChanged(self, text): | |
798 | """ | |
799 | Private slot handling a change of the firmware file. | |
800 | ||
801 | @param text current text of the firmware edit | |
802 | @type str | |
803 | """ | |
804 | self.__updateFlashButton() | |
805 | ||
806 | @pyqtSlot(str) | |
807 | def on_bootPicker_textChanged(self, text): | |
808 | """ | |
809 | Private slot handling a change of the boot volume. | |
810 | ||
811 | @param text current text of the boot volume edit | |
812 | @type str | |
813 | """ | |
814 | self.__updateFlashButton() |