FastLED 3.10.8
Loading...
Searching...
No Matches
AutoResearchStartupHook.cpp
Go to the documentation of this file.
1// Early-boot loop guard: the bench recovers by itself when a firmware hangs
2// or crash-loops, including before USB comes up. Each boot that never reaches
3// loop() counts toward the escape; the third drops into the bootloader so the
4// next deploy can flash the board. The platform owns the details (see
5// fl/wdt/boot_guard.h); where it has no early-boot hook this is a no-op.
6//
7// The guard lives in this .cpp, not the .ino: Arduino prototype generation can
8// give .ino startup hooks C++ linkage. setup() ends with markBootHealthy().
9//
10// Hardware test: build with -DFL_WATCHDOG_DEBUG_EARLY_HANG and the board hangs
11// before USB on every boot; it must come back in its bootloader by itself.
12
13#include "FastLED.h"
15
16// Only the full sketch marks the boot healthy at the end of setup(); the
17// low-memory surface (AutoResearchLowMemory.h) never does, so it must not arm
18// a guard that would count its successful warm boots toward the escape.
19#if FL_PLATFORM_HAS_LARGE_MEMORY
20#include "fl/wdt/boot_guard.h"
21
22#ifndef AUTORESEARCH_BOOT_GUARD_ESCAPE_BOOTS
23#define AUTORESEARCH_BOOT_GUARD_ESCAPE_BOOTS 3
24#endif
25
26// Covers USB bring-up, static constructors and setup(), which re-arms the
27// watchdog with its own timeout.
28#ifndef AUTORESEARCH_BOOT_GUARD_TIMEOUT_MS
29#define AUTORESEARCH_BOOT_GUARD_TIMEOUT_MS 30000
30#endif
31
32FL_WATCHDOG_BOOT_GUARD(AUTORESEARCH_BOOT_GUARD_ESCAPE_BOOTS,
33 AUTORESEARCH_BOOT_GUARD_TIMEOUT_MS);
34
35#endif // FL_PLATFORM_HAS_LARGE_MEMORY
#define FL_WATCHDOG_BOOT_GUARD(escape_boots, early_timeout_ms)
Definition boot_guard.h:58
Early-boot loop guard: escape to the bootloader when firmware keeps failing before it ever reaches a ...