Skip to content

fix(watchdog/avr): gate hardware impl behind classic-AVR symbol presence (refs #2779) - #2780

Merged
zackees merged 1 commit into
masterfrom
fix/avr-watchdog-classic-symbol-guards
Jun 5, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/avr-watchdog-classic-symbol-guards

Conversation

@zackees

@zackees zackees commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

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

Family Symbols present Behavior after fix
ATmega328P, 2560, etc. (classic AVR) yes unchanged — full hardware impl
ATtiny85 / 88 / 4313 (classic ATtiny) yes unchanged — full hardware impl
ATmega8 / 8A (original ATmega8) no (caps at WDTO_2S, uses MCUCSR) noop fallback
ATmega4809 a.k.a. nano_every (megaAVR-0) no (RSTCTRL peripheral) noop fallback
ATtiny1604 / 1616 (tinyAVR-1) no (RSTCTRL peripheral) noop fallback

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

  • Bug Fixes
    • Enhanced AVR platform compatibility by adding conditional watchdog support. The firmware now builds successfully on additional AVR chip families (megaAVR-0, tinyAVR-1) with automatic fallback to a no-op mode when hardware watchdog support is unavailable.

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]>
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 06c736cb-9639-4b33-afee-2ba001f00a3d

📥 Commits

Reviewing files that changed from the base of the PR and between d471d94 and f9c7e44.

📒 Files selected for processing (1)
  • src/platforms/avr/watchdog_avr.impl.hpp

📝 Walkthrough

Walkthrough

This PR adds a preprocessor capability gate to watchdog_avr.impl.hpp that conditionally includes either the classic-AVR hardware watchdog implementation or a no-op fallback, depending on whether required watchdog and reset-cause symbols are available in the target's headers.

Changes

AVR Watchdog Conditional Compilation

Layer / File(s) Summary
Classic-AVR watchdog symbol detection and fallback
src/platforms/avr/watchdog_avr.impl.hpp
Detects presence of classic-AVR watchdog symbols (WDTO_8S, MCUSR, WDRF, BORF, EXTRF, PORF); when absent, includes platforms/shared/watchdog_noop.hpp instead of the hardware implementation, allowing firmware to link on targets like megaAVR-0 and tinyAVR-1 without watchdog support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐰 A watchdog once guarded the classic AVR home,
But some modern chips had symbols unknown—
Now a gentle gate checks what's near,
And when symbols disappear,
A quiet no-op lets them safely roam. ⏰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a guard to conditionally compile the AVR watchdog implementation based on classic-AVR symbol availability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/avr-watchdog-classic-symbol-guards

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit a4c7233 into master Jun 5, 2026
6 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 5, 2026
@zackees
zackees deleted the fix/avr-watchdog-classic-symbol-guards branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant