Skip to content

fix(autoresearch): stabilize ObjectFLED bring-up path - #3358

Merged
zackees merged 1 commit into
masterfrom
codex/objectfled-bringup
Jun 24, 2026
Merged

zackees merged 1 commit into
masterfrom
codex/objectfled-bringup

Conversation

@zackees

@zackees zackees commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #3353.

Stabilizes the ObjectFLED AutoResearch path before the next valid-RX hardware pass.

Changes:

  • Increase ObjectFLED DMA chunk size to 60 and make both ObjectFLED headers agree regardless of include order.
  • Wait for ObjectFLED DMA completion before destruction and use delete[] for the frame buffer allocated with new[].
  • Keep AutoResearch hardware validation quiet with ScopedLogDisable while sending JSON-RPC responses through raw Serial, so response framing survives log suppression.
  • Move the Teensy 4 startup_early_hook into a .cpp file to avoid Arduino prototype/linkage issues during fbuild deploy.
  • Add captured-byte and zero-capture fields to RPC results so ObjectFLED failures distinguish "bad bytes" from "no RX capture" without FL_WARN spam.

Verification

bash autoresearch teensy41 --object-fled --tx-pin 8 --rx-pin 9 --strip-sizes 1 --timeout 2m

Result:

  • C++ lint passed.
  • fbuild deploy succeeded.
  • GPIO pretest passed for current physical 8 -> 9 jumper.
  • Run stopped honestly at setPins with RxChannelCreationFailed because RX pin 9 is not supported by the current capture backend.

Final ObjectFLED pass still requires rewiring to a supported RX capture pin, expected GPIO 8 -> GPIO 22 per #3353/#3355.

Summary by CodeRabbit

  • New Features

    • Improved AutoResearch run reporting with additional capture details, including captured bytes and capture-failure status.
    • Added early startup recovery support for Teensy 4 boards.
  • Bug Fixes

    • Improved stability around hardware capture and DMA handling.
    • Fixed memory cleanup for frame buffers and made shutdown wait for DMA transfers to complete safely.
    • Expanded failure diagnostics when a capture does not complete as expected.

@zackees
zackees merged commit 96aa404 into master Jun 24, 2026
7 of 10 checks passed
@zackees
zackees deleted the codex/objectfled-bringup branch June 24, 2026 17:49
@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5d94f256-752b-411b-823f-ac4cdc99e9ed

📥 Commits

Reviewing files that changed from the base of the PR and between 53686b5 and 0c813ac.

📒 Files selected for processing (10)
  • examples/AutoResearch/AutoResearch.ino
  • examples/AutoResearch/AutoResearchRemote.cpp
  • examples/AutoResearch/AutoResearchRemotePinMethods.cpp
  • examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
  • examples/AutoResearch/AutoResearchStartupHook.cpp
  • examples/AutoResearch/AutoResearchTest.cpp
  • examples/AutoResearch/AutoResearchTest.h
  • src/third_party/object_fled/src/ObjectFLED.h
  • src/third_party/object_fled/src/ObjectFLEDDmaManager.h
  • src/third_party/object_fled/src/OjectFLED.cpp.hpp

📝 Walkthrough

Walkthrough

The PR extracts the Teensy 4 WDOG3 watchdog early startup hook from AutoResearch.ino into a dedicated AutoResearchStartupHook.cpp. It adds capturedBytes and captureFailed fields to fl::RunResult and propagates them through test execution and RPC serialization. RPC serial output is rerouted through direct Serial.println/Serial.flush calls, and setDebug now controls the FastLED log level. ObjectFLED's DMA buffer default (BYTES_PER_DMA) is increased from 20 to 60, and the destructor is fixed to use delete[] and a dedicated waitForDmaToFinish() helper.

Changes

AutoResearch Diagnostics, Logging, and Startup Hook

Layer / File(s) Summary
Teensy 4 WDOG3 startup hook extraction
examples/AutoResearch/AutoResearchStartupHook.cpp, examples/AutoResearch/AutoResearch.ino
New file defines extern "C" startup_early_hook that configures WDOG3 registers with inline barriers and bounded polling. The .ino removes the prior inline hook and updates setup() to call init_serial_buffers(), fl::serial_begin(115200), and set log level to FL_LOG_LEVEL_NONE.
RunResult capture-failure diagnostics
examples/AutoResearch/AutoResearchTest.h, examples/AutoResearch/AutoResearchTest.cpp, examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
fl::RunResult gains capturedBytes and captureFailed fields. runMultiTest() populates these when capture() returns 0. Per-pattern failure JSON in runSingleTestImpl emits both new fields.
RPC serial routing and log-level control
examples/AutoResearch/AutoResearchRemote.cpp, examples/AutoResearch/AutoResearchRemotePinMethods.cpp, examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
Introduces printRemoteResponseRaw helper using Serial.println/Serial.flush directly, wired into fl::Remote constructor. setDebug RPC handler now calls fl::setLogLevel. Test execution wraps with fl::ScopedLogDisable to suppress output during timing-sensitive validation.

ObjectFLED DMA Buffer and Destructor Fixes

Layer / File(s) Summary
DMA buffer size and destructor corrections
src/third_party/object_fled/src/ObjectFLED.h, src/third_party/object_fled/src/ObjectFLEDDmaManager.h, src/third_party/object_fled/src/OjectFLED.cpp.hpp
BYTES_PER_DMA default increased from 20 to 60 in both headers, guarded with #ifndef. Destructor replaces microsecond busy-wait with waitForDmaToFinish() and fixes delete to delete[] for frameBufferLocal.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2297: Both PRs update AutoResearchTest.cpp to record capturedBytes/captureFailed on capture failure in runMultiTest() so truncated RX runs hard-fail rather than silently pass.
  • FastLED/FastLED#2753: Direct inverse relationship — that PR added the WDOG3-disarming hook inline in AutoResearch.ino; this PR removes it from there and moves it into the new AutoResearchStartupHook.cpp.
  • FastLED/FastLED#3342: Both PRs modify AutoResearchTest.cpp around runMultiTest() capture-failure diagnostics and logging behavior.

Poem

🐇 Hop hop, the watchdog's tamed at dawn,
In its own file, before setup's drawn.
The RPC whispers straight through Serial's wire,
While log levels dim the diagnostic fire.
DMA buffers triple, destructors mend,
Every captured byte accounted to the end! ✨

✨ 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 codex/objectfled-bringup

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.

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