Add 'uart.Port.console' to read input from the console UART.#3091
Merged
Conversation
The console UART (the one used for logging and 'print') can now be opened with 'uart.Port.console'. It keeps the configuration it was given during boot; only the UART driver is installed, so RX becomes interrupt driven while system output continues through the polling VFS path. This is the base for driving hardware tests over the serial connection instead of WiFi: the esp-tester now answers 'UART-INPUT-REQUEST: ' marker lines by writing the payload back over the serial port, and a new hardware test exercises the full loop.
floitsch
commented
Jul 19, 2026
| // interrupt driven. System output (logging, `print`) keeps going through | ||
| // the polling VFS path and thus doesn't need the driver. | ||
| // Installing the driver resets the TX FIFO, so drain in-flight output first. | ||
| esp_rom_output_tx_wait_idle(port); |
Member
Author
There was a problem hiding this comment.
I guess there could be a race condition?
If we wait for idle, and another container prints something we might still drop a few bytes.
If there isn't a good way around that, then we should document that.
| set(TOIT_SKIP_TESTS | ||
| # On the test rig the S3's board1 is connected through the USB-Serial-JTAG | ||
| # console, so data written by the tester doesn't reach the UART0 RX pin. | ||
| uart-console-test.toit-esp32s3 |
Member
Author
There was a problem hiding this comment.
I don't think that's true.
| run-test: test | ||
|
|
||
| test: | ||
| port := uart.Port.console |
Member
Author
There was a problem hiding this comment.
Also add a test (or modify this one) that we can change the uart baudrate of the console. (obviously needs to work together with the tester).
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.
The console UART (the one used for logging and
print) can now be opened withuart.Port.console. It keeps the configuration it was given during boot; only the UART driver is installed, so RX becomes interrupt driven while system output continues through the polling VFS path (the same coexistence ESP-IDF's own console REPL uses). A dedicated one-slot pool guards single-open and returns the port on close, and in-flight TX is drained before the driver install since that resets the TX FIFO.This is the base for driving hardware tests over the serial connection instead of WiFi (following the EC618 tester's serial mini-jag model): the esp-tester now answers
UART-INPUT-REQUEST: <payload>marker lines by writing the payload back over the serial port, and the newuart-console-testexercises the full loop (open, double-open rejection, host echo received byte-exact, driver-side write, close/reopen).Verified on the hardware rig:
uart-console-test.toit-esp32passes, and the remaining 15 uart hardware tests pass on the new firmware (the teardown change touches every UART's close path). Skipped on esp32s3: that rig's board1 is connected through USB-Serial-JTAG, so host writes don't reach UART0 RX — S3 input needs a usb_serial_jtag equivalent as a follow-up.