AgentSkillsCN

ESP-IDF Terminal

如何在本项目中运行 ESP-IDF 命令(idf.py)。

SKILL.md
--- frontmatter
name: ESP-IDF Terminal
description: How to run ESP-IDF commands (idf.py) in this project

ESP-IDF Terminal

This project uses ESP-IDF installed via the Espressif VS Code extension. The ESP-IDF environment is not available in a default shell — you must source a PowerShell profile script first.

Discovering the Environment

  1. Read .vscode/settings.json and find the idf.currentSetup value — this is IDF_PATH.
  2. Find the PowerShell profile script by searching for Microsoft.*PowerShell_profile.ps1 under the ESP-IDF tools directory (typically C:\Espressif\tools\ on Windows).
powershell
# Example: discover the profile script
Get-ChildItem -Path "C:\Espressif\tools" -Filter "Microsoft.*PowerShell_profile.ps1" -Recurse | Select -First 1

Running idf.py Commands

Source the discovered PowerShell profile, then run idf.py:

powershell
& '<path-to-PowerShell-profile>'; idf.py <command>

Common Commands

powershell
# Set target chip
& '<profile>'; idf.py set-target esp32s3

# Build
& '<profile>'; idf.py build

# Clean build
& '<profile>'; idf.py fullclean

# Flash and monitor
& '<profile>'; idf.py flash monitor

# Open menuconfig
& '<profile>'; idf.py menuconfig

Important Notes

  • Always source the profile script before running idf.py. The idf.py.exe wrapper alone will fail without the full environment.
  • Do NOT use export.bat or export.ps1 from the ESP-IDF source tree — they reference a different Python venv path and will fail.
  • The working directory must be the project root.
  • Build commands are long-running — use WaitMsBeforeAsync: 10000 and poll with command_status.
  • Dependencies are managed via main/idf_component.yml (ESP-IDF Component Manager).