Repository navigation
feat(esp32): remove <esp32-hal.h> Arduino fallbacks from clock_cycles.h - #3732
Conversation
clock_cycles.h had two fallback branches that included the Arduino core's <esp32-hal.h> for the CPU cycle counter. Both are dead weight: the branch those served (Xtensa targets) already reads CCOUNT directly via inline asm in __clock_cycles() (the ifdef chain in this file only matters for RISC-V targets, which never shipped on an Arduino-ESP32 core old enough to need the removed <hal/cpu_ll.h>-predating branch). Remove both esp32-hal.h branches; the IDF-native chain (hal/cpu_hal.h on IDF5+, hal/cpu_ll.h on IDF4.3+, esp_cpu.h, xtensa/hal.h) already covers every real ESP32 toolchain. The final fallback now reads CCOUNT via inline asm on Xtensa or hard-errors with a clear message instead of silently depending on the Arduino core. Also removes the redundant direct <esp32-hal.h> include from channel_driver_rmt4.h (RMT4 driver), which already includes clock_cycles.h and uses its __clock_cycles() helper. Part of #3715. Closes #3717. Co-Authored-By: Claude Sonnet 5 <[email protected]>
📝 WalkthroughWalkthroughThe ESP32 cycle-counter header removes Arduino-core fallbacks, adds direct Xtensa ChangesESP32 cycle counter cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@src/platforms/esp/32/core/clock_cycles.h`:
- Around line 46-54: Move the definition of __cpu_hal_get_cycle_count out of
clock_cycles.h, leaving only its declaration there. Add the complete
FASTLED_XTENSA/__XTENSA__ implementation and fallback error handling to the
matching implementation file, preserving the existing signature and behavior.
- Line 47: Replace the newly added FASTLED_XTENSA preprocessor check with the
repository-standard FL_IS_XTENSA platform detection, preserving the existing
Xtensa conditional behavior without introducing any new FASTLED_* defined check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9ccb6afd-a2e7-4123-ba2d-a9c15cfb8b07
📒 Files selected for processing (2)
src/platforms/esp/32/core/clock_cycles.hsrc/platforms/esp/32/drivers/rmt/rmt_4/channel_driver_rmt4.h
💤 Files with no reviewable changes (1)
- src/platforms/esp/32/drivers/rmt/rmt_4/channel_driver_rmt4.h
Closes #3717. Part of meta #3715 (ESP Arduino-decoupling).
Problem
clock_cycles.hhad two fallback branches including the Arduino core's<esp32-hal.h>for the CPU cycle counter. Both were dead weight in practice:CCOUNTdirectly via inline asm in__clock_cycles()— the ifdef chain inclock_cycles.honly matters for RISC-V targets.<hal/cpu_ll.h>-predating branch, so that branch was effectively unreachable dead code.Also
channel_driver_rmt4.hhad a redundant direct<esp32-hal.h>include — it already includesclock_cycles.hand uses its__clock_cycles()helper.Fix
<esp32-hal.h>branches fromclock_cycles.h. The IDF-native chain (hal/cpu_hal.hon IDF5+,hal/cpu_ll.hon IDF4.3+,esp_cpu.h,xtensa/hal.h) covers every real ESP32 toolchain. The final fallback now readsCCOUNTvia inline asm on Xtensa or hard-errors with a clear message instead of silently depending on the Arduino core.<esp32-hal.h>include fromchannel_driver_rmt4.h.Test plan
bash lint --cpp— cleanbash test --cpp— 355/355 passbash compile esp32dev --examples Blink— real Arduino-ESP32 3.3.7 (IDF 5.x) build succeeds and links (flash 391611 bytes, ram 146345 bytes — matches the esp32: bare-IDF fl::platforms time impl — drop Arduino millis()/micros()/delayMicroseconds() (blocks all framework=espidf builds) #3716 baseline), exercising both the cycle-counter path and the RMT4 driverSummary by CodeRabbit