Skip to main content
Glama

进入调试模式

enter_debug
Idempotent

Enter Keil debug mode for ARM Cortex-M targets, automatically waiting until the target is ready and freezing watchdogs to prevent reset during halt.

Instructions

自动进入 Keil 调试模式(UV_DBG_ENTER)。若目标本来就在调试态(status=10 正在调试),不会报失败,而是返回 ok=true + already_in_debug=true + note,可省掉一轮 exit/enter;返回 ready/ready_waited_ms 表示已确认就绪。受工程 Load/Flash Download/Run-to-main 设置影响,属于有副作用的操作:若工程 Utilities 勾选了 Update Target before Debugging(.uvprojx 的 Utilities/Flash1/UpdateFlashBeforeDebugging=1),Keil 会在进入调试前自动把最新 .axf 下载进 Flash(等价一次烧录)——此时编译完直接 enter_debug 即可,不必先 flash_download;该选项为 0 时 Keil 不下载,板上可能仍是旧固件(可用 read_project_config 查该字段)。进入后即可设断点、读变量、运行控制。注意:若当前 Keil 是旧窗口、加载旧固件,进入后调试的是旧代码符号;建议改用 flash_debug 闭环(关旧Keil→编烧→重开→进调试)。受工程 Load/Flash Download/Run-to-main 设置影响,属有副作用操作。需 UVSOCK 已开启。真机实测:进入调试是异步的——命令返回成功时目标尚未挂载完成,约 0.6~0.7s 后才真正就绪,期间紧接的读内存/表达式/断点命令会返回 status=6(Target is not in debug mode)。本工具已自动轮询等待就绪(默认最多 6s),返回 ready 与 ready_waited_ms;若超时未就绪会给出 warning,此时先读内存会失败,请检查目标板连接或 Keil 是否弹窗待确认。看门狗防御(真机踩过):新会话/复位后 DBGMCU 的 IWDG/WWDG 冻结位会被清零,目标 halt 超过看门狗溢出时间(典型 1.626s)就会被看门狗复位、RAM 现场全丢。本工具默认在就绪后自动置位冻结位(freeze_watchdogs=true),返回 watchdog_freeze 供核对;万一失败会带 warning,此时请尽快手动调 watchdog_freeze(action="enable")。 【参数】必填: 无;可选: freeze_watchdogs 【调用示例】{} 【风险】中——会改变目标状态或占用共享资源(调试态/串口/Keil 实例),必要时可回退。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
freeze_watchdogsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.8

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond annotations (readOnlyHint=false, idempotentHint=true), the description discloses extensive behavioral details: async entry timing (~0.6-0.7s), automatic polling and ready status, watchdog freezing with fallback warning, and optional flash download side effects. It also warns about potential pitfalls like old symbol loading and suggests the flash_debug closed loop. This far exceeds what annotations provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections and bold warnings, but it has notable redundancy: the sentence '受工程 Load/Flash Download/Run-to-main 设置影响,属于有副作用的操作' (or similar) appears twice, and the side-effect statement is repeated. While the detail is valuable, not every sentence earns its place, and the text could be tightened by ~15-20% without losing information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (side effects, async behavior, watchdog interactions, failure modes), the description is remarkably complete. It covers return fields (ok, already_in_debug, ready, ready_waited_ms, watchdog_freeze), error conditions (status=6, timeout warnings), and recovery steps. Nothing essential is missing for correct invocation and interpretation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With schema coverage at 0% and only one parameter (freeze_watchdogs), the description fully compensates by explaining its purpose (freeze watchdog bits to prevent resets), the default behavior (auto-enable), and the failure handling (warning + manual call suggestion). This adds significant value beyond the bare Boolean type.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: automatically enters Keil debug mode (UV_DBG_ENTER). It distinguishes itself from siblings like exit_debug and flash_debug by explaining the entry mechanism and the alternative closed-loop workflow. The purpose is unambiguous and specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: when to use (e.g., after compilation with UpdateFlashBeforeDebugging=1), when to avoid (if old firmware might be present, recommending flash_debug instead), and prerequisites (UVSOCK enabled). It also notes idempotent behavior when already in debug, saving an exit/enter cycle.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.