build-idf
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseESP-IDF 编译
ESP-IDF Compilation
适用场景
Applicable Scenarios
- 中标明
Project Profile或工作区包含 ESP-IDF 工程结构。build_system: idf - 用户希望对 ESP-IDF 工程执行目标芯片设置、编译或确认固件产物。
- 烧录或调试流程需要新的固件二进制文件。
- 需要在构建前确认 ESP-IDF 环境是否就绪。
- The specifies
Project Profileor the workspace contains an ESP-IDF project structure.build_system: idf - Users want to perform target chip configuration, compilation, or confirm firmware artifacts for an ESP-IDF project.
- A new firmware binary is required for flashing or debugging processes.
- Need to confirm whether the ESP-IDF environment is ready before building.
必要输入
Required Inputs
- 工作区路径,或一份已有的 。
Project Profile - 目标芯片(esp32、esp32s2、esp32s3、esp32c3、esp32c6、esp32h2 等)。
- Workspace path, or an existing .
Project Profile - Target chip (esp32, esp32s2, esp32s3, esp32c3, esp32c6, esp32h2, etc.).
首次参数确认
First-Time Parameter Confirmation
首次调用时,必须向用户确认以下参数,不得跳过或自动使用探测值:
- 目标芯片:即使 中已有
sdkconfig,首次也必须向用户确认。CONFIG_IDF_TARGET - IDF_PATH:若环境变量已设置,向用户展示当前值并确认是否正确。
当 中已记录过上述参数(即非首次),可直接复用,无需再次询问。
Project ProfileWhen calling for the first time, the following parameters must be confirmed with the user, and cannot be skipped or automatically detected values used:
- Target Chip: Even if exists in
CONFIG_IDF_TARGET, it must be confirmed with the user for the first time.sdkconfig - IDF_PATH: If the environment variable has been set, display the current value to the user and confirm whether it is correct.
When the above parameters have been recorded in the (i.e., not the first time), they can be directly reused without asking again.
Project Profile自动探测
Automatic Detection
- 检查 是否可用(
idf.py已设置且环境已激活)。IDF_PATH- ESP-IDF v5.x:通过 激活。
source $IDF_PATH/export.sh - ESP-IDF v6.0+:通过 EIM(ESP-IDF Installation Manager)激活,如 。
source ~/.espressif/tools/activate_idf_vX.Y.Z.sh
- ESP-IDF v5.x:通过
- 读取 中的
sdkconfig作为参考(首次仍需用户确认)。CONFIG_IDF_TARGET - 检查 和
CMakeLists.txt目录确认 ESP-IDF 工程结构。main/ - 若已有成功的构建目录且与当前意图一致,优先复用。
- 若目标芯片未设置且 不存在,必须先执行
sdkconfig。set-target
- Check if is available (the
idf.pyis set and the environment is activated).IDF_PATH- ESP-IDF v5.x: Activate via .
source $IDF_PATH/export.sh - ESP-IDF v6.0+: Activate via EIM (ESP-IDF Installation Manager), such as .
source ~/.espressif/tools/activate_idf_vX.Y.Z.sh
- ESP-IDF v5.x: Activate via
- Read in
CONFIG_IDF_TARGETas a reference (still need user confirmation for the first time).sdkconfig - Check the and
CMakeLists.txtdirectory to confirm the ESP-IDF project structure.main/ - If there is an existing successful build directory that matches the current intent, prioritize reusing it.
- If the target chip is not set and does not exist,
sdkconfigmust be executed first.set-target
执行步骤
Execution Steps
- 先阅读 references/usage.md,确认本次是环境探测、设置目标、执行构建,还是仅扫描产物。
- 若不确定环境是否就绪,先运行自带脚本 scripts/idf_builder.py 的 模式确认。
--detect - 若需要设置或切换目标芯片,使用 执行。
--set-target <chip> - 使用 执行构建。
--build --project <path> - 若用户需要修改 sdkconfig,提示手动运行 (交互式命令,不可自动执行)。
idf.py menuconfig - 读取脚本输出的构建结果和产物扫描报告。
- 将构建目录、产物路径、目标芯片信息写回 ,并在需要时交给下游 skill。
Project Profile
- First read references/usage.md to confirm whether this time is for environment detection, target configuration, build execution, or only artifact scanning.
- If unsure whether the environment is ready, first run the mode of the built-in script scripts/idf_builder.py to confirm.
--detect - If you need to set or switch the target chip, execute it using .
--set-target <chip> - Use to execute the build.
--build --project <path> - If the user needs to modify sdkconfig, prompt to manually run (interactive command, cannot be executed automatically).
idf.py menuconfig - Read the build results and artifact scan report output by the script.
- Write the build directory, artifact path, and target chip information back to the , and pass it to downstream skills when needed.
Project Profile
失败分流
Failure Diversion
- 当 不可用或
idf.py未设置时,返回IDF_PATH,提示用户手动安装 ESP-IDF。environment-missing - 当 或
CMakeLists.txt目录缺失时,返回main/。project-config-error - 当编译错误(语法错误、链接失败)时,返回 。
project-config-error - 当构建成功但未找到固件产物时,返回 。
artifact-missing - 当存在多个可能的目标芯片且用户未指定时,返回 。
ambiguous-context
- When is unavailable or
idf.pyis not set, returnIDF_PATHand prompt the user to manually install ESP-IDF.environment-missing - When the or
CMakeLists.txtdirectory is missing, returnmain/.project-config-error - When compilation errors occur (syntax errors, linking failures), return .
project-config-error - When the build is successful but no firmware artifacts are found, return .
artifact-missing - When multiple possible target chips exist and the user has not specified, return .
ambiguous-context
平台说明
Platform Notes
- 是跨平台的 Python 脚本,在所有宿主平台上行为一致。
idf.py - 自带脚本通过 subprocess 调用 ,需要确保 ESP-IDF 环境变量已激活。
idf.py - 构建目录默认为工程根目录下的 。
build/
- is a cross-platform Python script that behaves consistently on all host platforms.
idf.py - The built-in script calls via subprocess, which requires ensuring that the ESP-IDF environment variables are activated.
idf.py - The build directory defaults to under the project root directory.
build/
输出约定
Output Conventions
- 输出构建命令、构建目录、目标芯片、IDF 版本和首选产物路径。
- 用 、
artifact_path、artifact_kind、idf_target更新idf_version。Project Profile - 成功后推荐 。
flash-idf
- Output the build command, build directory, target chip, IDF version, and preferred artifact path.
- Update the with
Project Profile,artifact_path,artifact_kind,idf_target.idf_version - Recommend after success.
flash-idf
交接关系
Handover Relationships
- 当下一步意图是给硬件烧录程序时,将成功构建结果交给 。
flash-idf - 当 ESP-IDF 环境未安装时,提示用户手动安装 ESP-IDF。
- When the next step is to flash the program to hardware, pass the successful build result to .
flash-idf - When the ESP-IDF environment is not installed, prompt the user to manually install ESP-IDF.