28 Commits

Author SHA1 Message Date
ef19d19da2 Add ESP-IDF integration component with two-tier loading
Fix idf.py path bug (tools/idf.py in ESP-IDF v5.x) that prevented
auto-detection. Add get_idf_path_found() for toolchain management
without requiring a fully configured environment.

Tier 1 (idf_path_found): idf_tools_list, idf_tools_check,
idf_tools_install, idf_env_info — always available when IDF directory
exists with idf_tools.py.

Tier 2 (idf_available): idf_build_project, idf_flash_project,
idf_monitor — require full IDF env, gate checked at invocation time
so they unlock after install without restart.

Includes input validation (target names, tool names, baud rates),
centralized subprocess cleanup via _run_idf_py, mtime-based cache
invalidation for tools.json, and esp://idf/status resource with
per-target readiness map.
2026-02-25 19:52:50 -07:00
34bc2e2d86 Use generic git icon for source link in docs nav
Repo is on Gitea, not GitHub — the octocat was misleading.
2026-02-25 17:04:49 -07:00
c6a55a5e8f Merge feature/smart-backup: partition-aware flash backup and restore
Adds esp_smart_backup and esp_smart_restore tools with chunked reads,
adaptive sizing, skip-empty detection, gzip compression, SHA256
verification, and an esp_backup_plan prompt for pre-flight planning.

Hardened against 11 code review findings including path traversal
protection, atomic manifest writes, and timeout caps.
2026-02-25 17:01:22 -07:00
ca893f1bbd Add smart backup tools to reference docs
Also fix Flash Operations count (6 tools, not 7).
2026-02-25 16:17:39 -07:00
a07b3a0fd3 Harden smart backup against review findings
- Path traversal protection: validate manifest file paths stay within
  backup directory (prevents ../../etc/passwd in crafted manifests)
- Input validation: reject chunk_mb outside 1-16 range
- Memory: _is_chunk_empty uses count() instead of allocating comparison buffer
- Type safety: accept bytes | bytearray in hash/empty-check helpers
- Timeout cap: _compute_chunk_timeout capped at 240s (MCP limit is 300s)
- Manifest schema: validate required fields before processing
- Disk full: wrap file writes in OSError handling with partial_backup path
- Atomic manifest: write via temp+rename to prevent corrupt state
- Decompression cache: avoid decompressing twice during restore
- Tempfile race: close NamedTemporaryFile before Path.write_bytes
- Unused variable: replace sum(1 for v in ...) with len()
2026-02-25 16:17:09 -07:00
9fa314dae9 Add partition-aware smart backup and restore
Adds SmartBackupManager component that reads the partition table first,
then backs up each partition individually with chunked reads to stay
under the 300s MCP timeout. Solves timeout issues on large flash devices
(e.g. 16 MB ESP32-P4).

Tools: esp_smart_backup, esp_smart_restore
Prompt: esp_backup_plan (estimates backup time per partition)

Features:
- Adaptive chunk sizing based on measured throughput
- Skip-empty detection (0xFF regions)
- Optional gzip compression per partition
- SHA256 manifest for integrity verification
- Dry-run mode for time estimation
- Progress reporting via MCP context
2026-02-25 16:09:10 -07:00
6c71fbc319 Fix flash operations tool count in reference index
Heading said 7 tools but the table correctly listed 6.
2026-02-25 16:06:16 -07:00
f8dfa90fba Add live product catalog to docs site
Espressif product data fetched at build time via Content Layer API
and rendered as browsable Starlight pages. Alpine.js provides
client-side filtering by series, type, connectivity, and status.

- Products content collection with inline API loader + Zod schema
- Filterable browse page at /products/ with card grid
- Individual spec sheet pages at /products/[id]/ (94 products)
- Separate CSS with dark/light theme support
- Sidebar section linking to catalog
- Cross-references to MCP tool reference docs
2026-02-25 16:02:43 -07:00
dab9c6848e Add Espressif product catalog integration
5 new MCP tools for chip/module discovery, comparison, and procurement
planning using Espressif's public product catalog API. Data is lazily
fetched and cached in-memory with a 24h TTL.

Tools: esp_product_search, esp_product_info, esp_chip_compare,
esp_product_recommend, esp_product_availability
Resource: esp://products/catalog
2026-02-24 13:33:34 -07:00
58f9b3a4df Redesign landing page with conversation example and capability overview
Enriches the splash page from a bare title + 4 cards into a full
product page: hero SVG illustration, example detect→flash→verify
conversation, tabbed install instructions, supported chips table,
and capability summary. Frames content around MCP protocol rather
than any specific client.
2026-02-24 10:37:00 -07:00
b2ba0cd67a Upgrade to FastMCP 3.x, add Starlight docs site
Dependency changes:
- fastmcp >=2.12.4 → >=3.0.2,<4
- Drop asyncio-mqtt (dead dependency, never imported)
- Align pydantic, click, rich with FastMCP 3.x
- Bump version to 2026.02.23

Docs site (docs-site/):
- Astro Starlight with Tailwind v4 teal theme
- 28 pages following Diataxis: 3 tutorials, 7 how-to guides,
  13 reference pages, 4 explanation pages
- Docker infrastructure (Caddy prod, Node HMR dev)
- Configured for mcesptool.warehack.ing
2026-02-23 18:57:16 -07:00
6623cfa016 Add MIT license 2026-02-06 21:12:15 -07:00
d5dc9c99c0 Rename package to mcesptool
- Rename mcp-esptool-server -> mcesptool
- Update all imports and references
- Single entry point: mcesptool command
- New home: git.supported.systems/MCP/mcesptool
2026-02-06 21:08:53 -07:00
57953fc60f Add flash workflow and development iteration tools
New tools:
- esp_flash_multi: Flash multiple binaries at different addresses in one operation
- esp_verify_flash: Verify flash contents match a file without re-flashing
- esp_load_ram: Load and execute binary in RAM for rapid development
- esp_serial_monitor: Capture serial output from device
- esp_elf_to_ram_binary: Convert ELF to RAM-loadable binary

Fixes:
- Use hyphenated esptool commands (load-ram, verify-flash) to avoid deprecation warnings
- Fix verify_flash parser for esptool v5.x output format
- Fix flash_multi command ordering for esptool v5.x CLI structure

Documentation updated with flash operations table and RAM loading workflow.
2026-02-06 01:02:16 -07:00
972f09b2d2 Remove error output truncation for better diagnostics 2026-02-05 09:57:13 -07:00
78dc7e1279 Refactor chip_control to subprocess pattern, remove middleware layer
- Rewrite chip_control.py to use esptool CLI subprocess exclusively
- Delete middleware/ directory (~830 lines): esptool_middleware, logger_interceptor, middleware_factory
- Remove `import esptool` library dependency (keep as CLI tool only)
- Remove mypy override for esptool module
- Add address parameter to esp_flash_firmware to prevent bootloader overwrites
2026-02-05 09:56:35 -07:00
9d232305c6 Implement firmware builder, OTA manager, and production tools
Replace all remaining stub implementations with real functionality:

- firmware_builder: elf2image conversion and image-info analysis
- ota_manager: package creation (zip+manifest), HTTP deploy via curl,
  rollback by erasing otadata partition
- production_tools: factory programming (erase/flash/verify pipeline),
  batch parallel programming, QC test suites (basic + extended)
2026-01-31 09:02:34 -07:00
9810d35637 Remove esp_binary_optimize tool
No real esptool operation backs "optimize firmware binary". Size
optimization happens at compile-time via ESP-IDF menuconfig, not as
a post-processing step on a .bin file. The analysis use case is
already covered by esp_firmware_analyze.
2026-01-30 21:38:14 -07:00
f2f2dbd5eb Fix eFuse summary parser for espefuse v5.x output format
The R/W permission field uses 'R/W' not just 'R' at end of line,
and values can be 'False', '0', hex, or binary representations.
2026-01-30 20:52:09 -07:00
945939bdad Implement security manager, diagnostics, and partition manager
Security manager: eFuse read/burn via espefuse, security audit
combining chip-id + get-security-info + eFuse summary, flash
encryption status checking.

Diagnostics: memory dump with hex formatting via dump-mem,
performance profiling by timing esptool operations, diagnostic
report combining chip-id + read-mac + flash-id.

Partition manager: OTA partition table generation with auto-layout,
custom partition table from config dict with validation, binary
partition table parsing from flash reads at 0x8000.
2026-01-30 20:32:48 -07:00
9fe57005c3 Remove --no-stub from flash operations for faster transfers
The ROM bootloader (--no-stub) runs at ~62 kbit/s which causes
timeouts on large images. The stub flasher is dramatically faster
and works correctly over QEMU socket connections.
2026-01-30 11:40:54 -07:00
609928ff6e Implement flash manager operations (write, read, erase, backup)
Replace stub implementations with real esptool subprocess calls.
Each operation runs esptool as an async subprocess with timeout,
matching the chip_control pattern. All four tools now work with
both physical ports and QEMU socket:// URIs.
2026-01-29 16:33:25 -07:00
3818599b94 Fix port allocation to ignore stopped instances
Port allocator was counting stopped QEMU instances as occupying ports,
preventing new starts after stop-all. Only running instances now block
port reuse. Stopped instances with flash images on disk are preserved
for esp_qemu_flash; truly stale entries are purged.
2026-01-29 16:23:36 -07:00
ff138c492e Fix QEMU version detection and remove unsupported ESP32-S2
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.
2026-01-28 16:59:24 -07:00
cb4822a0a4 Document QEMU emulation in README and improve tool descriptions
Add QEMU section to README with install instructions and tool reference.
Enrich MCP tool docstrings with workflow context, cross-references to
related tools, and guidance on when to use each tool — these descriptions
are read by the calling LLM to decide tool selection.
2026-01-28 16:48:39 -07:00
740164f582 Add download mode, efuse emulation, and watchdog disable to QEMU manager
Smoke tested against real Espressif QEMU fork — esptool successfully
identifies, reads flash_id, and writes firmware to emulated ESP32 via
socket://localhost:5555. Enriched CHIP_MACHINES with per-chip efuse
data, GPIO strap values, and watchdog timer driver names derived from
ESP-IDF's qemu_ext.py.
2026-01-28 16:44:17 -07:00
0d684088a4 Fix esptool skip condition to use shutil.which
The test was hardcoded to check /usr/bin/esptool, but esptool lives
in ~/.local/bin/ on this system. Use shutil.which() to properly
search PATH.
2026-01-28 15:46:55 -07:00
64c1505a00 Add QEMU ESP32 emulation support
Integrate Espressif's QEMU fork for virtual ESP device management:

- QemuManager component with 5 MCP tools (start/stop/list/status/flash)
- Config auto-detects QEMU binaries from ~/.espressif/tools/
- Supports esp32, esp32s2, esp32s3, esp32c3 chip emulation
- Virtual serial over TCP (socket://localhost:PORT) transparent to esptool
- Scan integration: QEMU instances appear in esp_scan_ports results
- Blank flash images initialized to 0xFF (erased NOR flash state)
- 38 unit tests covering lifecycle, port allocation, flash writes
2026-01-28 15:35:22 -07:00