Skip to content

fix(esp32s3/i2s): guard show() timeout, bound DMA waits, and protect deferred groups - #5500

Merged
zackees merged 1 commit into
masterfrom
fix/esp32s3-i2s-show-spin-and-inuse
Dec 3, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/esp32s3-i2s-show-spin-and-inuse

Conversation

@zackees

@zackees zackees commented Dec 3, 2026

Copy link
Copy Markdown
Member

Fixes item #8 from #5492.

Summary

  • ChannelEngineI2S::show(): Check waitForReady() return value; if timed out, drop the newly enqueued frame and release its isInUse() flags instead of overwriting active mTransmittingChannels/mChipsetGroups. Mark ALL enqueued channels (including deferred timing groups 1..N) setInUse(true) upfront before starting group 0.
  • ChannelEngineI2S::poll(): Never report DriverState::READY while mTransmittingChannels is non-empty and mPeripheral->isBusy() is true; release channels cleanly when mPeripheral is null or all groups complete.
  • Bounded DMA waits: Replace unbounded spin loops in ~ChannelEngineI2S() and beginTransmission() (both reinit and transmit waits) with bounded mPeripheral->waitTransmitDone(2000), releasing resources and channel isInUse() flags cleanly on timeout/destruction.
  • prepareScratchBuffer() & beginTransmission(): Reject >16 channels (preventing mStrips[16] OOB), guard overflow and mScratchBuffer.resize() OOM, avoid null-pointer memcpy on empty channels, and free mBuffers[0] if mBuffers[1] allocation fails.

Verification

  • bash lint passed on all 3 modified files.
  • bash test channel_driver_i2s --debug passed (ASAN/LSAN/UBSAN), including a new regression test for multi-group isInUse() protection, stuck-busy show() drop, and non-hanging destructor cleanup.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b40e282 and 091612a.

Files selected for processing: 3

  • src/platforms/esp/32/drivers/i2s/channel_driver_i2s.cpp.hpp
  • src/platforms/esp/32/drivers/i2s/channel_driver_i2s.h
  • tests/unit/platforms/esp/32/drivers/i2s/channel_driver_i2s.cpp

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Memory usage (this PR vs. its merge base)

Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).

Target FLASH [bytes] RAM [bytes]
attiny85 2,460 (Same) 136 (Same)
esp32dev 285,567 (Same) 18,767 (Same)
esp32s3 318,695 ($\color{green}\downarrow$ 8) 22,519 (Same)

@zackees
zackees added this pull request to the merge queue Dec 3, 2026
Merged via the queue into master with commit ae11bf4 Dec 3, 2026
134 checks passed
@zackees
zackees deleted the fix/esp32s3-i2s-show-spin-and-inuse branch December 3, 2026 03:47
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