Skip to content

perf: get LPC845 back on the slim bridge (printf and ChannelManager no longer linked on small tiers) - #4671

Merged
zackees merged 3 commits into
masterfrom
perf/lpc-slim-bridge-fits
Oct 2, 2026
Merged

zackees merged 3 commits into
masterfrom
perf/lpc-slim-bridge-fits

Conversation

@zackees

@zackees zackees commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Gets the LPC845 back onto fl::SlimBridgeController (#4605) within its 64 KB of flash. This supersedes the revert in #4668.

Where the bloat was

I diffed the LPC845 AutoResearch link maps per symbol: the pre-slim-bridge build (7ff7c4aad0^) against the slim-bridge build (7ff7c4aad0), which overflowed by 16,448 bytes.

Category Δ flash
double soft-float (__aeabi_dadd/dsub/dmul/d2f, cmpdf) +6.1 KB
printf engine (format_scalar, format_float, ...) +4.3 KB
ChannelManager (addDriver, registry, waitForReady*, poll) +3.0 KB
other / strings +4.2 KB
PixelIterator / encoders +56 B

The encoder path was not the cause; the slim bridge's showPixels is the same size as the old controller's. The type-erased enum switch that cost space was in printf: one format_scalar switch over every scalar kind, so formatting any int linked float formatting and libgcc's doubles. And the logging core's prefix used fl::printf, so every log site linked the printf engine.

Changes

  1. format_integral / format_floating. The specifier switch is split in two, and format_arg<T> picks one at compile time. Integer-only programs never reference float code. Each specifier's behavior is pinned by a new test matrix.
  2. log_emit_prefix / log_emit_newline use fl::print and a local integer conversion instead of fl::printf. A new test checks the exact prefix text, including negative line numbers and INT_MAX.
  3. Logs in ChannelManager, SlimBridgeController and the LPC UART engine use stream form.
  4. Small-memory slim bridge. A DIRECT_SHOW template parameter (default FL_SLIM_BRIDGE_DIRECT_SHOW = !FL_PLATFORM_HAS_LARGE_MEMORY) selects a SlimBridgeShowPolicy specialization that never names ChannelManager: no registration, no runtime enable/disable gate, and the controller calls driver.show() itself. Large platforms keep the manager path unchanged. Affected: LPC and STM32 F1.

Results

LPC845 AutoResearch overflow at each step:

Step Result
master overflowed by 16,448 B
+ printf split overflowed by 7,032 B
+ logging prefix and stream-form logs overflowed by 3,392 B
+ direct-show slim bridge links: 63.45 KB / 64 KB (99.1%), +248 B vs the old direct controllers

On hardware (LPC845-BRK through LPC-Link2): bash autoresearch lpc845 deploys and BRING-UP TEST PASSED.

Host: 316/316 unit, 95/95 examples. Board builds: Blink on lpc845, lpc804, stm32f103c8, stm32f103tb.

Known, pre-existing

bash autoresearch lpc845 --ws2812-loopback overflows on master and on #4668's direct controllers alike (FLASH 176 B, RAM 8 B there; FLASH 340 B / RAM 8 B here). It is tracked separately.

Summary by CodeRabbit

  • New Features
    • Added an option for slim bridge controllers to send frames directly to the driver, with behavior configurable at compile time.
  • Bug Fixes
    • Improved integer and floating-point format handling, including type-mismatch reporting and hexadecimal formatting.
    • Logging output now correctly handles negative and large line numbers and retains consistent prefixes and newlines.

Measured on the LPC845 AutoResearch image with the slim-bridge LPC
controllers (master), where the link overflowed FLASH by 16,448 bytes.
A per-symbol map diff against the pre-slim-bridge build showed the
encoder/PixelIterator path was flat (+56 B); the growth was printf:

- The scalar formatter erased every type into one out-of-line
  format_scalar() switch, so formatting any int linked float formatting
  and libgcc's double routines (dadd/dsub/dmul/d2f/cmpdf, ~6 KB).
  Split into format_integral()/format_floating(), selected at compile
  time by format_arg<T>; integer-only programs never reference the
  float half. Behaviour is pinned per specifier by a new test matrix.
- log_emit_prefix() wrote "file(line): KIND: " with fl::printf, so every
  log site -- stream-form included -- linked the printf engine. Build
  it with fl::print and a local integer conversion.
- ChannelManager, SlimBridgeController and the LPC UART engine logs use
  stream form, so the registration path the slim bridge adds does not
  instantiate printf either.

LPC845 AutoResearch overflow: 16,448 -> 3,392 bytes. What remains is
ChannelManager itself (~3 KB). Host: 315/315 unit, 95/95 examples.
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
.cursorrules — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 353d558e-0d49-4378-9f6c-9413699eb51d

📥 Commits

Reviewing files that changed from the base of the PR and between 43edb94 and 4dc3e70.

📒 Files selected for processing (2)
  • src/fl/channels/slim_bridge_controller.h
  • tests/fl/channels/slim_bridge_controller.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Scalar formatting now uses separate integral and floating-point paths. Log prefix output uses fl::print, and selected logging calls use stream-style expressions. SlimBridgeController supports manager-based and direct-show operation, with tests covering direct registration and frame output.

Changes

Formatting and logging

Layer / File(s) Summary
Separate integral and floating-point formatting
src/fl/stl/stdio.h, src/fl/stl/stdio.cpp.hpp, tests/fl/stl/stdio.cpp
Scalar arguments now dispatch to integral or floating-point formatters. Shared padding output handles width. Tests cover representative formats, type errors, and unknown conversions.
Log prefix output
src/fl/log/log.cpp.hpp, tests/fl/log/log.hpp
Log prefixes and newlines use fl::print. Tests check file names, line numbers, log kinds, and newline output.
Stream-style logging calls
src/fl/channels/manager.cpp.hpp, src/platforms/arm/lpc/drivers/uart_dma/channel_engine_lpc_uart_dma.cpp.hpp
Selected logging calls now use stream-style expressions. The described control flow and outcomes remain unchanged.

SlimBridgeController direct-show mode

Layer / File(s) Summary
Direct-show policy and controller integration
src/fl/channels/slim_bridge_controller.h, tests/fl/channels/slim_bridge_controller.cpp
DIRECT_SHOW selects manager-based or direct driver operation. Direct mode skips manager registration and calls driver.show() after enqueue. Tests check registration and frame output.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4dc3e

No actionable issue remains identified for this change; it is mergeable after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 4dc3e

Small-memory builds bypass runtime driver controls and coordinated frame completion. Some asynchronous drivers still depend on that coordination, creating device-local risks of incomplete output and overlapping transfers. No remotely reachable exploit was established.

Retained concerns

  • Medium · reliability · inferred: Direct mode removes the polling owner needed by the optional LPC845 SCT DMA path. With UART disabled and PWM DMA enabled, show starts only the first chunk; subsequent chunks and cleanup require poll. The driver never marks the channel in use, so the bridge does not invoke its conditional wait before re-encoding. Without independent polling, frames can remain incomplete and repeated submissions can restart an unfinished transfer. The inspected managed path instead polls registered drivers at frame boundaries.
  • Medium · reliability · inferred: Direct mode checks the controller's buffer rather than the shared driver's readiness. On LPC UART DMA, a second controller can enqueue while the first transmission is active, but show returns without consuming that queue. Because the driver is no longer registered for frame-end processing, that work depends on a later controller submission or external lifecycle management to be transmitted. This weakens frame completion and recovery containment compared with manager-owned batching.
Security review details

Security Blast Radius

  • inferred — The demonstrated failure scope is output and shared driver state within a configured device. Controllers sharing one LPC driver inherit its lifecycle limitations. The inspected call paths do not establish cross-tenant, credential, service, or environment authority expansion.

Trust Boundaries and Controls

  • observed — The changed boundary is lifecycle mediation between controllers and drivers, not dynamic driver selection. Managed mode preserves enablement checks and registered-driver flushing; direct mode makes those controls inapplicable to the bridge.

Resilience and Maintainability Implications

  • inferred — Completion and recovery ownership become driver-dependent after the bypass. The existing per-buffer wait can protect repeated UART submissions from one controller, but it cannot replace shared-driver readiness or the SCT polling owner. Consequently, the generic direct policy does not preserve failure containment for every inspected driver.

Hardening Proposals

  • proposed — Make direct-mode eligibility depend on an explicit driver lifecycle guarantee rather than memory tier alone. Require shared-driver readiness, a polling/completion owner, and a defined drain or recovery path for queued work before bypassing frame coordination.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: reducing small-tier linkage by removing printf and ChannelManager dependencies to fit the LPC845 slim-bridge build.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

…annelManager

With printf gone, LPC845 AutoResearch on the slim bridge was still 3,392
bytes over 64 KB, and the remainder was ChannelManager itself (~3 KB:
addDriver, registry, waitForReady*, poll, ctor/dtor, DriverInfo cache).

Add a DIRECT_SHOW template parameter (default FL_SLIM_BRIDGE_DIRECT_SHOW =
!FL_PLATFORM_HAS_LARGE_MEMORY) selecting a SlimBridgeShowPolicy
specialization. The direct policy never names ChannelManager: no
registration, no runtime enable/disable gate, and the controller calls
driver.show() after enqueue as the pre-bridge LPC controllers did. Large
platforms are unchanged. Affects LPC and STM32 F1.

LPC845 AutoResearch: links at 63.45 KB / 64 KB (+248 B vs the old direct
controllers); deployed to an LPC845-BRK, bring-up passes.
@zackees zackees changed the title perf(log,stdio): stop logging from linking printf and soft-float doubles perf: get LPC845 back on the slim bridge (printf and ChannelManager no longer linked on small tiers) Oct 2, 2026
@zackees
zackees merged commit dbe9874 into master Oct 2, 2026
118 checks passed
@zackees
zackees deleted the perf/lpc-slim-bridge-fits branch October 2, 2026 21:17
zackees added a commit that referenced this pull request Oct 2, 2026
…IT_BANG> it uses

AutoResearchPwmDmaClockless.h names fl::BusTraits<fl::Bus::BIT_BANG>, whose
LPC specialization only arrived through clockless_channel_lpc.h. That header
is skipped once another ClocklessController is picked, so the
--pwm-dma-cl build failed with 'incomplete type' (pre-existing; also fails
before #4671). Include the specialization directly. Links at 59.31 KB.
zackees added a commit that referenced this pull request Oct 3, 2026
…#4674)

* fix(autoresearch): LPC845 RX-DMA loopback builds fit and get the port

The --ws2812-loopback / --pwm-dma-cl LPC845 builds (the only ones that
link the real SCT RX-DMA capture) overflowed FLASH by 348 B and RAM by
8 B on master, and once fitted the firmware HardFaulted at boot with
PC in heap/stack: the two fixed 512-word capture rings (4 KB of a 16 KB
part) left too little heap/stack for the RPC layer.

- _lpc_rx_defines(): one place for the LPC RX bench defines. DMA
  loopback builds also pass FASTLED_AUTORESEARCH_LPC_DMA_LOOPBACK (the
  sketch leaves out the unrelated ~1 KB pinToggleRx RPC unless
  --pin-toggle-rx is also given) and FL_LPC_RX_SCT_DMA_RING_WORDS=128
  (the sketch caps a capture at 192 edges).
- rx_sct_capture: ring size overridable via FL_LPC_RX_SCT_DMA_RING_WORDS
  (default unchanged at 512, checked against the 1..1024 XFERCOUNT range).
- _release_harness_port(): the LPC subprocess benches now close the
  harness serial interface before the child opens the port, as the RP
  SPI bench already did (#4207); otherwise the child's client is inert.

Loopback build: 62.91 KB / 64 KB flash, RAM fits; firmware boots and
answers RPC on an LPC845-BRK.

* fix(autoresearch): --pwm-dma-cl LPC845 build includes the BusTraits<BIT_BANG> it uses

AutoResearchPwmDmaClockless.h names fl::BusTraits<fl::Bus::BIT_BANG>, whose
LPC specialization only arrived through clockless_channel_lpc.h. That header
is skipped once another ClocklessController is picked, so the
--pwm-dma-cl build failed with 'incomplete type' (pre-existing; also fails
before #4671). Include the specialization directly. Links at 59.31 KB.
zackees added a commit that referenced this pull request Oct 6, 2026
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 <[email protected]>
zackees added a commit that referenced this pull request Oct 6, 2026
…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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* chore(teensy): mark dmamem.h as macro-only for the namespace linter

Co-Authored-By: Claude <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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