ws2812: fix build on ESP32-S3 - #885
Open
tomekc wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ESP32-S3
machinepackage supports runtime CPU frequency scaling and exposesmachine.GetCPUFrequency()instead of the constant-stylemachine.CPUFrequency(), so the xtensa WS2812 driver fails to build for esp32s3 targets:This PR routes the frequency lookup through a small build-tagged
cpuFrequency()helper:ws2812_freq_xtensa.go(xtensa && !esp32s3): keeps usingmachine.CPUFrequency()— no behavior change for ESP32 / ESP8266.ws2812_freq_esp32s3.go(esp32s3): usesmachine.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 returnserrUnknownClockSpeedotherwise, matching the existing behavior on other chips.Verified with the TinyGo dev branch:
tinygo build -target=esp32s3-genericfails before this change and succeeds after;-target=esp32-genericstill builds. Also tested on real hardware (ESP32-S3 board driving a NeoPixel at 160MHz).🤖 Generated with Claude Code