--- a/src/eric7/MicroPython/UF2FlashDialog.py Tue Oct 17 11:46:54 2023 +0200 +++ b/src/eric7/MicroPython/UF2FlashDialog.py Sat Oct 21 18:18:19 2023 +0200 @@ -19,7 +19,7 @@ from eric7.EricWidgets import EricMessageBox from eric7.EricWidgets.EricApplication import ericApp from eric7.EricWidgets.EricPathPicker import EricPathPickerModes -from eric7.SystemUtilities import FileSystemUtilities +from eric7.SystemUtilities import FileSystemUtilities, OSUtilities from . import Devices from .Ui_UF2FlashDialog import Ui_UF2FlashDialog @@ -671,14 +671,24 @@ foundDevices = set() # step 1: determine all known UF2 volumes that are mounted + if not OSUtilities.isWindowsPlatform(): + userMounts = FileSystemUtilities.getUserMounts() + boardTypes = [boardType] if boardType else list(SupportedUF2Boards.keys()) for board in boardTypes: for vidpid, volumes in SupportedUF2Boards[board]["volumes"].items(): for volume, description in volumes: - if FileSystemUtilities.findVolume(volume, findAll=True): - foundDevices.add((board, description, vidpid)) + if OSUtilities.isWindowsPlatform(): + if FileSystemUtilities.findVolume(volume, findAll=True): + foundDevices.add((board, description, vidpid)) + else: + # check only user mounted devices on non-Windows systems + for userMount in userMounts: + if os.path.basename(userMount).startswith(volume): + foundDevices.add((board, description, vidpid)) + break - # set 2: determine all devices that have their UF2 volume not mounted + # step 2: determine all devices that have their UF2 volume not mounted availablePorts = QSerialPortInfo.availablePorts() for port in availablePorts: vid = port.vendorIdentifier() @@ -750,8 +760,7 @@ self.__boardType = boardType - self.__populate() - self.__updateFlashButton() + self.on_refreshButton_clicked() def __populate(self): """ @@ -783,7 +792,7 @@ else: self.__showAllInstructions() self.devicesComboBox.addItem(self.tr("Manual Select")) - self.devicesComboBox.setItemData(1, self.__manualType, self.DeviceTypeRole) + self.devicesComboBox.setItemData(0, self.__manualType, self.DeviceTypeRole) elif len(devices) == 1: # set the board type to the found one self.__boardType = devices[0][0] @@ -1035,6 +1044,7 @@ """ self.__populate() self.__updateFlashButton() + self.on_devicesComboBox_currentIndexChanged(0) @pyqtSlot(int) def on_devicesComboBox_currentIndexChanged(self, index): @@ -1098,12 +1108,21 @@ Private slot to look for all known boot paths and present a list to select from. """ foundBootVolumes = set() + if not OSUtilities.isWindowsPlatform(): + userMounts = FileSystemUtilities.getUserMounts() + for boardType in SupportedUF2Boards: for volumes in SupportedUF2Boards[boardType]["volumes"].values(): for volume, _ in volumes: - foundBootVolumes.update( - FileSystemUtilities.findVolume(volume, findAll=True) - ) + if OSUtilities.isWindowsPlatform(): + foundBootVolumes.update( + FileSystemUtilities.findVolume(volume, findAll=True) + ) + else: + # check only user mounted devices on non-Windows systems + for userMount in userMounts: + if os.path.basename(userMount).startswith(volume): + foundBootVolumes.add(userMount) if len(foundBootVolumes) == 0: selectedVolume = ""