Repository navigation
Closed
Description
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:
- Add
src/platforms/<family>/watchdog_<family>.impl.hppimplementing thefl::Watchdogmethods +Watchdog::instance()singleton + theFL_WATCHDOG_*capability macros it supports. - Add the
#elif defined(FL_IS_<PLATFORM>)branch insrc/platforms/watchdog.impl.cpp.hpp. - Validate on hardware via
bash autoresearch <board>.
Per-platform punch list
- Teensy 4.x (iMXRT1062) —
WDT_T4<WDT3>+CrashReportbridge. Highest priority — fixes the AutoResearch bricking documented inAutoResearch.ino:204-214. Wraps the bundledWatchdog_t4.h. Backed by OCRAM2 retained region for crash counter, EEPROM emulation for persistence across power-cycle. - Teensy 3.x (K20/K66/KL26) — direct
WDOGregister code with the one-shot unlock window; requires interceptingstartup_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()viareset_usb_boot(). - RP2350 — same as RP2040 plus
POWMAN.CHIP_RESETfor richer cause detection andPOWMAN.SCRATCH[0..7]for VBAT-backed power-cycle-surviving persist. - nRF52 (Adafruit BSP) —
NRF_WDTregisters +POWER->RESETREASfor cause. Persist viaGPREGRET/GPREGRET2— must avoid Adafruit bootloader sentinel values (0x57,0xA8,0x4e,0x90,0xB0). - STM32 — IWDG + RTC
BKPxRfor 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 —
WDTperipheral +PM->RCAUSE+ FlashStorage library for persist. Mind WDT register sync busy waits. - SAMD51 —
WDTperipheral +RSTC->RCAUSE+ SmartEEPROM (wear-leveled, configured via NVMCTRL fuses) for persist + window mode support. - AVR (atmega328/2560/attiny85) —
avr/wdt.h+ EEPROM for persist +.init3MCUSR=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->STATfor cause + flash for persist (no GPREGRET-equivalent). - MGM240 (EFR32MG24, SiLabs Arduino core) —
WDOG0/WDOG1viaem_wdog.h+EMU->RSTCAUSE+ BURAM / RETREG / NVM3 for persist. Beware Matter stack may claimWDOG1. - WASM emulated — currently routes to noop. Add emscripten timer integration (
emscripten_set_timeoutstyle) +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 (viaDBGMCUfreeze). -
setWindow()for STM32 WWDG / SAMD / MGM240 / Teensy 4. -
hasCrashReport()/readCrashReport()for Teensy 4 (CrashReportbridge), 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_ATTRon variants with RTC slow memory and__NOINIT_ATTRon ESP32-P4 (which has none). The persist tail already stores the crash counter — just needs the storage attribute change.
Reference
- API design: Unified cross-platform Watchdog Timer API via FastLED.watchdog() singleton #2731 (closed)
- Phase 1 implementation: feat(watchdog): Phase 1 — unified fl::Watchdog API + host/stub/ESP32 impls #2738 (merged in
c2faf92e) - Conventions: docs(conventions): codify noop fallback and FL_<COMPONENT>_HAS_* macro patterns #2732 (merged) —
agents/docs/cpp-standards.mdType 3 capability macros +_noop.hppfallback rules - Existing ESP32 watchdog (wrapped by Phase 1):
src/platforms/esp/32/watchdog_esp32.{h,_idf4.hpp,_idf5.hpp} - AutoResearch call site (current ESP32-only
fl::watchdog_setup):examples/AutoResearch/AutoResearch.ino:314-316
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 4, 2026
Superseded by PR #2745 — Phase 2 hardware impls all rolled into one PR per the original goal directive.