fix(i2s): ESP32 reset_tx/reset_rx too fast for hardware#5609
Open
okhsunrog wants to merge 1 commit into
Open
Conversation
bfe813f to
221fa4c
Compare
On ESP32, `reset_tx()` and `reset_rx()` use `toggle()` which asserts and deasserts the reset bits (tx_reset, tx_fifo_reset, out_rst) in back-to-back register writes. The hardware does not register the reset pulse, causing `tx_start()` to hang forever on the next transfer. Replace `toggle()` with explicit assert → read-back barrier → deassert. The register read forces the bus write to complete before the clear, giving the hardware enough time to process the reset. Tested on M5Stack Core2 v1.1 (ESP32-D0WDQ6-V3): 20+ consecutive `write_words()` calls succeed with this fix (previously hung on the 2nd call). Full reproduction and PAC-based workaround: https://github.com/okhsunrog/m5core2v1-1_demo_rust Fixes esp-rs#5608
221fa4c to
886e1a2
Compare
Contributor
|
I would like to see a test case covering this, even though i2s tests are disabled for esp32 |
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.
On ESP32,
reset_tx()andreset_rx()usetoggle()which assertsand deasserts the reset bits in two back-to-back
modify()calls.The pulse is too short for the I2S peripheral to register, leaving
the DMA engine in a stale state and causing
tx_start()to hang onsubsequent transfers.
Fix by replacing
toggle()with explicit assert → register read-back→ deassert. The read-back acts as a bus round-trip delay, ensuring
the reset is registered before it is released.
Tested on ESP32-D0WDQ6-V3 (M5Stack Core2 v1.1) with IMA ADPCM audio
playback over I2S1 + NS4168 speaker amplifier — 20+ consecutive
write_words()calls succeed, three different audio clips playback-to-back without hangs.
Closes #5608
Changelog
esp-hal
reset_tx()/reset_rx()hanging on subsequent transfers due to reset pulse being too short for hardware