diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2846b11df..ca98576d0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ Version history * Fix MicroPython config page regression introduced in 4.1.0b1 (#2724, #2763) * Fix code completion shortcut displayed in macOS menu * Add command "Show esptool version" for ESP flasher +* Don't disconnect for ESP flasher commands which don't touch the device * Close tab on middle click (#2767) by @mrexodia * Make package manager support new micropython-lib index (#2777) * Report macOS version instead of Darwin version in the About box diff --git a/thonny/plugins/micropython/base_flashing_dialog.py b/thonny/plugins/micropython/base_flashing_dialog.py index c9c89ae49..4c244b8ba 100644 --- a/thonny/plugins/micropython/base_flashing_dialog.py +++ b/thonny/plugins/micropython/base_flashing_dialog.py @@ -408,9 +408,6 @@ def start_work(self): target_info: TargetInfo = self._target_combo.get_selected_value() self.report_progress(0, 100) - proxy = get_runner().get_backend_proxy() - if isinstance(proxy, BareMetalMicroPythonProxy): - proxy.disconnect() work_options = self.prepare_work_get_options() self.clear_log() diff --git a/thonny/plugins/micropython/esptool_dialog.py b/thonny/plugins/micropython/esptool_dialog.py index e1a5d31a9..bd698178b 100644 --- a/thonny/plugins/micropython/esptool_dialog.py +++ b/thonny/plugins/micropython/esptool_dialog.py @@ -225,13 +225,17 @@ def get_variants_url(self) -> str: def get_action_text_max_length(self): return 35 + def _work_needs_disconnect(self): + return self._work_mode not in ["image_info", "esptool_version"] + def prepare_work_get_options(self) -> Dict[str, Any]: target = self._target_combo.get_selected_value() proxy = get_runner().get_backend_proxy() port_was_used_in_thonny = ( isinstance(proxy, BareMetalMicroPythonProxy) and proxy._port == target.port.device ) - if port_was_used_in_thonny: + if port_was_used_in_thonny and self._work_needs_disconnect(): + logger.info("Disconnecting") proxy.disconnect() if self._work_mode in ["device_info", "image_info", "esptool_version"]: @@ -329,10 +333,7 @@ def perform_core_operation( else: raise RuntimeError(f"Unknown work mode {self._work_mode!r}") - if ( - self._work_mode in ["install", "device_info"] - and work_options["port_was_used_in_thonny"] - ): + if self._work_needs_disconnect() and work_options["port_was_used_in_thonny"]: self.append_text("Disconnecting from REPL...") self.set_action_text("Disconnecting from REPL...") time.sleep(1.5)