Repository navigation
feat(channels): remove FASTLED_DISABLE_LEGACY_DRIVER_REGISTRY (default-as-opt-in, closes binary-bloat half of #2421) - #2469
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (31)
📝 WalkthroughWalkthroughRemoves legacy auto-registration macro, adds a typed CFastLED/ChannelManager exclusive-driver template API, makes per-platform initChannelDrivers no-ops, makes unity-build driver includes unconditional, and updates examples/tests to explicitly enable drivers. ChangesPublic API & ChannelManager
Docs and Contracts
Driver Unity-Build Headers: Unconditional Compilation
Platform-Specific Driver Initialization: No-Op Conversion
Driver Selection: BusTraits-Direct Implementations
Stub/WASM Implementations
Tests and Examples: Explicit Driver Enablement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/platforms/stub/spi_channel_stub.h (1)
62-74:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winFix syntax error: extra closing brace.
Line 74 contains an extra closing brace that will cause a compilation error. The
if (mChannelData->isInUse())block already closes at line 73.🐛 Proposed fix
u32 lastWarnTime = startTime; if (mChannelData->isInUse()) { FL_WARN_EVERY(100, "ClocklessSPI(stub): driver should have finished transmitting by now - waiting"); bool finished = mDriver->waitForReady(); if (!finished) { FL_ERROR("ClocklessSPI(stub): Engine still busy after " << fl::millis() - startTime << "ms"); return; } } - }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platforms/stub/spi_channel_stub.h` around lines 62 - 74, There is an extra closing brace that breaks the if-block around the clockless SPI wait logic; in the block that starts with if (mChannelData->isInUse()) and contains FL_WARN_EVERY(100, ...), bool finished = mDriver->waitForReady(), and the FL_ERROR(...) return, remove the stray closing brace after that return so the block closes exactly once and the surrounding scope remains balanced (adjust only the unmatched brace, leaving startTime/lastWarnTime, the FL_WARN_EVERY call, the mDriver->waitForReady() call, and the FL_ERROR handling intact).
🧹 Nitpick comments (2)
tests/doctest_main.cpp (1)
86-92: ⚡ Quick winKeep driver enablement consistent across both test entrypoints.
fl_run_tests()enables drivers, butfl_main()still runs without that bootstrap. Aligning both paths avoids mode-dependent test behavior after auto-registration removal.Proposed diff
int fl_main(int argc, char** argv) { `#ifdef` ENABLE_CRASH_HANDLER setup_crash_handler(); `#endif` @@ `#ifndef` TEST_DLL_MODE // Setup internal timeout watchdog (detects hangs from within test process) // Only in standalone mode - DLL mode uses external monitoring timeout_watchdog::setup(); // Default: 20 seconds, configurable via FASTLED_TEST_TIMEOUT `#endif` + // Keep standalone test bootstrap aligned with DLL mode. + fl::enableAllDrivers(); + // Run fl_unittest test framework fl::test::RunOptions opts = fl::test::parse_args(argc, (const char**)argv); int result = fl::test::run_all(opts);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/doctest_main.cpp` around lines 86 - 92, fl_main() is missing the same driver bootstrap that fl_run_tests() performs, causing mode-dependent test behavior; call fl::enableAllDrivers() (or invoke the same bootstrap routine used by fl_run_tests()) early in fl_main() before any tests run so both entrypoints enable platform drivers consistently, and keep the existing escape hatch for stricter tests via manager.clearAllDrivers() followed by enableDrivers<...>().src/fl/channels/manager.cpp.hpp (1)
6-8: ⚡ Quick winRemove duplicate includes.
Lines 6-8 include
fl/log/log.hthree times. Header guards prevent compilation errors, but this is redundant.♻️ Proposed fix
`#include` "fl/channels/manager.h" `#include` "fl/stl/singleton.h" `#include` "fl/log/log.h" -#include "fl/log/log.h" -#include "fl/log/log.h" `#include` "fl/system/engine_events.h"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/fl/channels/manager.cpp.hpp` around lines 6 - 8, Remove the redundant includes of the same header: keep a single `#include` "fl/log/log.h" and delete the extra duplicate lines; locate the repeated include entries of "fl/log/log.h" in manager.cpp.hpp and ensure only one include remains to avoid redundancy while preserving header guards.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/platforms/stub/spi_channel_stub.h`:
- Around line 62-74: There is an extra closing brace that breaks the if-block
around the clockless SPI wait logic; in the block that starts with if
(mChannelData->isInUse()) and contains FL_WARN_EVERY(100, ...), bool finished =
mDriver->waitForReady(), and the FL_ERROR(...) return, remove the stray closing
brace after that return so the block closes exactly once and the surrounding
scope remains balanced (adjust only the unmatched brace, leaving
startTime/lastWarnTime, the FL_WARN_EVERY call, the mDriver->waitForReady()
call, and the FL_ERROR handling intact).
---
Nitpick comments:
In `@src/fl/channels/manager.cpp.hpp`:
- Around line 6-8: Remove the redundant includes of the same header: keep a
single `#include` "fl/log/log.h" and delete the extra duplicate lines; locate the
repeated include entries of "fl/log/log.h" in manager.cpp.hpp and ensure only
one include remains to avoid redundancy while preserving header guards.
In `@tests/doctest_main.cpp`:
- Around line 86-92: fl_main() is missing the same driver bootstrap that
fl_run_tests() performs, causing mode-dependent test behavior; call
fl::enableAllDrivers() (or invoke the same bootstrap routine used by
fl_run_tests()) early in fl_main() before any tests run so both entrypoints
enable platform drivers consistently, and keep the existing escape hatch for
stricter tests via manager.clearAllDrivers() followed by enableDrivers<...>().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 581e966b-65b7-40ed-99e7-5f9b66ab7762
📒 Files selected for processing (28)
examples/AutoResearch/AutoResearch.inosrc/FastLED.hsrc/fl/channels/README.mdsrc/fl/channels/bus.hsrc/fl/channels/channel.hsrc/fl/channels/manager.cpp.hppsrc/fl/channels/manager.hsrc/platforms/esp/32/drivers/_build.cpp.hppsrc/platforms/esp/32/drivers/channel_manager_esp32.cpp.hppsrc/platforms/esp/32/drivers/i2s/_build.cpp.hppsrc/platforms/esp/32/drivers/i2s_spi/_build.cpp.hppsrc/platforms/esp/32/drivers/lcd_cam/_build.cpp.hppsrc/platforms/esp/32/drivers/lcd_spi/_build.cpp.hppsrc/platforms/esp/32/drivers/parlio/_build.cpp.hppsrc/platforms/esp/32/drivers/rmt/_build.cpp.hppsrc/platforms/esp/32/drivers/rmt/rmt_4/idf4_clockless_rmt_esp32.hsrc/platforms/esp/32/drivers/rmt/rmt_5/idf5_clockless.hsrc/platforms/esp/32/drivers/spi/_build.cpp.hppsrc/platforms/esp/32/drivers/spi/idf5_clockless_spi_esp32.hsrc/platforms/esp/32/drivers/uart/_build.cpp.hppsrc/platforms/stub/clockless_channel_stub.hsrc/platforms/stub/init_channel_driver.hsrc/platforms/stub/spi_channel_stub.hsrc/platforms/wasm/clockless_channel_wasm.hsrc/platforms/wasm/spi_channel_wasm.htests/doctest_main.cpptests/fastled_core.cpptests/platforms/shared/active_strip_data/active_strip_data.cpp
…default-as-opt-in) Closes the binary-bloat half of #2421 by making the previously opt-in "no driver auto-registration" behavior the default and removing the macro entirely. Drivers now link only when their `BusTraits<Bus::X>::instance` is named via: - Legacy `addLeds<>` Phase 5b pre-bind (platform-default driver) - `addLeds<..., fl::Bus::X>` trailing template parameter (#2460) - `fl::TypedChannel<Bus::X, Chipset>::create(cfg)` (#2451) - `fl::enableDrivers<fl::Bus::X, ...>()` opt-in - `FastLED.enableAllDrivers()` (3.10.3-style universal enrollment) - `FastLED.setExclusiveDriver<fl::Bus::X>()` (NEW template overload) Stock `examples/Blink/Blink.ino` on ESP32-S3 drops from ~776 KB to 657 KB with no source change or build flag needed. Only `ChannelEngineRMT` (the platform default) is linked; UART / LCD_SPI / LCD_CLOCKLESS / I2S / SPI driver TUs are all garbage-collected. `setExclusiveDriver` is now also exposed as a template overload that links + registers a non-default driver at priority above the platform default. The string-form `setExclusiveDriver(const char*)` is kept for mock/test scenarios (drivers already registered with the manager that aren't in the `fl::Bus` enum). Test harness changes: - `tests/doctest_main.cpp` calls `fl::enableAllDrivers()` at startup so unit tests that depend on runtime driver dispatch keep working. - `tests/fastled_core.cpp` "Legacy API 4 parallel strips" test rewritten to use the Channel API (`FastLED.add(cfg)`) instead of the legacy `addLeds<>` path; the legacy path now pre-binds to the platform default and bypasses the manager, so the mock-driver pattern only works via Channel API. - `tests/platforms/shared/active_strip_data` updated to probe the `BusTraits<Bus::STUB>::instancePtr()` singleton directly rather than expecting auto-registration. - `examples/AutoResearch/AutoResearch.ino` calls `FastLED.enableAllDrivers()` in `setup()` for its driver-enumeration flow. Closes #2421 (binary-bloat half). Refs #2428. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b1bd9f6 to
4127a0c
Compare
…ed (fbuild#755) When an `--lpuart`-style request hits a Teensy 4 build that doesn't have the LPUART driver enrolled at boot, the firmware used to return a generic "DriverSetupFailed: Failed to set LPUART as exclusive driver" with no hint of what IS available. Drivers like LPUART are scaffolded under `src/platforms/arm/teensy/.../lpuart/` but not yet implemented (FastLED #3157 tracks the engine work, #3182 the ISR-chunked streaming). Pre-#3341 the wrapper masked this with a wrapper-skip + synthetic PASS. PR #3341 removed the wrapper-skip; the generic error became visible. This commit makes that error self-diagnosing. New error shape: {"error":"DriverNotRegistered", "message":"Driver 'LPUART' is not registered on this build. Registered drivers: SPI_UNIFIED, FLEX_IO, OBJECT_FLED, BIT_BANG"} Implementation: queries `ChannelManager::instance().getDriverInfos()` on the failure path, filters to `enabled` drivers, joins the names with commas. ~15 LOC, no behavior change for the happy path. The ChannelManager API already existed (#2469 cleanup). The longer-term LPUART fix needs the actual engine implementation (FastLED #3157). This change just makes the missing-driver diagnostic honest so future "why isn't X working" sessions don't waste time on generic-error chasing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…4709) (#4710) * fix: post-3.10.6 memory and host-runner regressions (#4709) - Teensy 4: initChannelDrivers() is now a no-op, as on ESP32 since #2469. FlexIO/ObjectFLED/SPI_UNIFIED registration moves to enableAllDrivers(), so TypedChannel<Bus::X> sketches stop linking every driver into ITCM. Typed Channel sketch on teensy41: RAM1 114.8 KB -> 94.1 KB. Fixes #4708. - Log verbosity defaults to 0 on tiny/small-memory tiers, silencing the FL_WARN_LIT/FL_LOG_LIT literals as well. - Stub: delayNanoseconds/delayMicroseconds honour the fast-exit delay override, so bit-bang wire timing no longer runs in host example runs (ArrayOfLedArrays: >20 s watchdog timeout -> 1.6 s). Co-Authored-By: Claude <noreply@anthropic.com> * fix: address review on #4709 fixes - Teensy lazy init registers the platform-default ObjectFLED engine so Channel::create(cfg) + FastLED.add(ch) with Bus::AUTO keeps working; enableAllDrivers() registers the full set first so FlexIO keeps priority 8. - Keep the log verbosity default unchanged: full FL_WARN/FL_ERROR/FL_INFO are already compiled out on small tiers, and the *_LIT macros back the LPC845 bring-up check. - Stub timing skip lives in one place (stub delayNanoseconds_impl), which also covers the compile-time delayNanoseconds<NS>(). Co-Authored-By: Claude <noreply@anthropic.com> * fix(teensy): drop unused-driver DMA buffers and newlib printf from RAM (#4709) - FL_DMAMEM: Teensy DMAMEM placement without the core's `used`, so a driver's .dmabuffers static is dropped when the driver is not linked. Applied to LPUART, FlexIO, ObjectFLED SPI-mode and ObjectFLED bitdata. Typed Channel sketch on teensy41: RAM 85.75 KB -> 73.75 KB. Fixes #4713. - ObjectFLED: replace three error-path Serial.printf calls with Serial.print (same output). printf linked ~16 KB of newlib formatting into ITCM (RAM1) for every Teensy 4 addLeds sketch: DemoReel100 ITCM 59,664 B -> 38,368 B, flash 80 KB -> 58 KB. Co-Authored-By: Claude <noreply@anthropic.com> * chore(teensy): mark dmamem.h as macro-only for the namespace linter Co-Authored-By: Claude <noreply@anthropic.com> * perf(teensy): stream-form logs so fl::printf is not linked (#4709) Same strategy as #4671: printf-form FL_WARN/FL_ERROR calls link the fl::printf engine (parse_format_spec, apply_width, format_integral), and on Teensy 4 all code lives in ITCM (RAM1). Convert the %s/%d sites on the Teensy 4 driver paths (ObjectFLED, SPI, FlexPWM RX, audio, ISR, coroutine, block clockless) and the shared Channel / CLEDController paths to stream form. Output text is unchanged; u8 values stream as numbers. teensy41, fl::printf_detail symbols now 0 in both sketches: - DemoReel100 (addLeds): ITCM 38,368 B -> 35,680 B, flash 58 KB -> 56 KB - typed Channel API: ITCM 55,200 B -> 51,232 B The hex register dumps in rx_flexio_channel and the RMT driver logs are left as printf form. Co-Authored-By: Claude <noreply@anthropic.com> * perf(teensy): convert remaining SPI/RX printf-form logs to stream form (#4709) Review follow-up: SlimSpiBridgeController, SpiChannelEngineAdapter, SPI lane, FlexIO/FlexPWM RX and FL_LOG_OBJECTFLED sites. A Teensy 4 APA102 sketch now links no fl::printf_detail symbols (ITCM 33,952 B). ESP32 DemoReel100 grows ~0.6 KB: RMT keeps fl::printf linked there. Co-Authored-By: Claude <noreply@anthropic.com> * feat(log)!: make printf-style log formatting a compile error (#4709) printf-form log calls (FL_WARN("x=%d", x)) link the whole fl::printf engine into any image that logs; on Teensy 4 that code sits in RAM1. Every log macro now takes exactly one literal or one << stream chain: - log.h: the multi-argument path of FL_WARN/FL_ERROR/FL_INFO/FL_DBG/ FL_PRINT/FASTLED_*/FL_LOG_ASYNC is FL_STATIC_ASSERT with a message pointing at stream form. The no-op variants (small tiers, logging off, FL_LOG_<channel> disabled) run the same check, so a sketch fails identically on every board. - Convert all 959 printf-form call sites in src/, tests/ and examples/ (%s/%d/%u/%zu -> <<, %x -> fl::to_hex(v), same output text). - color_profile tests also capture println: stream-form logs are emitted through fl::println. Verified: host 317/317 unit + 95/95 examples; Blink builds on esp32dev, esp32dev_idf44, esp32dev_idf33, esp32s3, esp32c6, esp32p4, esp32c3, esp32s2, esp8266, teensy41, teensy31, teensylc, uno, attiny85, rp2040, rp2350, nrf52840, stm32f103c8, stm32f411ce, nucleo_f429zi, lpc845brk, samd51j, samd21, sam3x8e_due, wasm. BREAKING CHANGE: user code calling a FastLED log macro with printf-style arguments no longer compiles; write FL_WARN("x=" << x). Co-Authored-By: Claude <noreply@anthropic.com> * fix(log): address review on the printf-form ban (#4709) - fl::sstream gets operator<<(const void*) printing 0x<hex>, like %p. Converted pointer arguments otherwise converted to bool ("true"). - Use fl::to_hex for the "0x" << n sites (OTA magic byte, RISC-V interrupt flags) and cast esp_err_t to unsigned before to_hex. - Delete the now-unused log_emit_f / log_format_string helpers. - Fold the converter's "" << seeds and fl::string("lit") wrappers, restore two comments it rewrote, fix stale FL_WARN/FL_ERROR docs. - Test: every log macro's printf form expands to the ban; rename the stale "printf-style" test cases. Co-Authored-By: Claude <noreply@anthropic.com> * fix: address CodeRabbit review feedback - Replace mojibake in RMT/SPI driver diagnostics and comments with ASCII * fix(ci): claim ESP32-S3 bloat saving; update BLE source assertion (#4709) - esp32s3 Blink image_flash 398,799 -> 392,019 B (CI run 37421506562): the gate requires the saving from removing fl::printf to be claimed. - test_rp2350w_board_config asserted the old printf-form log text. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
Removes
FASTLED_DISABLE_LEGACY_DRIVER_REGISTRYentirely. The previously opt-in "no driver auto-registration" mode is now the only mode. Drivers link only when theirBusTraits<Bus::X>::instanceis named at the call site.This closes the binary-bloat half of #2421 (and #2420). The architectural choice that #2428 introduced for opt-in users is now the default behaviour for everyone.
Also re-templates
setExclusiveDriverto take afl::Bustemplate parameter:The string form
setExclusiveDriver(const char*)is kept as a test/mock helper.Empirical: ESP32-S3 stock Blink, no flags
firmware.bin119 KB recovered with zero source change or build flag.
New API surface
Files changed
src/fl/channels/bus.h— macro definition removed.src/platforms/esp/32/drivers/channel_manager_esp32.cpp.hpp— duplicate guard removed;initChannelDrivers()collapsed to a no-op.src/platforms/esp/32/drivers/_build.cpp.hpp+ per-driver aggregators —#if !FASTLED_DISABLE_LEGACY_DRIVER_REGISTRYgates removed; impl files now always compile soenableDrivers<>/enableAllDrivers()always link.src/platforms/esp/32/drivers/rmt/rmt_{4,5}/idf{4,5}_clockless_*.h,src/platforms/esp/32/drivers/spi/idf5_clockless_spi_esp32.h— Phase 5b pre-bind made unconditional.src/platforms/stub/*+src/platforms/wasm/*— same: pre-bind unconditional, init becomes no-op.src/fl/channels/manager.h/manager.cpp.hpp— new templatesetExclusiveDriver<fl::Bus B>(); string overload kept;mExclusiveDriverfield removed (no longer needed).src/FastLED.h/FastLED.cpp.hpp— public templateFastLED.setExclusiveDriver<fl::Bus::X>(); string forwarder kept.src/fl/channels/README.md— sweep of every macro reference + setExclusiveDriver example update.tests/doctest_main.cpp— callsfl::enableAllDrivers()at test-suite startup so existing manager-dispatch tests continue to work.tests/fastled_core.cpp— "Legacy API 4 parallel strips" test rewritten to use the Channel API (FastLED.add(cfg)). The legacyaddLeds<>path now pre-binds to the platform default and bypasses the manager, so the mock-injection pattern only works via Channel API.tests/platforms/shared/active_strip_data/active_strip_data.cpp— probesBusTraits<Bus::STUB>::instancePtr()directly instead of expecting auto-registration.examples/AutoResearch/AutoResearch.ino—FastLED.enableAllDrivers()insetup()for the example's driver-enumeration flow.Risk
manager.addDriver(mock); FastLED.addLeds<...>(...); FastLED.show();expectingmock->enqueue()to fire). Such sketches need to migrate toFastLED.add(ChannelConfig{...})(Channel API path stays manager-routed) or callFastLED.enableAllDrivers()plussetExclusiveDriver("MOCK")beforeaddLeds<>. The legacyaddLeds<>pre-binds to the platform-default driver and bypasses the manager — that's the binary-size win.cfg.options.mBus = fl::Bus::XwithoutenableAllDrivers()/enableDrivers<X>()first emits the one-shot miss diagnostic from Channel API: FL_ERROR + AUTO-fallback when a runtime-selected driver wasn't instantiated #2455/Channel API: legacy FastLED.addLeds<..., fl::Bus B> trailing template parameter #2460 and falls back to AUTO/priority. Behaviour unchanged from previous opt-in path; new in the default path.Test plan
bash test --cpp: 303 / 304 pass. The one failing test (example-AutoResearch) is already failing on master before this PR (verified bygit checkout master -- ...+ rerun). Not a regression introduced here.bash lint: clean.bash compile uno --examples Blink --platformio: passes (AVR C++11 path).bash compile esp32s3 --examples Blink --platformio: passes; binary drops to 657 KB vs master's 776 KB; symbol analysis confirms only RMT driver TU linked, all other ESP32-S3 driver TUs (UART / LCD_SPI / LCD_CLOCKLESS / I2S) absent.Related
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Examples
Tests