# RTC: Tamper event detected on TAMP2, backup registers cleared, system must reinitialize

- **ID:** `embedded/rtc-tamper-battery-backed`
- **Domain:** embedded
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A tamper detection event on the RTC TAMP2 pin triggered automatic clearing of backup registers (BKP) to protect sensitive data, requiring full system reinitialization.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32L4 series | active | — | — |
| STM32CubeMX v6.9.0 | active | — | — |
| HAL_RTC v2.3.0 | active | — | — |

## Workarounds

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.** (85% success)
   ```
   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.** (75% success)
   ```
   After tamper detection, restore backup registers from a secure non-volatile store (e.g., external EEPROM or flash) if the tamper was false.
   ```

## Dead Ends

- **Disable the tamper detection feature entirely** — Removes security protection; may be unacceptable for applications requiring anti-tamper (e.g., metering, secure boot). (70% fail)
- **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% fail)
- **Reinitialize backup registers without checking tamper flag** — Overwrites valid data and masks the tamper event, potentially allowing unauthorized access to persist. (80% fail)
