Repository navigation
fix(autoresearch): gate 6 companion .cpp files on FASTLED_AUTORESEARCH_LOW_MEMORY (refs #3076) - #3123
Conversation
…RESEARCH_LOW_MEMORY The AutoResearch sketch already gates `<FastLED.h>` and the full LED-protocol matrix behind `FASTLED_AUTORESEARCH_LOW_MEMORY` in AutoResearch.ino itself (line 18). But the companion files in `examples/AutoResearch/` -- Ble.cpp, Helpers.cpp, Net.cpp, Ota.cpp, Remote.cpp, Test.cpp -- compile unconditionally and link the full BLE / Net / Helpers / Remote / Test code into every build, including the LowMemory branch. Two problems land at the same time: 1. **Master build regression** (verified now): AutoResearchRemote.cpp:3650 references bare `memcpy`. With current master + LowMemory target the compile fails with "memcpy was not declared in this scope" because the LowMemory include set doesn't pull in `<cstring>`. The LowMemory sketch doesn't use anything in Remote.cpp anyway -- gating it out fixes the regression cleanly. 2. **Bloat hygiene** (refs #3076 / #3079): even though LTO dead-code- eliminates most of the unused symbols, the gates make the build's intent explicit -- the LowMemory bring-up doesn't need BLE/Net/OTA/ schema-generator etc., and the LTO output reflects that. Pattern matches `AutoResearch.ino`'s own `#if !FASTLED_AUTORESEARCH_LOW_MEMORY` gate. Each .cpp picks up the same `fl/system/sketch_macros.h` auto-detect (`FL_PLATFORM_HAS_LARGE_MEMORY == 0` -> LowMemory) so AVR / ATtiny / similar Tiny-memory targets benefit without an explicit build flag. Verification on LPC845-BRK with current master: * Before this PR: build fails at compile (memcpy regression) under -DFASTLED_AUTORESEARCH_LOW_MEMORY=1. * After this PR: build succeeds, fits 64 KB flash budget, echo RPC round- trips end-to-end via `bash autoresearch lpc845brk --pin-toggle-rx`. Refs #3076 (LowMemory bloat hunt). Does NOT close #3076 -- that closes via the bloat-reduction PRs that already shipped (#3084 / #3085 / #3087 / #3088 / #3089); this is the compile-side hygiene the bloat-fix sweep didn't pick up. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughSix ChangesAutoResearch Low-Memory Compile Guards
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 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 |
Summary
Gates the six companion
.cppfiles inexamples/AutoResearch/onFASTLED_AUTORESEARCH_LOW_MEMORYso they become empty translation units under LowMemory builds — mirroring the gateAutoResearch.inoalready applies to its own setup/loop body.Why
Two problems at once:
1. Master build regression on LowMemory (verified now)
AutoResearchRemote.cpp:3650calls barememcpy. With current master plus a LowMemory target (e.g.bash autoresearch lpc845brk --pin-toggle-rx), the compile fails with:The LowMemory bring-up surface (
AutoResearchLowMemory.h) doesn't use anything inRemote.cpp, so gating it out fixes the regression cleanly. Same applies to the other five companion files — none are used in LowMemory mode.2. Bloat hygiene (refs #3076 / #3079)
Even though LTO dead-code-eliminates most of the unused symbols, the gates make the build's intent explicit. The LowMemory bring-up doesn't need BLE / Net / OTA / schema-generator / FastLED brightness chain — and the LTO output now reflects that without anyone needing to read 3000+ lines of
Remote.cppto confirm.Pattern
Each
.cpppicks up the same auto-detect viafl/system/sketch_macros.h:Matches the conditional structure of
AutoResearch.inoitself (line 18). AVR / ATtiny / similar Tiny-memory targets benefit automatically viaFL_PLATFORM_HAS_LARGE_MEMORY == 0without needing an explicit build flag.Files
AutoResearchBle.cppAutoResearchHelpers.cppfl/channels/manager.h, validation suiteAutoResearchNet.cppfl/stl/json.h+ ESP32 net stackAutoResearchOta.cppfl/net/ota.hAutoResearchRemote.cppmemcpyregression)AutoResearchTest.cpp<FastLED.h>+ entire chipset matrixVerification
On LPC845-BRK against current master:
bash autoresearch lpc845brk --pin-toggle-rx --upload-port COM10fails at compile with the bare-memcpyerror.pinToggleRxRPC silent-fail observed is a separate runtime concern about the 8 KBEdgeTime[2048]stack frame on a 16 KB SRAM part — tracked separately, not in scope here.)Refs
AutoResearchLpc.inoretirement; this PR is the natural follow-up becauseAutoResearch.ino's LowMemory branch took over the LPC bring-up duty.🤖 Generated with Claude Code
Summary by CodeRabbit