smolmux is a portable C11 device multiplexer whose core purpose is to keep device connections (serial UART, GDB stub) open and multiplex access to multiple clients over a Unix socket using a newline-delimited JSON protocol. It is designed as a single static binary with low latency and a small footprint, targeting everyday serial and GDB debugging scenarios on Linux.
Key capabilities include: serial UART, GDB MI, and serial-to-TCP (telnet + RFC2217) device links, implemented via vtable polymorphism; multiple concurrent clients connecting over a Unix socket, with role-based access control (observer/controller/takeover); an expect engine that can concurrently run regex matches on the device byte stream with timeouts; anomaly detection that identifies crashes/errors based on patterns, with cooldown and event tracking; output history, a timestamped ring buffer for replay to clients that join later; structured logging, including JSONL I/O logs and human-readable text logs with rotation support, where the I/O log records everything the device sends and receives (including what is typed at login prompts), is created with 0600 permissions in a private state directory, and refuses to go through symlinks or write to files owned by others; network receivers supporting TCP and WebSocket for remote access (loopback only by default). The wire protocol is plaintext, and any client that completes the handshake gains full control of the device (console writes, pins, BREAK, SysRq, GDB). On loopback, when --auth-token is not provided, the broker generates a 0600 token file in $XDG_RUNTIME_DIR (or /tmp), so other local users and processes cannot connect; the bundled smolmux-monitor / smolmux-mcp read it automatically, and smolmux-cli token can print it. For remote use, it is recommended to keep the binding on loopback and access it via an SSH tunnel or WireGuard; smolmux refuses to serve non-loopback TCP bindings without --auth-token. --insecure-no-auth disables these two protections.
MCP server: the standalone smolmux-mcp / smolmux-gdb-mcp can attach to a running broker; an optional in-process --mcp receiver is used for single-process stdio. Boot tracing and auto-responders:Ordered boot stages, stall events, persistent expect->send rules. Auto-boot interruption: broker-side key flooding (optional DTR/RTS reset) for U-Boot with bootdelay=0. Device profiles/board manifests: JSON configuration for prompts, anomalies, and multi-line boards. Auto-reconnect: exponential backoff recovery when the USB serial port disconnects. Build-time feature selection: Kconfig-based; UART-only builds exclude GDB/TCP/WebSocket code.
Prerequisites: Linux, a C11 compiler, CMake 3.21+, Python 3 and kconfiglib (used in the configuration step to generate the feature header). libpcre2-8 is optional; when missing, regex matching falls back to POSIX. The core has no required external dependencies other than POSIX + cJSON.
Companion tools: smolmux-cli command-line client (send commands, read output; with-port <cmd> pauses the port, runs an external tool such as a flasher, then always resumes); smolmux-monitor interactive terminal client with escape sequences (prefix key followed by a command, prefix defaults to Ctrl-], changeable with -e, e.g. -e esc or -e ^A); smolmux-mcp standalone MCP server that connects to a running broker and exposes serial tools (serial_send_command, serial_read, serial_boot_status, serial_add_autoresponder, etc.); an alternative is the broker --mcp receiver, which embeds MCP in-process; smolmux-gdb-mcp standalone MCP server for GDB debugging, providing 21 tools through a broker holding a --gdb link—breakpoints, stepping, backtraces, registers with name labels, memory, expression evaluation, fault register decoding (when supported by the core), peripheral reads, gdb_interrupt, and unknown board probing on current ARM Cortex-M (gdb_identify_target / gdb_generate_profile; other architectures planned). Resources and prompts include smolmux-gdb://board-probing and probe_unknown_board. Built when SM_ENABLE_GDB is enabled; the chip ID has been verified on the SAM C21 Xplained Pro. The smolmux-watcher daemon monitors anomalies and saves event reports to disk.
The protocol message set covers session control, expect, history, anomalies, boot stages, auto-boot flooding, and autoresponders. The full reference is available via ./build/smolmux --help-protocol (always matching the current binary). Client-to-broker messages include hello, send, send_expect, takeover, release, status, pin_control, set_baud, suspend, resume, history_request, incidents_request, configure_anomaly, interrupt_autoboot, configure_autoresponder, autoresponders_request; broker-to-client messages include welcome, output, input_echo, expect_result, status_response, error, history_response, incidents_response, anomaly, autoboot_result, boot_stage, boot_stall, autoresponders_response, autoresponder_fired, suspended, resumed, link_down, link_up.
Use cases include: everyday serial multi-client sharing, U-Boot interruption, flasher handoff, new board exploration and AI agent collaboration, GDB debugging and unknown board probing. Limitations: primarily Linux-oriented; the network line protocol is plaintext, so remote use must be protected by your own SSH tunnel or WireGuard; non-loopback TCP binds must provide --auth-token; GDB unknown board probing currently supports only ARM Cortex-M.
The project is MIT licensed, and cJSON is bundled under its own MIT license. smolmux Pro is a convenience product rather than a feature gate: it offers prebuilt static binaries (x86_64 + aarch64, musl, zero runtime dependencies), curated configuration packs with per-configuration notes, and 6 months of email support, for a one-time purchase of $79.