Repository navigation
Speaker: enlarge the spk_task stack for builds without optimization - #425
Merged
Merged
Conversation
…36 bytes When the library is compiled without optimization (-O0), spk_task needs about 2376 bytes with the default dma_buf_len (256), which exceeded the 2304-byte stack and triggered the stack canary watchpoint right after the first tone() on ESP32-S3. The official PlatformIO espressif32 8.0.0 platform passes no optimization flag for Arduino projects, so sketches built there are compiled at -O0. Measured on ESP32-S3 (Arduino core 3.3.12), high water mark of spk_task: -O0: 2376 bytes used (now 172 bytes left of 2560) -Os: 2076 bytes used Fixes m5stack#424
This was referenced Oct 29, 2026
Merged
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.
Fixes #424
spk_taskoverflowed its stack right after the firsttone()when M5Unified was compiled without optimization. The official PlatformIOespressif328.0.0 platform passes no-Oflag for Arduino projects, so sketches built there (and the libraries they pull in) are compiled at-O0; pioarduino passes-Os. The sdkconfig of both platforms is identical for ESP32-S3.This raises the fixed part of the
spk_taskstack from 1280 to 1536 bytes (thedma_buf_len-dependent part is unchanged).Measurement
ESP32-S3 (Cardputer ADV), Arduino core 3.3.12, toolchain 14.2.0+20260121, default
dma_buf_len(256), stack high water mark ofspk_taskwhile playing tones:-Os(pioarduino 55.03.312, or official 8.0.0 +build_flags = -Os)-O0(official 8.0.0, no build_flags)The reporter's minimal sketch (
M5Cardputer.begin(cfg, true); M5Cardputer.Speaker.tone(1000, 100);) on official 8.0.0 boot-loops with the same register dump as in #424 before this change, and runs normally after it.M5.begin()alone reproduces it as well.Built with the upstream CI environments locally and with the CI on the fork.