esp32: implement USB Serial/JTAG console emulation - #13
Merged
Merged
Conversation
Signed-off-by: Florian Loitsch <florian@loitsch.com>
Signed-off-by: Florian Loitsch <florian@loitsch.com>
floitsch
added a commit
to toitlang/toit
that referenced
this pull request
Aug 7, 2026
Add non-closeable `io.stdin`, `io.stdout`, and `io.stderr` streams. - `io.stdin` is an `io.Reader`; concurrent readers and containers share the platform input, and whichever read consumes the available data first wins - `io.stdout` and `io.stderr` are `io.Writer`s that write directly to the platform descriptors, like `printf`, without going through the print service - host stdin is read by a dedicated blocking thread, including on Windows, while primitives remain non-blocking - host-package stdin and `io.stdin` can coexist and compete for the same descriptor - ESP32 stdin uses ESP-IDF's configured primary console: UART or USB Serial/JTAG - `io.stdin` and `uart.Port.console` share the UART driver and event queue when both are used ESP32-S2 USB CDC is intentionally not implemented in this change. Accessing `io.stdin` with an unsupported primary console backend reports `UNSUPPORTED`; stdout and stderr remain available. The companion QEMU console implementation is [toitlang/qemu#13](toitlang/qemu#13).
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.
Summary
-globalchardev syntax and update the Toit action setup exampleThis deliberately implements the serial-console portion needed by ESP-IDF. It does not emulate USB enumeration or the JTAG debugging half of the peripheral. ESP32-S2 USB CDC is a separate peripheral and is not covered here.
Testing
ninja qemu-system-xtensa qemu-system-riscv32checkpatch.pl: 0 errors, 0 warningsbash -n tests/toit/run-usb-serial-jtag-test.shCONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y:The C3 target builds and has its interrupt connected, but was not runtime-tested with a USB-primary C3 firmware image.