flash-keil

Original🇨🇳 Chinese
Translated
1 scriptsChecked / no sensitive code detected

Used when you need to flash firmware to the target board using the built-in debugger of Keil MDK, which executes the download with the debugger and Flash algorithm configured in the project.

3installs
Added on

NPX Install

npx skill4agent add leokemp223/embed-ai-tool flash-keil

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Keil MDK Flashing

Applicable Scenarios

  • Project Profile
    indicates
    build_system: keil
    or there are
    .uvprojx
    /
    .uvproj
    files in the workspace.
  • 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

  • Path to the
    .uvprojx
    /
    .uvproj
    project file (or obtained from
    Project Profile
    ).
  • Optional build target name and UV4.exe path.

Automatic Detection

  • Reuse the UV4.exe detection logic of
    build-keil
    (configuration file → environment variables → common paths → PATH).
  • Parse
    <DriverSelection>
    in the project XML to identify the debugger type (ST-Link, J-Link, CMSIS-DAP, ULINK).
  • If no target is specified, the first Target in the project is used by default.

Execution Steps

  1. First read references/usage.md to confirm this operation.
  2. For common scenarios, directly complete detection + flashing with one call:
    bash
    python scripts/keil_flasher.py --detect --flash --project <project file> --target <target name>
  3. Read the flashing result report output by the script, focusing on success/failure status, debugger type, and log evidence.
  4. Write the flashing result back to
    Project Profile
    and recommend the next skill.

Failure Diversion

  • environment-missing
    : Keil MDK is not installed or UV4.exe is unavailable.
  • connection-failure
    : Debugger connection failed (USB not connected, driver issue, target board not powered on).
  • project-config-error
    : Invalid Flash configuration in the project file or target name does not exist.

Platform Notes

  • 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

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
    serial-monitor
    (view serial output) or
    debug-gdb-openocd
    (online debugging).
  • When failed, output the failure category and log evidence to help users locate the problem.

Handover Relationships

  • Receive project information of successful compilation from
    build-keil
    .
  • After successful flashing, hand over to
    serial-monitor
    (view serial output) or
    debug-gdb-openocd
    (online debugging).