Skip to content

ws2812: fix build on ESP32-S3 - #885

Open
tomekc wants to merge 1 commit into
tinygo-org:devfrom
tomekc:ws2812-esp32s3-cpufreq
Open

ws2812: fix build on ESP32-S3#885
tomekc wants to merge 1 commit into
tinygo-org:devfrom
tomekc:ws2812-esp32s3-cpufreq

Conversation

@tomekc

@tomekc tomekc commented Aug 15, 2026

Copy link
Copy Markdown

The ESP32-S3 machine package supports runtime CPU frequency scaling and exposes machine.GetCPUFrequency() instead of the constant-style machine.CPUFrequency(), so the xtensa WS2812 driver fails to build for esp32s3 targets:

ws2812/ws2812_xtensa.go:17:17: undefined: machine.CPUFrequency

This PR routes the frequency lookup through a small build-tagged cpuFrequency() helper:

  • ws2812_freq_xtensa.go (xtensa && !esp32s3): keeps using machine.CPUFrequency() — no behavior change for ESP32 / ESP8266.
  • ws2812_freq_esp32s3.go (esp32s3): uses machine.GetCPUFrequency().

The existing bit-banged timing paths (160MHz / 80MHz) are unchanged; on the ESP32-S3 the driver works when the CPU is clocked at a supported frequency (e.g. after machine.SetCPUFrequency(160e6)) and returns errUnknownClockSpeed otherwise, matching the existing behavior on other chips.

Verified with the TinyGo dev branch: tinygo build -target=esp32s3-generic fails before this change and succeeds after; -target=esp32-generic still builds. Also tested on real hardware (ESP32-S3 board driving a NeoPixel at 160MHz).

🤖 Generated with Claude Code

The ESP32-S3 machine package supports runtime CPU frequency scaling and
exposes machine.GetCPUFrequency() instead of the constant-style
machine.CPUFrequency(), so the xtensa WS2812 driver failed to build for
esp32s3 targets with:

    ws2812/ws2812_xtensa.go:17:17: undefined: machine.CPUFrequency

Route the frequency lookup through a small build-tagged cpuFrequency()
helper: xtensa chips with the constant-style API keep using
machine.CPUFrequency(), while the ESP32-S3 uses GetCPUFrequency().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant