Fault Injection & Debugging
Testing IWDG, WWDG and watchdog starvation resets in CI
Inject a sensor deadlock or infinite loop and verify hardware watchdog reset plus RCC_CSR reset-cause logging in CI.
A watchdog that is refreshed inside a timer ISR instead of the main control loop passes every happy-path test while letting deadlocked application tasks hang forever in the field.
CircuitTwin runs hardware watchdog countdowns in virtual time so CI can stall a peripheral, let the watchdog expire, and assert that firmware boots back cleanly with IWDGRSTF set.
Watchdog checks in CI
| Watchdog type | Fault tested | Required verification |
|---|---|---|
Independent (IWDG) | Main task hangs on bus lockup | MCU resets within timeout and logs RCC_CSR.IWDGRSTF |
Window (WWDG) | Refresh too early or too late | Immediate reset on window violation |
External PMIC (TLF35584) | Missed SPI/WDI trigger pulse | PMIC drives ROT reset pin and logs fault |
Local CLI workflow
Shell - run watchdog starvation recovery test
ct test run --json --junit results/wdt.xml tests/watchdog.suite.yamlSuite & fault configuration
tests/watchdog.suite.yaml
version: 1
board: nucleo-f446re
firmware: build/wdt_app.elf
tests:
- name: task-deadlock-triggers-iwdg-reset
timeout_ms: 4000
faults:
- at_ms: 300
bus: I2C1
kind: nack
address: 0x68
count: 100
expect:
console_contains: "RESET_CAUSE_IWDG"
exit_code: 0CI pipeline integration
.github/workflows/watchdog-ci.yml
name: Watchdog Starvation CI
on: [push, pull_request]
jobs:
wdt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: circuittwin/action@v1
with:
suite: tests/watchdog.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| Watchdog never fires during deadlock test | Move HAL_IWDG_Refresh() out of SysTick/timer ISRs into a health supervisor that checks every task bitmask. |
| Reset cause shows POR instead of IWDG on every boot | Clear reset flags via RCC_CSR.RMVF after reading them at startup. |
Frequently asked questions
| Question | Answer |
|---|---|
| Why should firmware never kick the watchdog inside a periodic timer ISR? | If the main control loop deadlocks while interrupts remain enabled, a timer ISR keeps kicking the watchdog indefinitely and defeats the safety reset. |