Repository navigation
fix(watchdog/avr): gate hardware impl behind classic-AVR symbol presence (refs #2779) - #2780
Conversation
The AVR watchdog hardware impl introduced in commit ca09808 ("feat(watchdog): real per-platform hardware impls for ALL platforms (#2731 Phase 2) (#2745)") unconditionally referenced classic-AVR symbols (`MCUSR`, `WDRF`, `BORF`, `EXTRF`, `PORF`, `WDTO_8S`) that are not declared on every AVR variant: * ATmega8 / ATmega8A — original ATmega8 caps WDT prescaler at WDTO_2S; WDTO_4S / WDTO_8S are not defined, and reset cause sits in MCUCSR. * megaAVR-0 / tinyAVR-1 (ATmega4809 / nano_every, ATtiny1604, ATtiny1616) — new RSTCTRL peripheral for reset cause and new WDT (`WDT.CTRLA`); the legacy MCUSR / WDTO_* names are not declared at all. This broke `bash compile` and the corresponding GitHub Actions builds for atmega8a, nano_every, ATtiny1604, and ATtiny1616. Gate the existing implementation behind a single capability check (`WDTO_8S && MCUSR && WDRF && BORF && EXTRF && PORF`). When the classic surface isn't present, fall back to the shared no-op watchdog so the firmware still links. Hardware WDT support for the megaAVR-0 / tinyAVR-1 and ATmega8 families can be added later as a follow-up per-family impl without changing the dispatcher. Verified locally with `bash compile` on all 8 AVR-family boards in the README badge set: PASS atmega8a (previously broken — uses noop fallback now) PASS nano_every (previously broken — uses noop fallback now) PASS ATtiny1604 (previously broken — uses noop fallback now) PASS ATtiny1616 (previously broken — uses noop fallback now) PASS uno (still uses full hardware impl) PASS attiny85 (still uses full hardware impl) PASS attiny88 (still uses full hardware impl) PASS attiny4313 (still uses full hardware impl) Refs #2779 — partial fix (closes the 4 AVR-family build failures). The remaining 8 README badges flagged in that issue (apollo3, rp2040, stm32 giga, size checks, top-level build, AVR8JS QEMU) have independent root causes and will be addressed in follow-up PRs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a preprocessor capability gate to ChangesAVR Watchdog Conditional Compilation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fix the AVR watchdog hardware impl regression that broke 4 README-listed builds:
atmega8a,nano_every,attiny1604,attiny1616. These chips do not declare the classic-AVR symbols (`MCUSR`, `WDRF`, `BORF`, `EXTRF`, `PORF`, `WDTO_8S`) that the new per-platform watchdog impl assumed were universal.Introduced by commit `ca09808` — "feat(watchdog): real per-platform hardware impls for ALL platforms (#2731 Phase 2) (#2745)".
What the fix does
Adds a single capability gate at the top of `src/platforms/avr/watchdog_avr.impl.hpp`:
```cpp
#if !(defined(WDTO_8S) && defined(MCUSR) && defined(WDRF) &&
defined(BORF) && defined(EXTRF) && defined(PORF))
#include "platforms/shared/watchdog_noop.hpp"
#else
// ... existing hardware implementation ...
#endif
```
When the required classic-AVR symbols aren't all present, the file falls back to the platform-agnostic no-op watchdog (already used by every platform without hardware WDT). Net effect: the firmware links and runs on every AVR chip; `Watchdog` calls become no-ops on the chips without the symbol surface, instead of being compile-time hard errors.
Real hardware WDT support for the megaAVR-0 / tinyAVR-1 and ATmega8 families can land later as separate per-family impls — that's a feature addition; this PR is purely a build-unbreak.
Affected chip families
Test plan
Verified locally with `bash compile` (per CLAUDE.md). 4 previously-broken boards + 4 previously-working AVR boards as a regression guard:
```
PASS atmega8a (previously broken — uses noop fallback now)
PASS nano_every (previously broken — uses noop fallback now)
PASS ATtiny1604 (previously broken — uses noop fallback now)
PASS ATtiny1616 (previously broken — uses noop fallback now)
PASS uno (still uses full hardware impl)
PASS attiny85 (still uses full hardware impl)
PASS attiny88 (still uses full hardware impl)
PASS attiny4313 (still uses full hardware impl)
```
`bash lint` clean.
Scope
🤖 Generated with Claude Code
Summary by CodeRabbit