src/eric7/MicroPython/UF2FlashDialog.py

branch
eric7
changeset 11208
f776db7cc222
parent 11178
52699bca6df9
child 11213
2bbdb06da276
equal deleted inserted replaced
11207:7193db06924d 11208:f776db7cc222
25 25
26 with contextlib.suppress(ImportError): 26 with contextlib.suppress(ImportError):
27 import usb.core 27 import usb.core
28 28
29 SupportedUF2Boards = { 29 SupportedUF2Boards = {
30 "MPy or CPy": { 30 "UF2 Board": {
31 "volumes": { 31 "volumes": {
32 (0x03EB, 0x2402): [ 32 (0x03EB, 0x2402): [
33 ("SAMD21", "SAMD21 Board"), 33 ("SAMD21", "SAMD21 Board"),
34 ("SAME54", "SAME54 Board"), 34 ("SAME54", "SAME54 Board"),
35 ], 35 ],
760 ("F303BOOT", "STM32F303 Discovery"), 760 ("F303BOOT", "STM32F303 Discovery"),
761 ], 761 ],
762 }, 762 },
763 "instructions": QCoreApplication.translate( 763 "instructions": QCoreApplication.translate(
764 "UF2FlashDialog", 764 "UF2FlashDialog",
765 "<h3>CircuitPython Board</h3>" 765 "<h3>MicroPython / CircuitPython Board</h3>"
766 "<p>In order to prepare the board for flashing follow these" 766 "<p>In order to prepare the board for flashing follow these"
767 " steps:</p><ol>" 767 " steps:</p><ol>"
768 "<li>Switch your device to 'bootloader' mode by double-pressing" 768 "<li>Switch your device to 'bootloader' mode by double-pressing"
769 " the reset button.</li>" 769 " the reset button.</li>"
770 "<li>Wait until the device has entered 'bootloader' mode.</li>" 770 "<li>Wait until the device has entered 'bootloader' mode.</li>"
819 819
820 def getFoundDevices(boardType=""): 820 def getFoundDevices(boardType=""):
821 """ 821 """
822 Function to get the list of known serial devices supporting UF2. 822 Function to get the list of known serial devices supporting UF2.
823 823
824 @param boardType specific board type to search for 824 @param boardType specific board type to search for. This string may contain
825 multiple board types concatenated with a '+' (plus) character.
825 @type str 826 @type str
826 @return list of tuples with the board type, the port description, the 827 @return list of tuples with the board type, the port description, the
827 VID and PID 828 VID and PID
828 @rtype list of tuple of (str, str, (int, int)) 829 @rtype list of tuple of (str, str, (int, int))
829 """ 830 """
832 # step 1: determine all known UF2 volumes that are mounted 833 # step 1: determine all known UF2 volumes that are mounted
833 userMounts = ( 834 userMounts = (
834 [] if OSUtilities.isWindowsPlatform() else FileSystemUtilities.getUserMounts() 835 [] if OSUtilities.isWindowsPlatform() else FileSystemUtilities.getUserMounts()
835 ) 836 )
836 837
837 boardTypes = [boardType] if boardType else list(SupportedUF2Boards) 838 boardTypes = (
839 [b.strip() for b in boardType.split("+")]
840 if boardType
841 else list(SupportedUF2Boards)
842 )
838 for board in boardTypes: 843 for board in boardTypes:
839 for vidpid, volumes in SupportedUF2Boards[board]["volumes"].items(): 844 for vidpid, volumes in SupportedUF2Boards[board]["volumes"].items():
840 for volume, description in volumes: 845 for volume, description in volumes:
841 if OSUtilities.isWindowsPlatform(): 846 if OSUtilities.isWindowsPlatform():
842 if FileSystemUtilities.findVolume( 847 if FileSystemUtilities.findVolume(
1053 """ 1058 """
1054 boardTypes = {x[0] for x in devices} 1059 boardTypes = {x[0] for x in devices}
1055 1060
1056 self.infoLabel.setText(self.tr("Flash Instructions:")) 1061 self.infoLabel.setText(self.tr("Flash Instructions:"))
1057 1062
1058 if self.__boardType: 1063 if self.__boardType and not "+" in self.__boardType:
1059 htmlText = self.tr( 1064 htmlText = self.tr(
1060 "<h4>Flash {0} Firmware</h4>" 1065 "<h4>Flash {0} Firmware</h4>"
1061 "<p>Follow the instructions below to set <b>one</b> board into" 1066 "<p>Follow the instructions below to set <b>one</b> board into"
1062 " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>" 1067 " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>"
1063 "<hr/>{1}" 1068 "<hr/>{1}"

eric ide

mercurial