reset_reason
Read reset-cause flags and core state over hotplug to diagnose unexpected reboots or watchdog resets without resetting or halting the target.
Instructions
读复位原因(RCC_RSR 标志)与内核运行状态,走 hotplug:不复位、不停内核。
回答「板子为什么自己重启了」「是不是看门狗喂狗没喂上」这类问题。 RCC_RSR 会给出 PINRSTF(复位引脚)/ BORRSTF(欠压)/ SFTRSTF(软件)/ IWDGRSTF(独立看门狗)/ WWDGRSTF(窗口看门狗)/ LPWRRSTF(低功耗退出)。
★ 关键理解:这些标志是【累积】的,只有写 RMVF 或整片掉电才清。 所以「好几个位同时为 1」= 「自上次清零以来发生过这几类复位」, 不等于「最后一次是它们一起发生」。 要定位「这一次」:先 clear_flags=True + confirm=True 清零 → 复现 → 再读。 clear_flags 不可逆(销毁现场),受隔离层管辖且需 confirm=True。 then_reset 只在 clear_flags=True 时有意义:清零并读回验证后再复位一次, 让内核继续跑(默认 True)。
★ 哪些动作会自己置标志(实测,用来区分「真复位」与「读操作自带的噪声」): hotplug 连接(仅连接)→ 不置任何标志; normal 连接(仅连接)→ PINRSTF|SFTRSTF; hotplug + -rst → PINRSTF|SFTRSTF; hotplug + -hardRst → 仅 PINRSTF。 所以清零后读回还看到 PINRSTF/SFTRSTF 几乎总是命令自己造成的,不是 RMVF 没生效。
★ 为什么必须 hotplug:STM32CubeProgrammer 以 normal 档连接动作本身就会复位目标 并 halt 内核。用 normal 读复位原因,读到的第一个标志就是这次读操作自己造成的 —— 结论必然错。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sn | No | ||
| confirm | No | ||
| then_reset | No | ||
| clear_flags | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |