Repository navigation
Model classic ESP32 UART idle timeout and nonempty-FIFO clear behavior - #6
Conversation
|
I tested the re-fire case on real hardware. On two ESP32-S3 boards (rev v0.2, UART1 in internal loopback, interrupts off, polling For the original ESP32, the TRM says the same thing: So the delayed first timeout in this PR is right, but instead of re-arming after another idle interval, clearing |
614deb5 to
6bdfc6f
Compare
|
Prepared by Codex on behalf of Brandon. Thanks for testing this on hardware. I've rebased this PR onto The revised patch passes all four new regression tests and all 13 existing neighboring tests: 815 assertions, zero failures. |
|
Thanks, merged as 82917d1. I checked it locally against master as well: the full unit suite, and both Agon gates in both engines, with identical pixels and UART traffic and no timing change. One open question for the record: in REF_TICK mode this follows ESP-IDF's ×8, i.e. 1/8 bit per For comparison, on two ESP32-S3 boards one threshold unit measured as one bit time of the selected source clock (APB, XTAL and RC_FAST, at 115200 and 9600 baud), with the timeout firing about 1.5 bit times before the transmitter's idle point. |
|
Follow-up on the REF_TICK question, measured on an ESP32-S2 (S2FNR2, rev v1.0), which shares the classic ESP32's APB/REF_TICK UART clocking. Same method as before: UART1 in internal loopback, interrupts off, the raw
So on the S2 one unit is one bit time in both modes. There is no REF_TICK anomaly: not the TRM's 0.1 bit, and not ESP-IDF's 1/8 bit (ESP-IDF's S2 code applies no factor, which matches). The counter also ignores the baud divider's fractional part. With REF_TICK at 115200 the divider is 8.625, and one unit is exactly 8 REF_TICK periods (8.000 µs); at 9600 it is exactly 104 µs. The APB results fit the same rule (694/80 MHz = 8.675 µs). This doesn't settle the classic ESP32: ESP-IDF's 2018 "hardware issue workaround" suggests the classic chip has a REF_TICK problem the S2 may not share. The open candidates for classic REF_TICK are 8 bits per unit (what Espressif's QEMU and esp-hal assume, and what an S2-like counter would give), 1/8 bit (current ESP-IDF, which Flexe follows), or 0.1 bit (the TRM). A loopback measurement on a classic board would decide it. |
|
Thanks, Lev, for merging the fix and checking it against the Agon tests. — Written by Codex on behalf of Brandon. |
|
I’m tied up until early next week, but I’ll look at the classic ESP32 loopback test then. — Written by Codex on behalf of Brandon. |
|
Written by Codex on behalf of Brandon. Lev, we ran the UART1 internal-loopback test on two classic ESP32s: a We wrote raw CONF1 thresholds 20, 40, 80 and 120 and polled the raw |
|
Thanks Brandon, that settles it. Two chips, 32 trials per point, and the slope agrees at both rates: on the classic ESP32 one REF_TICK threshold unit is a tenth of a bit using the integer divider. That's the TRM's |
|
Thanks, Lev, for applying both UART fixes. We’ve integrated them into Alexe. Your UART regressions passed, and our Agon smoke checks passed in both JIT and interpreter modes. Written by Codex on behalf of Brandon. |
Prepared by Codex on behalf of Brandon
This PR fixes classic ESP32 RX timeouts firing immediately and being cleared
while unread bytes remain. The first timeout now waits for the configured idle
interval, then stays asserted until the receive FIFO is drained and the
interrupt is acknowledged.
The classic UART descriptor
does not specify a timeout threshold register, so
uart_rx_timeout_modeledselects the legacy behavior for that chip. This revision enables the classic
port in the shared model introduced in a20c094. Its APB and REF_TICK threshold
units follow Espressif's classic UART HAL.
The regression injects three bytes and waits for
the first timeout, then tries to clear it with zero, one or two bytes read.
Raw status, masked status and CPU interrupt delivery must remain asserted
until the final drain and acknowledgement. It covers all three classic UARTs,
APB/REF_TICK deadlines, fractional dividers, new-input restart and timeout
disable/re-enable. A shared reset check and existing S3 tests are also included.
The revised patch passes all four new regression tests and all 13 existing
UART/S3/system-clock/deferred-event tests: 815 assertions, zero failures.
Tested against
9372d98c30289d3f3576e720d645553f2133747eon Linux x86_64,GCC 15.2, Release with LTO/native tuning disabled.
The standalone reproducer
runs the same regression against the unmodified base and the corrected code.
It includes the test-only and source-only patches so the before/after behavior
can be checked independently.
To run the four new regression tests:
cmake -S . -B build -DNATIVE_ARCH=OFF -DFLEXE_LTO=OFF -DFLEXE_CCACHE=OFF cmake --build build --target xtensa-tests --parallel 2 ./build/xtensa-tests --quiet classic_uart_timeout_ shared_uart_timeout_reset_cancels_pending