Repository navigation
perf(esp32s3): link the ADC driver only when fl::analogRead is used (#4796) - #4804
Conversation
…4796) fl::analogRead lived in the always-linked fl.system+ unity object. Its IDF one-shot ADC reference extracted libesp_adc.a(adc_common.c.obj) even when the function itself was discarded, and that object's .ctors constructor (adc_hw_calibration) runs ADC self-calibration at boot and links the efuse calibration path into every sketch. Move the fl::analogRead wrapper into its own unity object (fl/build/fl.system.analog+.cpp), following the #4726 net/OTA split. esp32s3 Blink: flash 401876 -> 397480 (-4396), RAM 77936 -> 77760 (-176) esp32s3 APA102: flash 409656 -> 405244 (-4412), RAM 77864 -> 77672 (-192) esp32dev unchanged. A sketch calling fl::analogRead still links adc_oneshot_new_unit/adc_oneshot_read and adc_hw_calibration. bash test --cpp 319/319, 95/95; bash lint clean.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe ChangesAnalog read separation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This change moves the analogRead implementation into its own build unit. Sketches that never call analogRead no longer link the ESP32 ADC calibration code, which reduces flash and RAM use. analogRead behaves the same for sketches that use it. No concrete merge risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
#4797) (#4807) * perf: yield_system() keeps the task Scheduler out of driver wait loops (#4797) fl::task::run() dispatches on its flags at runtime, so every SYSTEM-only wait loop (FastLED.show() refresh throttle, ChannelManager/driver waitForReady, ESP32 RMT/SPI/I2S/LCD/PARLIO/UART drivers) linked task::Scheduler, Executor and their singletons into every sketch. Add fl::task::yield_system(us), the SYSTEM branch of run() with the same budget semantics, and use it at the 15 SYSTEM-only call sites. vs master (after #4802/#4804): esp32dev Blink: flash 295728 -> 293908 (-1820), RAM 24480 -> 24272 (-208) esp32dev APA102: flash 290864 -> 289044 (-1820), RAM 23944 -> 23744 (-200) esp32s3 Blink: flash 397660 -> 395804 (-1856), RAM 77760 -> 77552 (-208) esp32s3 APA102: flash 405416 -> 403576 (-1840), RAM 77672 -> 77488 (-184) bash test --cpp 319/319, 95/95 (new yield_system test). * docs: prescribe fl::task::yield_system() for DMA wait loops (#4797 review) Update the channel-engine wait rule (cpp-standards.md) and the review checklist: yield_system(us) is the same OS yield as run(us, SYSTEM) without linking the task Scheduler/Executor. * docs: finish yield_system rule update; correct host yield claim (#4797 review)
… (#4814) * chore(deps): pin fbuild 2.5.39 for the ESP32-S3 QEMU deploy fix (#4813) fbuild 2.5.39 skips the QEMU ADC-calibration image patch when adc_hw_calibration is not linked (FastLED/fbuild#1665). Since #4804 the ADC constructor is no longer linked into ordinary sketches, so 2.5.37/2.5.38 failed every esp32s3_qemu_* deploy. Local: esp32s3 QEMU BlinkParallel and DriverTest (QEMU_LCD_CLOCKLESS_REGISTRATION: PASS) both pass with 2.5.39. * ci: re-run after fbuild 2.5.39 reached the PyPI index * test(bloat): re-base ESP32-S3 budget/baseline for fbuild 2.5.39 accounting (#4813) Same firmware, new measurement: fbuild 2.5.38+ attributes weak vtable owners (fbuild#1663), so attributed RAM reads 40016 B (was 37844 B on 2.5.37) and the image 342099 B (was 342083 B). Section RAM over #4801 fell 77936 -> 77200 B. Re-base authorized by the maintainer. * fix(bloat): pass --nm/--cppfilt to fbuild symbols (fbuild 2.5.39, #4813) fbuild >= 2.5.38 matches the ELF to a build_info environment by prog_path. Teensy records prog_path as firmware.hex, so 'fbuild symbols' failed with 'no unambiguous environment matches the ELF'. Pass the cross tools from the single-env build_info.json explicitly, as the dashboard benchmark does. Local: bash bloat teensy41 / esp32s3 pass; teensy41 budget passes. * fix(bloat): name the build_info for fbuild symbols; re-base RAM budgets for 2.5.39 (#4813) - bloat.py: pass --build-info (build_info_<example>.json, else build_info.json) with --nm/--cppfilt, so build dirs holding several build_info_<example>.json files (esp32c6, esp32dev) are not 'ambiguous'. - Local sweep of all 11 budgets on fbuild 2.5.39: image sizes identical to 2.5.37; four RAM budgets fail only on attribution (fbuild#1663). The same ELFs measured under budget on 2.5.37: esp32c3 24607 -> 26670 esp32c6 29027 -> 33478 esp32dev 32618 -> 34734 rp2040 8689 -> 9474 Re-based with the maintainer's authorization; all 11 pass locally.
Part of #4801. Fixes #4796.
Root cause (linker map)
adc_common.c.objcarries a.ctorsconstructor,adc_hw_calibration. Constructors are always kept, so every ESP32-S3 sketch ran ADC self-calibration at boot and linked the efuse calibration path:adc_hal_self_calibration,adc_hal_arbiter_config,read_cal_channel;esp_efuse_utility_*,esp_efuse_rtc_calib_*.Archive extraction follows any undefined symbol in an extracted object, even when
fl::analogReaditself is later discarded by--gc-sections.Fix
Move the
fl::analogReadwrapper into its own unity object,fl/build/fl.system.analog+.cpp→fl/system/analog/. This is the same pattern as the #4726 Wi-Fi/OTA split. The declaration stays infl/system/pin.h.Evidence (dashboard protocol, fbuild 2.5.38)
fl::analogRead(4)still linksfl::analogRead,adc_oneshot_new_unit,adc_oneshot_readandadc_hw_calibration.bash test --cpp: 319/319 unit, 95/95 examples.bash lintpasses, with the new unit added to the unity-build list./code-review: no findings.Summary by CodeRabbit