From ff138c492e26796b16211967bb9735c05aa4acbf Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Wed, 28 Jan 2026 16:59:24 -0700 Subject: [PATCH] Fix QEMU version detection and remove unsupported ESP32-S2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort glob results when auto-detecting QEMU binaries to reliably pick the newest version. Previously filesystem ordering could select an older build (8.2.0 instead of 9.0.0), missing ESP32-S3 support. Remove ESP32-S2 from CHIP_MACHINES — the Espressif QEMU fork has no esp32s2 machine type. --- README.md | 2 +- src/mcp_esptool_server/components/qemu_manager.py | 8 ++------ src/mcp_esptool_server/config.py | 10 +++++----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f8d76af..8d04ee2 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ The server auto-detects QEMU binaries from `~/.espressif/tools/`. Once available | Tool | Description | |------|-------------| -| `esp_qemu_start` | Launch a virtual ESP device (supports esp32, esp32s2, esp32s3, esp32c3) | +| `esp_qemu_start` | Launch a virtual ESP device (supports esp32, esp32s3, esp32c3) | | `esp_qemu_stop` | Stop a running instance | | `esp_qemu_list` | List all running instances | | `esp_qemu_status` | Detailed instance info | diff --git a/src/mcp_esptool_server/components/qemu_manager.py b/src/mcp_esptool_server/components/qemu_manager.py index 79785b7..ddc99b3 100644 --- a/src/mcp_esptool_server/components/qemu_manager.py +++ b/src/mcp_esptool_server/components/qemu_manager.py @@ -28,6 +28,7 @@ logger = logging.getLogger(__name__) # Chip type to QEMU machine/binary/efuse mapping. # Derived from ESP-IDF's tools/idf_py_actions/qemu_ext.py. +# Note: ESP32-S2 is not supported by the Espressif QEMU fork (no machine type exists). CHIP_MACHINES: dict[str, dict[str, Any]] = { "esp32": { "machine": "esp32", @@ -44,11 +45,6 @@ CHIP_MACHINES: dict[str, dict[str, Any]] = { "00000000" ), }, - "esp32s2": { - "machine": "esp32s2", - "arch": "xtensa", - "memory": "4M", - }, "esp32s3": { "machine": "esp32s3", "arch": "xtensa", @@ -168,7 +164,7 @@ class QemuManager: 4. esp_qemu_start (normal mode, same flash image) -> boot firmware Args: - chip_type: Target chip (esp32, esp32s2, esp32s3, esp32c3) + chip_type: Target chip (esp32, esp32s3, esp32c3) flash_image: Path to existing flash image file. Creates a blank erased flash (all 0xFF) if not specified. flash_size_mb: Flash size in MB when creating blank images (default: 4) diff --git a/src/mcp_esptool_server/config.py b/src/mcp_esptool_server/config.py index 5f790dc..acc8715 100644 --- a/src/mcp_esptool_server/config.py +++ b/src/mcp_esptool_server/config.py @@ -145,17 +145,17 @@ class ESPToolServerConfig: import glob if not self.qemu_xtensa_path: - matches = glob.glob( + matches = sorted(glob.glob( str(Path.home() / ".espressif/tools/qemu-xtensa/*/qemu/bin/qemu-system-xtensa") - ) + )) if matches: - self.qemu_xtensa_path = matches[-1] # latest version + self.qemu_xtensa_path = matches[-1] logger.info(f"Auto-detected QEMU Xtensa: {self.qemu_xtensa_path}") if not self.qemu_riscv_path: - matches = glob.glob( + matches = sorted(glob.glob( str(Path.home() / ".espressif/tools/qemu-riscv32/*/qemu/bin/qemu-system-riscv32") - ) + )) if matches: self.qemu_riscv_path = matches[-1] logger.info(f"Auto-detected QEMU RISC-V: {self.qemu_riscv_path}")