Skip to content

esp32: remove <esp32-hal.h> Arduino fallbacks from clock_cycles.h (+ rmt4 driver cascade) #3717

Closed

Description

@zackees

Part of #3715.

Problem

src/platforms/esp/32/core/clock_cycles.h still has two <esp32-hal.h> (Arduino core) branches:

  • Line 17–19: #elif FL_HAS_INCLUDE(<esp32-hal.h>) && ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(4, 1, 4) → #include <esp32-hal.h> ("Relies on the Arduino core for ESP32").
  • Line 48: a last-resort #include <esp32-hal.h> fallback.

The file already prefers IDF-native sources above these branches (hal/cpu_hal.h → cpu_hal_get_cycle_count, hal/cpu_ll.h, esp_cpu.h → esp_cpu_get_cycle_count, xtensa/hal.h → xthal_get_ccount), so the Arduino branches are reachable only in odd toolchain combinations — but while they exist, an Arduino-core header can silently become load-bearing.

Cascade: src/platforms/esp/32/drivers/rmt/rmt_4/channel_driver_rmt4.h:44 includes <esp32-hal.h> directly, apparently only for the cycle counter. It already includes clock_cycles.h at line 39 — the direct include is redundant.

Fix

  1. Delete both <esp32-hal.h> branches from clock_cycles.h; terminate the chain with the IDF-native fallbacks only (esp_cpu_get_cycle_count() on IDF 5+/RISC-V, xthal_get_ccount() on Xtensa, cpu_hal_get_cycle_count() on IDF 4.x). If some IDF-3.x-era toolchain reaches the end of the chain, fall back to the raw CCOUNT special register read (RSR inline asm on Xtensa) rather than the Arduino core.
  2. Remove the <esp32-hal.h> include from channel_driver_rmt4.h:44; use __clock_cycles() from the already-included clock_cycles.h.

IDF compat notes (3.x/4.x/5.x/6.x)

  • esp_cpu_get_cycle_count() — IDF 5.0+ (esp_cpu.h).
  • cpu_hal_get_cycle_count() — IDF 4.x (hal/cpu_hal.h), removed in 5.x.
  • xthal_get_ccount() (xtensa/hal.h) — all Xtensa targets, IDF 3.x+; classic ESP32 on IDF 3.3 must land here.
  • RMT4 driver only compiles on IDF 4.x anyway, so the cascade fix is exercised by the esp32dev_idf44 leg.

Acceptance criteria

  • No esp32-hal occurrences remain under src/platforms/esp/ (grep-clean).
  • All four IDF CI legs (idf33 / idf44 / 5.x / idf6) green.
  • RMT4 driver still compiles on the idf44 leg with clockless timing unchanged.

Activity

  1. added
    type: feature
    platform: esp32
    area: core
    on Jul 22, 2026
  2. added a commit that references this issue on Jul 22, 2026
    3a20d0a
  3. moved this from Triage to Done in FastLED Trackeron Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreplatform: esp32type: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions