# RTC：在TAMP2上检测到篡改事件，备份寄存器已清除，系统必须重新初始化

- **ID:** `embedded/rtc-tamper-battery-backed`
- **领域:** embedded
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

RTC TAMP2引脚上的篡改检测事件触发了自动清除备份寄存器（BKP）以保护敏感数据，需要完全重新初始化系统。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32L4 series | active | — | — |
| STM32CubeMX v6.9.0 | active | — | — |
| HAL_RTC v2.3.0 | active | — | — |

## 解决方案

1. ```
   Implement a debounce filter on the TAMP2 pin using a low-pass RC circuit (e.g., 10kΩ resistor + 100nF capacitor) to filter out transient glitches.
   ```
2. ```
   After tamper detection, restore backup registers from a secure non-volatile store (e.g., external EEPROM or flash) if the tamper was false.
   ```

## 无效尝试

- **Disable the tamper detection feature entirely** — Removes security protection; may be unacceptable for applications requiring anti-tamper (e.g., metering, secure boot). (70% 失败率)
- **Short-circuit TAMP2 pin to ground to prevent false triggers** — Damages the pin or causes short circuit; does not address the root cause of noise or mechanical tamper. (90% 失败率)
- **Reinitialize backup registers without checking tamper flag** — Overwrites valid data and masks the tamper event, potentially allowing unauthorized access to persist. (80% 失败率)
