flash-keil
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKeil MDK 烧录
Keil MDK Flashing
适用场景
Applicable Scenarios
- 中标明
Project Profile或工作区中存在build_system: keil/.uvprojx文件。.uvproj - 用户希望将编译产物烧录到目标板,且工程已在 Keil 中配置好调试器(ST-Link、J-Link、CMSIS-DAP 等)。
- 不需要额外安装 OpenOCD,直接使用 Keil MDK 内置的 Flash Download 功能。
- indicates
Project Profileor there arebuild_system: keil/.uvprojxfiles in the workspace..uvproj - Users want to flash compiled products to the target board, and the debugger (ST-Link, J-Link, CMSIS-DAP, etc.) has been configured in Keil for the project.
- No need to install additional OpenOCD; directly use the built-in Flash Download function of Keil MDK.
必要输入
Required Inputs
- /
.uvprojx工程文件路径(或从.uvproj获取)。Project Profile - 可选的构建目标名称和 UV4.exe 路径。
- Path to the /
.uvprojxproject file (or obtained from.uvproj).Project Profile - Optional build target name and UV4.exe path.
自动探测
Automatic Detection
- 复用 的 UV4.exe 探测逻辑(配置文件 → 环境变量 → 常见路径 → PATH)。
build-keil - 解析工程 XML 中的 识别调试器类型(ST-Link、J-Link、CMSIS-DAP、ULINK)。
<DriverSelection> - 若未指定目标,默认使用工程中的第一个 Target。
- Reuse the UV4.exe detection logic of (configuration file → environment variables → common paths → PATH).
build-keil - Parse in the project XML to identify the debugger type (ST-Link, J-Link, CMSIS-DAP, ULINK).
<DriverSelection> - If no target is specified, the first Target in the project is used by default.
执行步骤
Execution Steps
- 先阅读 references/usage.md,确认本次操作。
- 对于常见场景,直接一次调用完成探测+烧录:
bash
python scripts/keil_flasher.py --detect --flash --project <工程文件> --target <目标名> - 读取脚本输出的烧录结果报告,关注成功/失败状态、调试器类型和日志证据。
- 将烧录结果写回 ,推荐下一步 skill。
Project Profile
- First read references/usage.md to confirm this operation.
- For common scenarios, directly complete detection + flashing with one call:
bash
python scripts/keil_flasher.py --detect --flash --project <project file> --target <target name> - Read the flashing result report output by the script, focusing on success/failure status, debugger type, and log evidence.
- Write the flashing result back to and recommend the next skill.
Project Profile
失败分流
Failure Diversion
- :Keil MDK 未安装或 UV4.exe 不可用。
environment-missing - :调试器连接失败(USB 未连接、驱动问题、目标板未上电)。
connection-failure - :工程文件中的 Flash 配置无效或目标名不存在。
project-config-error
- : Keil MDK is not installed or UV4.exe is unavailable.
environment-missing - : Debugger connection failed (USB not connected, driver issue, target board not powered on).
connection-failure - : Invalid Flash configuration in the project file or target name does not exist.
project-config-error
平台说明
Platform Notes
- Keil MDK 烧录仅在 Windows 上支持。
- 烧录使用工程中已配置的调试器和 Flash 算法,无需额外配置。
- 烧录日志可能包含 GBK 编码字符,脚本自动处理多种编码。
- Keil MDK flashing is only supported on Windows.
- Flashing uses the debugger and Flash algorithm configured in the project, no additional configuration is required.
- Flashing logs may contain GBK encoded characters, and the script automatically handles multiple encodings.
输出约定
Output Conventions
脚本执行完成后,必须将以下关键信息提取并呈现给用户:
- 烧录状态(成功/失败)
- 工程文件和目标名
- 芯片型号(如 STM32F103RC)
- 调试器类型(如 ST-Link、J-Link)
- 烧录固件路径和大小(如 Demo02.axf, 519.6 KB)
- 烧录完成时间
- 若失败:失败分类和日志证据
示例输出格式:
烧录成功 ✅
工程: Demo02.uvprojx → 目标: Demo02
芯片: STM32F103RC | 调试器: ST-Link
固件: Demo02.axf (519.6 KB)
状态: Erase Done → Programming Done → Verify OK → Application running- 成功后推荐 (查看串口输出)或
serial-monitor(在线调试)。debug-gdb-openocd - 失败时输出失败分类和日志证据,帮助用户定位问题。
After the script is executed, the following key information must be extracted and presented to the user:
- Flashing status (success/failure)
- Project file and target name
- Chip model (e.g., STM32F103RC)
- Debugger type (e.g., ST-Link, J-Link)
- Flashed firmware path and size (e.g., Demo02.axf, 519.6 KB)
- Flashing completion time
- If failed: failure category and log evidence
Example output format:
Flashing succeeded ✅
Project: Demo02.uvprojx → Target: Demo02
Chip: STM32F103RC | Debugger: ST-Link
Firmware: Demo02.axf (519.6 KB)
Status: Erase Done → Programming Done → Verify OK → Application running- After success, recommend (view serial output) or
serial-monitor(online debugging).debug-gdb-openocd - When failed, output the failure category and log evidence to help users locate the problem.
交接关系
Handover Relationships
- 从 接收编译成功的工程信息。
build-keil - 烧录成功后交给 (查看串口输出)或
serial-monitor(在线调试)。debug-gdb-openocd
- Receive project information of successful compilation from .
build-keil - After successful flashing, hand over to (view serial output) or
serial-monitor(online debugging).debug-gdb-openocd