Skip to content

ESP32 WiFi modules: host tests of the UART interrupt handler - #1077

Merged
chrisgleissner merged 5 commits into
GideonZ:masterfrom
JC-000:fix/wifi-module-uart-isr-tests
Nov 12, 2026
Merged

chrisgleissner merged 5 commits into
GideonZ:masterfrom
JC-000:fix/wifi-module-uart-isr-tests

Conversation

@JC-000

@JC-000 JC-000 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #1074

Problem

The UART interrupt handler of the ESP32 modules (my_uart.c, identical in raw_u64, raw_c3 and u64ctrl) has no test, so fixes to it cannot be shown red/green without a device. This adds a host harness: the handler is cut out of each module unchanged and run against a model of the UART, with the real cmd_buffer.c queues; no ESP-IDF needed.

What changed and why

New directory software/wifi/uart_tests with the harness and four first cases (a frame is delivered whole; escapes are decoded; a frame in pieces is delivered once; a queued frame goes out at the TX interrupt), wired into make host_tests. A fix adds its own test file and isr_<fix>.mk with red models. The directory is separate from software/wifi/tests that #1041 adds, so the two do not collide. The two module behaviour fixes for this issue — the RX-overflow resync and the TX-FIFO fill — build on this harness, so this PR goes in first.

Products. the ESP32 WiFi modules: raw_u64 (Ultimate 64 / Ultimate 64 Elite), raw_c3 (Ultimate-II+L) and u64ctrl (Ultimate 64 Elite II / C64 Ultimate); the same my_uart.c is in all three. Tests only, no firmware change.

How I tested it

Host: macOS, with the device-free tests run in an Ubuntu 24.04 container (g++ 13.3). The hardware runs used the test harness from the same machine.

Host tests (device-free, run before and after the change):

  • handler of my_uart.c cut out as it is and run against a modelled UART and the real buffer queues: make -C software/wifi/uart_tests isr
    • with the change: 4 tests pass per module build (raw_u64, raw_c3, u64ctrl)
    • without it: make isr-red is empty until a fix adds its models

Hardware.

Device Firmware Ultimate FPGA C64 core
Ultimate 64 Elite not recorded (tests only) not recorded not recorded
C64 Ultimate not recorded (tests only) not recorded not recorded

None: tests only.

Standard profile / soak: not reported here — this change is module-side (ESP32) firmware, which the host-driven ./run-tests standard profile and soak suites do not exercise. The module build is flashed and checked on its own (see above).

Untested

  • Ultimate-II cartridge (U2+ / U2+L): not tested. I do not have one. Not built either for the cartridges, because the build environment I use cannot build those targets; CI builds them.
  • Hardware: nothing to test; the harness models the UART. The model of the TX-FIFO interrupt follows what a C64 Ultimate showed, not a measurement of the chip.

Written with Claude Opus 5.5 in Claude Code.

JC-000 and others added 4 commits November 7, 2026 16:06
software/wifi/tests: the handler of my_uart.c (raw_u64, raw_c3, u64ctrl) is cut out
of each module as it is and run against a modelled UART and the real buffer queues of
software/io/uart/cmd_buffer.c. No hardware, no ESP-IDF; `make isr`. A fix adds its own
isr_<fix>_test.cpp and its models to the Makefile (`make isr-red`). First cases: a frame
is delivered whole, escapes are decoded, a frame in pieces is delivered once, a queued
frame goes out at the TX interrupt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
GideonZ#1041 (wifi-fixes) adds its own software/wifi/tests; the two trees would collide on Makefile and stub/. Nothing else changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Two fixes edited the same lines of the Makefile; each now adds a file, and the Makefile includes isr_*.mk.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The CI step "make host_tests" runs the other host suites; this one is added to it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chrisgleissner chrisgleissner added test Test suites, harnesses, coverage, and infrastructure; not tests supplied to reproduce firmware bugs. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access. labels Nov 10, 2026

@chrisgleissner chrisgleissner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JC-000 thanks for the harness. The branch conflicts with master. Please merge or rebase master. As you noted, this one goes in first, then #1078 and #1079, each rebased after the previous one merges.

…eonZ#1077)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 10, 2026
…1078)

Brings in GideonZ#1077 (updated onto master). Module IDENT renumbered after master: raw_u64 1.19, raw_c3 1.12, u64ctrl 1.30.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JC-000 added a commit to JC-000/1541ultimate that referenced this pull request Nov 10, 2026
Brings in GideonZ#1078 and GideonZ#1077 (updated onto master). Module IDENT renumbered after master and GideonZ#1078: raw_u64 1.20, raw_c3 1.13, u64ctrl 1.31.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JC-000 JC-000 changed the title # ESP32 WiFi modules: host tests of the UART interrupt handler ESP32 WiFi modules: host tests of the UART interrupt handler Nov 10, 2026

@chrisgleissner chrisgleissner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JC-000 thanks for the harness. I re-reviewed it at head 6dcfbbb and am approving it.

Reviewed: the whole diff (test-only: software/wifi/uart_tests/ and one line in the top-level Makefile). No firmware file changes, so no device run is needed for this PR; the module changes that use the harness are #1078 and #1079, and they get their own hardware runs.

Host results at head 6dcfbbb (Ubuntu, g++):

  • make -C software/wifi/uart_tests isr: 4 tests pass for each of raw_u64, raw_c3 and u64ctrl.
  • make isr-red does nothing at this head, because ISR_RED_FIXES is empty (Makefile:30). That is expected: the red models arrive with #1078 and #1079.
  • To show the cases can fail, I broke the handler on purpose (not committed): in raw_u64 my_uart.c, the TX fill loop condition fill_len > 2 changed to fill_len > 2000. a_queued_frame_goes_out_at_the_tx_interrupt then fails at isr_test.cpp:60.
  • CI build is green on this head, and GitHub reports the PR as mergeable with master 18bea13.

Non-blocking, for a later change: escaped_end_and_escape_bytes_are_decoded checks only the frame size (5), not the decoded bytes. With the 0xDB 0xDC case in raw_u64 changed to decode to 0x00 instead of 0xC0, all four cases still pass. isr_received() could also hand back the data so the case can compare 01 C0 02 DB 03. Two comments name files that do not exist in this directory: stub/freertos/FreeRTOS.h mentions module_stubs.c, and cmdbuf_queues.h mentions cmdbuf_test.cpp.

The description says Fixes #1074, so the merge will close #1074 although the fixes are in #1078 and #1079. I will reopen #1074 after the merge so it stays open until #1079 lands.

@chrisgleissner
chrisgleissner merged commit 6f89946 into GideonZ:master Nov 12, 2026
1 check passed
@chrisgleissner

Copy link
Copy Markdown
Collaborator

Merged. Thanks @JC-000. #1078 is next; I will merge master into it if needed and run the module tests on the Elite, the C64 Ultimate and the U2+L.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access. test Test suites, harnesses, coverage, and infrastructure; not tests supplied to reproduce firmware bugs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WiFi module UART: an RX FIFO overflow splices frames into junk commands, and queued replies go out one per received frame

2 participants