Report watchdog restarts and which loop step stalled
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c
- Domain
- embedded-iot
Research direction
Read src/utils/watchdog.cpp and src/hello_robot.cpp, especially run() and crash_report(), then compare how teensy4/CrashReport.cpp reads SRC_SRSR and how teensy4/imxrt.h defines its watchdog bit. Trace the main loop steps and watchdog callback; test on a bare Teensy with a temporary forced hang, removing it before opening a PR. Done means a watchdog restart logs its cause and last loop step, while normal power-on logs no watchdog message.
Written by the indexing model from the issue text.
Description
When the main loop stalls, the watchdog restarts the Teensy, but nothing tells us it was the watchdog or which part of the loop hung. See the TODO in src/utils/watchdog.cpp ("Read and print a flag to identify the cause of stall").
Good first task. Needs a bare Teensy, no robot.
Files
src/utils/watchdog.cpp,src/utils/watchdog.hppsrc/hello_robot.cpp(run()andcrash_report())teensy4/CrashReport.cpp(reference, readsSRC_SRSRaround line 160)teensy4/imxrt.h(SRC_SRSR_*bits)
Steps
- Our watchdog is
WDT_T4<WDT1>, which sets theSRC_SRSR_WDOG_RST_Bbit inSRC_SRSRon reset.CrashReport.breadcrumb(n, value)stores a value that survives a restart. - In
HelloRobot::run(), before each main step (sensors, controls, comms, ...), record a step number withCrashReport.breadcrumb(1, step). Use a small enum for the steps. - At boot, before
crash_report(), readSRC_SRSR. If the watchdog bit is set, log "Restarted by watchdog" and the last step viaSystemLog. - Don't clear
SRC_SRSRyourself;CrashReportreads it too. CheckCrashReport.cppbefore writing to the register. - Fill in the TODO in
watchdog_callback()by printing the current step there as well. - Test on a bare Teensy with a temporary forced hang (
while (true) {}inside one step). Remove it before opening the PR.
Done when
- After a forced hang, the next boot says the watchdog caused the restart and names the step.
- A normal power-on prints no watchdog message.
Related: #211 (safety asserts currently end in a watchdog reset).
- Dominant language
- C
- Stars
- 11
- Forks
- 2
- Avg merge
- 18d 3h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CU-Robotics/firmware
-
good first issue not started
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
CU-Robotics/firmware#257 ·
-
Pre-flight checksOpenin progress
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
CU-Robotics/firmware#222 ·
-
Fix existing clang-tidy findingsPossibly taken @roccoagain claimed this today. Open
CU-Robotics/firmware#262 · 1 assignee ·
-
not started
Difficulty 5/5 Over a week Newbie friendliness 35/100
CU-Robotics/firmware#258 ·
-
in progress software-in-the-loop
Difficulty 4/5 3-5 days Newbie friendliness 42/100
CU-Robotics/firmware#250 · 1 comment ·
All issues in CU-Robotics/firmware
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
schrodinger/pymol-open-source#532 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
CTSRD-CHERI/cheribsd#2769 ·
Maintainers usually reply within 2 days
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
severity: low
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
luainkernel/lunatik#2633 ·
Maintainers usually reply within 1 day
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day