I've been working on hardware-in-the-loop testing for use in continuous integration testing, coding agent loops and validating coding agent output. There are a number of pieces to this puzzle.
esp-usbip-bridge
This ESP-IDF firmware runs on an ESP chip and bridges the usb host port to a TCP usbip server. This allows the USB devices connected to the ESP to be controlled remotely. They can be attached to the Linux kernel with the usbip command OR they can be used directly (see below).
This firmware also starts an MDNS server so they can be discovered on the network. The firmware advertises a _usbip._tcp mDNS/DNS-SD service on port 3240 with hostname usbip-XXYYZZ.local.
Lastly, this firmware can integrate other ESP-IDF components via a virtual CDC link. Virtual devices appear as a subsequent USB bus with a single virtual device. Currently only CDC is supported and translates to internal input and output FIFOs the component can use. The first example use is with the logic analyzer firmware.
esp-perfetto-logic
This is an ESP component with standalone examples that uses the PARLIO peripheral on the ESP32-P4 (and others untested) to capture signals up to 16 bits at 80 mhz. It uses an extended SUMP protocol for configuration. It also returns perfetto encoded trace data for visualization and analysis. It doesn't currently stream data. It simply writes it into PSRAM.
This code can be run standalone on a P4 with the USB example or as a virtual device from within the USBIP bridge.
viewtrace.dev
This is the UI for the logic analyzer. It is based on the Perfetto UI originally designed for debugging Chrome and Android runtimes.
It has been modified to support capturing from a serial connecting logic analyzer using the above firmware. It also has basic protocol decoding.
Direct communication
There are two layers to communicating from Python to the USB devices hosted by the bridge.
pyusb-usbip-backend
This Python library provides a backend to PyUSB that translates backend calls into the USB over IP protocol. Higher level libraries can then be written targeting the PyUSB API, which is what CircuitPython's USB host API is too.
pyserial-pyusb
This library implements the serial protocol portion of USB on top of PyUSB and connects it into PySerial. It is essentially drivers for standard CDC and CP210x. PySerial has a backend system but it requires the backend to be registered in the same python instance. Not quite like pluggy for USB where installation is enough.
This works with idf.py by modifying it to import serial_pyusb which does the registration.
This page (Logic Friend) was last updated on April 15, 2026.
Text editor powered by tinymce.