eric6/MicroPython/UF2FlashDialog.py

changeset 8167
cdc1b6692766
parent 8143
2c730d5fd177
child 8170
fb77bff32621
diff -r bd5cd5858503 -r cdc1b6692766 eric6/MicroPython/UF2FlashDialog.py
--- a/eric6/MicroPython/UF2FlashDialog.py	Sun Mar 21 14:17:16 2021 +0100
+++ b/eric6/MicroPython/UF2FlashDialog.py	Sun Mar 21 18:00:30 2021 +0100
@@ -373,6 +373,38 @@
         "firmware": "CircuitPython",
     },
     
+    "circuitpython_rp2040": {
+        "volumes": {
+            (0x239A, 0x80F4): [
+                "RPI-RP2",        # Raspberry Pi Pico loaded with CircuitPython
+            ],
+        },
+        "instructions": QCoreApplication.translate(
+            "UF2FlashDialog",
+            "<h3>Pi Pico (RP2040) Board</h3>"
+            "<p>In order to prepare the board for flashing follow these"
+            " steps:</p><ol>"
+            "<li>Enter 'bootloader' mode (board <b>without</b> RESET button):"
+            "<ul>"
+            "<li>Plug in your board while holding the BOOTSEL button.</li>"
+            "</ul>"
+            "Enter 'bootloader' mode (board <b>with</b> RESET button):"
+            "<ul>"
+            "<li>hold down RESET</li>"
+            "<li>hold down BOOTSEL</li>"
+            "<li>release RESET</li>"
+            "<li>release BOOTSEL</li>"
+            "</ul></li>"
+            "<li>Wait until the device has entered 'bootloader' mode.</li>"
+            "<li>Ensure the boot volume is available (this may require"
+            " mounting it).</li>"
+            "<li>Select the firmware file to be flashed and click the"
+            " flash button.</li>"
+            "</ol>"
+        ),
+        "firmware": "CircuitPython",
+    },
+    
     "rp2040": {
         "volumes": {
             (0x0000, 0x0000): [
@@ -384,7 +416,17 @@
             "<h3>Pi Pico (RP2040) Board</h3>"
             "<p>In order to prepare the board for flashing follow these"
             " steps:</p><ol>"
+            "<li>Enter 'bootloader' mode (board <b>without</b> RESET button):"
+            "<ul>"
             "<li>Plug in your board while holding the BOOTSEL button.</li>"
+            "</ul>"
+            "Enter 'bootloader' mode (board <b>with</b> RESET button):"
+            "<ul>"
+            "<li>hold down RESET</li>"
+            "<li>hold down BOOTSEL</li>"
+            "<li>release RESET</li>"
+            "<li>release BOOTSEL</li>"
+            "</ul></li>"
             "<li>Wait until the device has entered 'bootloader' mode.</li>"
             "<li>Ensure the boot volume is available (this may require"
             " mounting it).</li>"
@@ -421,7 +463,7 @@
             continue
         
         for board in SupportedUF2Boards:
-            if not boardType or (board == boardType):
+            if not boardType or (board.startswith(boardType)):
                 if (vid, pid) in SupportedUF2Boards[board]["volumes"]:
                     foundDevices.append((
                         board,
@@ -524,6 +566,9 @@
             self.devicesComboBox.setItemData(1, self.__manualType,
                                              self.DeviceTypeRole)
         elif len(devices) == 1:
+            # set the board type to the found one
+            self.__boardType = devices[0][0]
+            
             self.devicesComboBox.addItem(devices[0][1])
             self.devicesComboBox.setItemData(
                 0, devices[0][0], self.DeviceTypeRole)
@@ -675,12 +720,14 @@
             htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"]
         self.infoEdit.setHtml(htmlText)
     
-    def __showNoVolumeInformation(self, volumes):
+    def __showNoVolumeInformation(self, volumes, boardType):
         """
         Private method to show information about the expected boot volume(s).
         
         @param volumes list of expected volume names
         @type list of str
+        @param boardType type of the board to show instructions for
+        @type str
         """
         self.infoLabel.setText(self.tr("Boot Volume not found:"))
         
@@ -700,6 +747,15 @@
                 "<ul><li>{0}</li></ul>"
                 "<p>Press <b>Refresh</b> when ready.</p>"
             ).format("</li><li>".join(sorted(volumes)))
+        
+        if boardType:
+            htmlText += self.tr(
+                "<h4>Reset Instructions</h4>"
+                "<p>Follow the instructions below to set the board into"
+                " 'bootloader' mode. Press <b>Refresh</b> when ready.</p>"
+            )
+            htmlText += "<hr/>" + SupportedUF2Boards[boardType]["instructions"]
+        
         self.infoEdit.setHtml(htmlText)
     
     def __showMultipleVolumesInformation(self, volumePaths):
@@ -757,6 +813,10 @@
         """
         Private slot to refresh the dialog.
         """
+        # special treatment for RPi Pico
+        if self.__boardType == "circuitpython_rp2040":
+            self.__boardType = "rp2040"
+        
         self.__populate()
     
     @pyqtSlot(int)
@@ -784,7 +844,7 @@
                 foundVolumes += Utilities.findVolume(volume, findAll=True)
             
             if len(foundVolumes) == 0:
-                self.__showNoVolumeInformation(volumes)
+                self.__showNoVolumeInformation(volumes, boardType)
                 self.bootPicker.clear()
             elif len(foundVolumes) == 1:
                 self.bootPicker.setText(foundVolumes[0])

eric ide

mercurial