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