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