Skip to content

Fix classic ESP32 I2S EOF address register latching - #3

Merged
levkropp merged 1 commit into
levkropp:masterfrom
bgates747:codex/i2s-eof-register-latching
Nov 6, 2026
Merged

levkropp merged 1 commit into
levkropp:masterfrom
bgates747:codex/i2s-eof-register-latching

Conversation

@bgates747

Copy link
Copy Markdown
Contributor

Prepared by Codex on behalf of Brandon

In downstream Agon VDP testing, the initial correction improved a vertical
video judder symptom. Later intermittent scanline-refill symptoms remain unresolved;
this PR addresses the independently reproduced register defect.

After an EOF transmit descriptor A completes, a subsequent non-EOF descriptor B
overwrites I2S_OUT_EOF_DES_ADDR and I2S_OUT_EOF_BFR_DES_ADDR. Software handling
the earlier interrupt then sees B's addresses instead of A's, even while the
EOF interrupt remains pending.

The ESP32 Technical Reference Manual, registers 22.15 and 22.17
defines these as the descriptor and buffer that produced EOF. Current DMA
progress has separate OUTLINK_DSCR registers.

Move the two address updates into the existing I2S_DESC_EOF branch. Descriptor
progress, payload delivery, OUT_DONE and interrupt acknowledgement retain their
existing behavior. The production change is confined to that branch in
i2s_process_tx_descriptor; the other changed file adds a peripheral regression.

The regression sends EOF A → non-EOF B → EOF C → non-EOF D on both classic
I2S ports, with the first EOF interrupt either pending or already cleared.
It checks retained EOF addresses, current descriptor progress, ordered payloads,
interrupt state and read-only register behavior. It uses public memory and
peripheral APIs, with no firmware image or application assets.

Validated against current master c3259fcd1483ed881a21adf42e27e71753d736d1
on Linux ARM64 with GCC 14.2.0:

  1. With the new regression but unchanged production code: 24 failing EOF-address
    assertions, 188 passing assertions.
  2. With the correction: 212 passing regression assertions, 0 failures.
  3. Focused I2S group: 9 tests, 343 passing assertions, 0 failures.

After applying the patch:

cmake -S . -B build-eof -DCMAKE_BUILD_TYPE=Release \
  -DFLEXE_LTO=OFF -DNATIVE_ARCH=OFF -DFLEXE_CCACHE=OFF \
  -DCMAKE_C_FLAGS=-Wno-error=stringop-truncation
cmake --build build-eof --target xtensa-tests --parallel 1
./build-eof/xtensa-tests --quiet i2s

The GCC warning flag keeps an existing rom_stubs.c truncation warning visible
without treating it as an error; the default strict build stopped there before
any tests ran. No ROM-stub source change is included.

The original correction and regression are MIT licensed. We maintain a few
other core corrections and can follow your preferred process for those.

@levkropp

levkropp commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Thanks for this. I reproduced your results on Linux ARM64 with GCC 14.2 (24 failures without the fix, 343 passing with it), and CI is green. For your other core corrections, please open a separate PR for each fix.

Your rom_stubs.c warning reproduces on master too, so I'll fix that separately. The full suite also crashes on Linux ARM64 because the JIT doesn't flush the instruction cache there, so you may hit that if you run beyond the i2s group; a fix for that is coming as well.

@levkropp
levkropp merged commit e862d98 into levkropp:master Nov 6, 2026
5 checks passed
@bgates747

Copy link
Copy Markdown
Contributor Author

You're welcome, thanks for the response. Will send more along as my robot prepares them and I have had time to review so I don't unwittingly deluge you with AI slop. BTW, this is becoming a handy tool for correctness testing new code on my end, thanks for putting it together, and giving the Agon some love!

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.

2 participants