devlog
A Mac terminal running usbnet ls, which lists an ESP32 board and a USB missile launcher on a Raspberry Pi, then usbnet esptool chip-id, which connects to the ESP32-S3 over rfc2217:// and starts the flasher stub

usbnet: flashing an ESP32 and an Uno on a Raspberry Pi from a Mac

28 November 2026 · usbnet · sinkers/usbnet

usbnet puts USB devices plugged into a Raspberry Pi within reach of my Mac. The first target was serial boards: an ESP32-S3 on the Pi's hub shows up on the Mac as rfc2217://printpi.local:4001, and esptool connects to it, identifies the chip and runs its flasher stub across the LAN. It is about 1,000 lines of Python and shell, MIT licensed, with 19 tests. Everything below was run on 28 November 2026 against a Pi 4 on wired Ethernet and a Mac on the same LAN.

Why not USB/IP on the Mac

Linux has USB/IP: the Pi exports a device, a client attaches it, and it appears as local USB. macOS has no USB/IP client. Making a remote device look local needs a virtual USB host controller inside macOS. Kernel extensions used to do that and are now deprecated. VirtualHere's client logs "Unable to connect to the kernel" when it tries Apple's user-space API for this. Parallels and UTM only go the other way: they take a device that is physically on the Mac and hand its traffic to a VM.

So usbnet works per device class instead, and translates each class into something macOS already understands. Serial goes over RFC2217, which is telnet plus COM-PORT-OPTION, so the remote end can set baud and drive DTR and RTS. pyserial speaks it, and so does anything built on pyserial, including esptool. A Linux machine can still use USB/IP for everything else.

Block diagram: Mac running the usbnet CLI and pyserial, connected over the LAN to a Raspberry Pi running usbnet-gw on port 3241, one esp_rfc2217_server per serial device on ports 4001 and up, and usbipd on 3240, with the USB devices on the right
The pieces as deployed. Devices are as listed by lsusb on the Pi; ports and code from usbnet_gw.py at c1f3478.

How it works

On the Pi, usbnet-gw polls /sys/class/tty every 2 s for ttyUSB* and ttyACM*. It gives each device a name, made from the chip plus the USB serial number (or the port path when the chip has no serial number), and a TCP port from 4001 upwards. Both are kept in /var/lib/usbnet/state.json, so a board gets the same port after a replug or a reboot. The daemon runs one esp_rfc2217_server per device and lists them all on GET :3241/devices. A udev hook shares any other device over USB/IP, except hubs, cameras, serial devices and anything in /etc/usbnet/exclude. The 3D printer's CH340 is in that list, because OctoPrint on the same Pi drives it.

On the Mac:

uv tool install --with esptool git+https://github.com/sinkers/usbnet
usbnet ls
usbnet esptool fuel -- chip-id          # --port filled in from the gateway
usbnet esptool fuel -- read-flash 0 0x40000 dump.bin
usbnet reset fuel                       # pulse EN to see the boot log
usbnet run arduino -- arduino-cli upload -p {port} -b arduino:avr:uno Blink
usbnet launcher left 500

What I checked

Test, macOS client Result
esptool chip-id (esptool 5.7.0) ESP32-S3 (QFN56) rev v0.2, MAC 28:84:85:90:04:e4, stub running
read-flash 256 KB at 115200 23.5 s, 89.4 kbit/s, digest OK
read-flash 256 KB at 460800 11.1 s, 188.7 kbit/s, digest OK, byte-identical to the 115200 read
read-flash at 921600 1 MB: "Digest mismatch". 256 KB: "Read more than expected"
pyserial read after usbnet reset 482 bytes of boot log and firmware output
Uno R3, arduino-cli upload (2.2 KB sketch) 3/3 in 6.0 to 7.7 s; new sketch's banner read back over serial
Uno R3, avrdude 6.3 write + verify 5594 bytes written and verified in 5.4 s
arduino-cli monitor via pty fails: "error getting modem bits status"

I didn't write to the ESP32, which belongs to another project. The Uno's flash was backed up first (read on the Pi, then verified against the chip), and the avrdude row is that backup going back on.

What was wrong along the way

The first version served each port with ser2net. Reads worked, but esptool failed every time with "Wrong boot mode detected (0x8)". Getting an ESP32 into its bootloader takes a DTR/RTS sequence timed to tens of milliseconds, and a LAN round trip between each step throws the timing off. Espressif ships esp_rfc2217_server for exactly this case. It spots the start of the reset sequence and runs the whole thing on the Pi. With that server, esptool connected on its first attempt. The cost is a Python process per device instead of one ser2net.

Smaller mistakes:

Uno uploads took several attempts. avrdude resets the board by toggling DTR, which a pty can't carry, so usbnet run reconnects the RFC2217 session when an uploader starts talking, and the gateway's server runs the reset. Holding avrdude's sync and forwarding it once the bootloader was up still failed, one reply out of step. A byte trace (USBNET_TRACE=1) showed why:

   2.858 -> 30 20 30 20
   2.861 <- 14 10 14 10
   2.861 -> 41 81 20
   2.865 <- 14
avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

During the 1.7 s hold, avrdude had retried, and the pty had merged two syncs into one read. The board answered both, and avrdude had already drained past the first answer. The bridge now forwards only the latest write, collapsed to one copy. With that, the next three uploads all worked.

Limits

The obvious objection is that RFC2217 isn't USB. It isn't, and that shows up in the tools.

Next

Storage: the Pi will mount a USB drive and share it over SMB, with a usbnet mount command on the Mac. The same day, the Pi also took over OctoPrint and the printer camera from the home server. A USB missile launcher turned up on the hub as well. It is driven through /dev/hidraw from POST /launcher/<action>, and it moves.

More articles

TeamAICoder: 11 merged PRs and a notarised 0.1.0 build
Eleven PRs merged into the TeamAICoder Electron app between 28 October and 9 November 2026, unit tests up from 46 to 141, and a signed, notarised 0.1.0 build in an open PR. Plus sitekit, which generates the crawler files for the project's website.
10 Nov 2026 · teamaicoder · 5 min read
Mapping a 12-way boat harness before cutting it
The dead Siemens VDO batteries-and-tanks panel on a Beneteau First 45 is being replaced by an ESP32-S3 and a 3.5-inch TFT. Three weeks of pin mapping moved all sensing to a Victron Cerbo GX and cut the panel board from 143 footprints to 82. Nothing is built yet.
8 Nov 2026 · beneteau-f45-display · 5 min read
Agents that use no RAM while they wait
A one-agent trial of wake-on-demand in agent-core: 0 Mi while asleep against 543–651 Mi for an always-on OpenClaw pod, and a median 3.0 s first answer from sleep with a warm pool, 10.7–14.7 s without one. What it saves, and what it doesn't prove.
5 Nov 2026 · agent-core · 5 min read
All articles →