A KVM-over-IP solution running on Raspberry Pi Zero 2 W, rewritten in Python
Project description
zeropykvm
A KVM-over-IP solution running on Raspberry Pi Zero 2 W — rewritten from Zig to Python.
Attribution: This project is a Python port of darkyzhou/mykvm, originally written in Zig. All credit for the architecture and design goes to the original author.
Features
- Zero-copy video pipeline: Uses Linux DMA-BUF to share buffers between capture device (TC358743) and hardware H.264 encoder (bcm2835-codec)
- USB HID gadget: Emulates USB keyboard and mouse via Linux ConfigFS, with Boot Protocol support for BIOS compatibility
- HTTPS + WebSocket: Serves a web frontend over HTTPS with WebSocket for real-time video streaming and HID control
- E-Paper display: Optional status display on Waveshare EPD 2in13 V4
Demo hardware
- Raspberry Pi Zero 2 W (Archive)
- Waveshare HDMI-CSI Adapter (Archive)
- Raspberry Pi Zero Camera Cable (38 cm) (Archive)
Screenshots
Architecture
The Python rewrite mirrors the original Zig project's architecture:
| Module | Description |
|---|---|
args.py |
CLI argument parsing (argparse) |
utils.py |
Utility functions (ioctl wrapper, IP detection, FourCC) |
v4l2.py |
V4L2 constants, ioctl numbers, and ctypes structures |
dma.py |
DMA heap allocation and buffer management |
edid.py |
EDID setting and HDMI signal detection |
capture.py |
V4L2 capture device with DMABUF support |
encode.py |
V4L2 M2M H.264 encoder with DMABUF input |
usb.py |
USB HID gadget setup, keyboard/mouse emulation |
epaper.py |
E-Paper display driver |
http_handler.py |
HTTP static file serving |
server.py |
WebSocket client management and broadcast |
ws_handler.py |
WebSocket message handling (keyboard/mouse events) |
https_server.py |
HTTPS/TLS server with WebSocket upgrade |
video.py |
Zero-copy video pipeline orchestration |
gencert.py |
Self-signed certificate generator (zeropykvm gencrt subcommand) |
install_service.py |
Systemd service installer (zeropykvm install-service subcommand) |
main.py |
Main entry point |
Requirements
- Python >= 3.12
- Linux with V4L2 support (Raspberry Pi OS recommended)
- TC358743 HDMI capture device
- bcm2835-codec hardware encoder
- USB gadget support (dwc2 overlay)
- uv (recommended for dependency management)
Installation
# Install from PyPI using uv (recommended)
uv tool install zeropykvm
# Or with pip
pip install zeropykvm
# With e-Paper display support (on Raspberry Pi)
pip install zeropykvm[epaper]
Development setup
git clone https://github.com/esoadamo/zeropykvm.git
cd zeropykvm
uv sync
# With development tools
uv sync --extra dev
# With e-Paper display support (on Raspberry Pi)
uv sync --extra epaper
Usage
# Generate a self-signed TLS certificate (no openssl required)
zeropykvm gencrt --cert cert.pem --key key.pem
# Run zeropykvm
zeropykvm --cert cert.pem --key key.pem
# With custom settings
zeropykvm --cert cert.pem --key key.pem --port 443 --bitrate 2000000
Then open https://<pi-ip>:8443/ in a browser (or whatever port you chose) and accept the self-signed certificate.
Systemd service
zeropykvm install-service automates the full setup on a Raspberry Pi OS host:
- creates
/etc/zeropykvm/(mode0755) - generates a self-signed TLS certificate there if one does not already exist
- writes
/etc/systemd/system/zeropykvm.serviceand runsdaemon-reload→enable→start
# Install with defaults (port 8443, data dir /etc/zeropykvm) — runs as root
sudo zeropykvm install-service
# Custom port and data directory
sudo zeropykvm install-service --port 443 --data-dir /opt/zeropykvm
# Install without starting the service immediately
sudo zeropykvm install-service --no-start
# Full option list
zeropykvm install-service --help
Testing
# Run all tests
uv run pytest
# Run with verbose output
uv run pytest -v
# Run specific test module
uv run pytest tests/test_usb.py -v
License
This project follows the same license as the original mykvm.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zeropykvm-0.2.0.tar.gz.
File metadata
- Download URL: zeropykvm-0.2.0.tar.gz
- Upload date:
- Size: 158.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38d22f4fbf407adc319aefd413f778e9e1c49cb25500c34d22e2833082ea842a
|
|
| MD5 |
202c6cf26cdf6db9fa6c94443eca957a
|
|
| BLAKE2b-256 |
028cf676eaae54e44b9b5d33a11f902f3a4203ba713016da740a0ea988b814e0
|
Provenance
The following attestation bundles were made for zeropykvm-0.2.0.tar.gz:
Publisher:
pypi-deploy.yml on esoadamo/zeropykvm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zeropykvm-0.2.0.tar.gz -
Subject digest:
38d22f4fbf407adc319aefd413f778e9e1c49cb25500c34d22e2833082ea842a - Sigstore transparency entry: 1396371750
- Sigstore integration time:
-
Permalink:
esoadamo/zeropykvm@3776ef2ebb481189a27c25ba6daf81d59f2860fb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/esoadamo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-deploy.yml@3776ef2ebb481189a27c25ba6daf81d59f2860fb -
Trigger Event:
push
-
Statement type:
File details
Details for the file zeropykvm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: zeropykvm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 149.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98af8a837f04cb92ce032826f3839fced3d5d0e0b36ecc556de649d906b4fd7f
|
|
| MD5 |
2ea5599b8c267a3a978fee4ae696560f
|
|
| BLAKE2b-256 |
ef7f568fcb417b02b5bcadafcb654dcf0811c9ae5419d418453cad23f5360a7b
|
Provenance
The following attestation bundles were made for zeropykvm-0.2.0-py3-none-any.whl:
Publisher:
pypi-deploy.yml on esoadamo/zeropykvm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zeropykvm-0.2.0-py3-none-any.whl -
Subject digest:
98af8a837f04cb92ce032826f3839fced3d5d0e0b36ecc556de649d906b4fd7f - Sigstore transparency entry: 1396371755
- Sigstore integration time:
-
Permalink:
esoadamo/zeropykvm@3776ef2ebb481189a27c25ba6daf81d59f2860fb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/esoadamo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-deploy.yml@3776ef2ebb481189a27c25ba6daf81d59f2860fb -
Trigger Event:
push
-
Statement type: