Skip to content

esp32: implement USB Serial/JTAG console emulation - #13

Merged
floitsch merged 2 commits into
mainfrom
esp32-usb-serial-jtag-console
Aug 5, 2026
Merged

floitsch merged 2 commits into
mainfrom
esp32-usb-serial-jtag-console

Conversation

@floitsch

@floitsch floitsch commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • implement the USB Serial/JTAG serial endpoint registers and 64-byte RX/TX FIFOs using a QEMU character backend
  • route the peripheral interrupt through the ESP32-S3 and ESP32-C3 interrupt matrices
  • add an ESP32-S3 Toit smoke test covering ROM/firmware output and interrupt-driven stdin, stdout, and stderr
  • document the structured -global chardev syntax and update the Toit action setup example

This 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-riscv32
  • QEMU checkpatch.pl: 0 errors, 0 warnings
  • bash -n tests/toit/run-usb-serial-jtag-test.sh
  • ESP32-S3 end-to-end smoke test using firmware built with CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y:
TOIT-QEMU-USB-SERIAL-JTAG: READY
TOIT-QEMU-USB-SERIAL-JTAG-STDOUT:usb-test
TOIT-QEMU-USB-SERIAL-JTAG-STDERR:usb-test

The C3 target builds and has its interrupt connected, but was not runtime-tested with a USB-primary C3 firmware image.

Signed-off-by: Florian Loitsch <florian@loitsch.com>
Signed-off-by: Florian Loitsch <florian@loitsch.com>
@floitsch
floitsch merged commit 20a9f97 into main Aug 5, 2026
13 checks passed
@floitsch
floitsch deleted the esp32-usb-serial-jtag-console branch August 5, 2026 23:12
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant