Skip to content

Watchdog Phase 2: per-platform hardware impls (Teensy / RP / nRF / STM / SAMD / AVR / Apollo3 / MGM240 / WASM) #2744

Closed

Description

@zackees

Follow-up to #2731 (closed). Phase 1 (#2738) landed the unified fl::Watchdog API surface + dispatcher + no-op fallback + stub host impl + ESP32 wrapper. Every platform compiles and routes correctly; this issue tracks adding the real hardware-backed implementations for each remaining platform.

Each platform is independent and can be a separate PR. The dispatcher path is already wired — adding a platform means:

  1. Add src/platforms/<family>/watchdog_<family>.impl.hpp implementing the fl::Watchdog methods + Watchdog::instance() singleton + the FL_WATCHDOG_* capability macros it supports.
  2. Add the #elif defined(FL_IS_<PLATFORM>) branch in src/platforms/watchdog.impl.cpp.hpp.
  3. Validate on hardware via bash autoresearch <board>.

Per-platform punch list

  • Teensy 4.x (iMXRT1062) — WDT_T4<WDT3> + CrashReport bridge. Highest priority — fixes the AutoResearch bricking documented in AutoResearch.ino:204-214. Wraps the bundled Watchdog_t4.h. Backed by OCRAM2 retained region for crash counter, EEPROM emulation for persistence across power-cycle.
  • Teensy 3.x (K20/K66/KL26) — direct WDOG register code with the one-shot unlock window; requires intercepting startup_early_hook(). Persist via FlexNVM EEPROM.
  • RP2040 — hardware/watchdog.h + watchdog_caused_reboot() for cause detection + watchdog_hw->scratch[0..3] for crash counter (scratch[4..7] are SDK/bootrom-reserved). rebootIntoBootloader() via reset_usb_boot().
  • RP2350 — same as RP2040 plus POWMAN.CHIP_RESET for richer cause detection and POWMAN.SCRATCH[0..7] for VBAT-backed power-cycle-surviving persist.
  • nRF52 (Adafruit BSP) — NRF_WDT registers + POWER->RESETREAS for cause. Persist via GPREGRET/GPREGRET2 — must avoid Adafruit bootloader sentinel values (0x57, 0xA8, 0x4e, 0x90, 0xB0).
  • STM32 — IWDG + RTC BKPxR for persist, optional WWDG for window mode + pre-reset EWI. Per-core variant cleanup may be needed (F1/F4/F7/H7/L4/G0/G4 + Giga R1 mbed wrapping).
  • SAMD21 — WDT peripheral + PM->RCAUSE + FlashStorage library for persist. Mind WDT register sync busy waits.
  • SAMD51 — WDT peripheral + RSTC->RCAUSE + SmartEEPROM (wear-leveled, configured via NVMCTRL fuses) for persist + window mode support.
  • AVR (atmega328/2560/attiny85) — avr/wdt.h + EEPROM for persist + .init3 MCUSR=0 / wdt_disable() bootloop fix (critical — without it, post-WDT-reset boards loop forever on Optiboot-less variants).
  • Apollo3 (SparkFun Artemis) — am_hal_wdt_* SDK functions + RSTGEN->STAT for cause + flash for persist (no GPREGRET-equivalent).
  • MGM240 (EFR32MG24, SiLabs Arduino core) — WDOG0/WDOG1 via em_wdog.h + EMU->RSTCAUSE + BURAM / RETREG / NVM3 for persist. Beware Matter stack may claim WDOG1.
  • WASM emulated — currently routes to noop. Add emscripten timer integration (emscripten_set_timeout style) + localStorage / IDBFS for persist.

Cross-cutting follow-ups (Tier 1/2 surface)

  • Watchdog::onTimeout(fl::function<void()>) overload — currently returns false on ESP32. Implement the small allocator-aware trampoline.
  • setPauseOnDebug() for RP (already supported by Pico SDK), STM32 (via DBGMCU freeze).
  • setWindow() for STM32 WWDG / SAMD / MGM240 / Teensy 4.
  • hasCrashReport()/readCrashReport() for Teensy 4 (CrashReport bridge), ESP32 (core dump partition), SAMD51 (CFSR), MGM240 (CFSR via M33 SAU).
  • writeCrashLog()/readCrashLog() for any platform with flash (NVS on ESP32, EEPROM/SmartEEPROM, LittleFS).
  • ESP32 persist storage — currently in-RAM (not crash-resistant). Move to RTC_NOINIT_ATTR on variants with RTC slow memory and __NOINIT_ATTR on ESP32-P4 (which has none). The persist tail already stores the crash counter — just needs the storage attribute change.

Reference

Activity

  1. zackees commented on Jun 4, 2026

    @zackees
    MemberAuthor

    Superseded by PR #2745 — Phase 2 hardware impls all rolled into one PR per the original goal directive.

  2. moved this from Triage to Done in FastLED Trackeron Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions