Built for Raspberry Pi 5 · Rust · Apache-2.0

The agent that understands
live hardware state

A hardware-fault-clearance harness for Raspberry Pi 5. It distinguishes faults that look like broken hardware (wrong pin numbering, address, library, or config) from STOP hardware faults (shorted I2C, undervoltage), and may edit workspace-relative driver files when the gold fix is software.

$ git clone https://github.com/nitishagar/piforge && cd piforge/rust && cargo build --release --features hw --bin piforge

Why PiForge

The durable moat: typed sensor reads with units/ranges and sub-millisecond time-series correlation that can't cross a WAN — instead of parsing ASCII from i2cdetect over SSH.

📡

Typed HIL tools

GPIO, I2C, telemetry, and code-edit tools return structured values with units and nominal ranges — so the model reasons about the actual hardware state instead of grepping logs.

〰️

Sub-ms scope

Edge-event capture via the kernel character device catches the glitches a single sample misses. The capability cloud-over-SSH genuinely can't match.

🛡️

Safety-first broker

Reads are always safe. GPIO writes and physical ops are Class I — per-action human approval, risk-tiered, scoped. The under-voltage bit is a hard STOP before any load.

⚡

Pure Rust, one binary

No C dependency (the gpiod crate talks to /dev/gpiochipN directly). Cross-compiles to a single static aarch64 binary (~2.7 MB) you drop on the Pi. Built on llama.cpp's OpenAI-compatible server.

🎯

Honest about limits

Fixes ~25–35% of "hardware feels broken" bugs in code/config. Correctly triages the rest as real hardware faults. Blind spot: analog/scope debugging (it can't see waveforms).

🔬

Capability eval gate

Ships with a headless eval harness: run the model against simulated fixtures and apply the 55% fix-rate / 10% hallucination go/no-go rule before trusting it with real hardware.

Quick start

Start a local llama-server, point PiForge at it, give it a symptom.

1 · Start llama-server

Load a small model with the Qwen3 chat template and Q8 KV cache (the cache-friendly prefix is the key cost lever on a slow Pi).

# On the Pi 5 (8GB, NVMe, official Active Cooler)
llama-server -m qwen3-4b-instruct-2507-q4_k_m.gguf \
  --jinja --port 8080 -c 8192 \
  -ctk q8_0 -ctv q8_0

2 · Run the agent

Reads (i2c, gpio get, scope, telemetry) are always safe. GPIO writes and I2C writes are Class I and require per-action approval.

# Add your user to the hardware groups once:
sudo usermod -aG gpio,i2c,spi,dialout $USER

# Then:
./piforge --config piforge.toml \
  --task "my BME280 keeps returning NaN for humidity"
Prompt-injection aware: tool output is treated as inert data. Instructions inside sensor reads, dmesg, or file contents are never obeyed — the agent only drives a pin because your request requires it.

3 · The tool surface

  • hardware_inventory — list detected I2C devices, GPIO pins, board model. Call first to ground yourself.
  • telemetry — vcgencmd temp/volts + decoded get_throttled bitmask (the under-voltage STOP signal).
  • i2c — scan / detect / read with parsed values, units, and both endian interpretations for 2-byte reads.
  • gpio — typed get/set over the RP1 character device.
  • scope — time-series edge capture (the moat).
  • edit_file — whole-file edits, sandboxed to the workspace root.

The capability eval gate

No public benchmark covers hardware diagnosis. So before betting on the local-appliance product, run the gate.

The eval runs cases headless: the agent's HIL tool calls are served by a simulator driven by each case fixture, and edits land in a per-case temp workspace the scorer reads back. A mock provider lets the whole thing run in CI without a llama-server.

# Headless CI run (scripted mock provider):
./piforge-eval --mock --config piforge.toml.example

# Real model evaluation against a running llama-server:
./piforge-eval --config piforge.toml
Decision rule: ≥55% fix-rate AND <10% register/pin hallucination → BUILD_LOCAL. ~30% → PIVOT_TO_CLOUD. The gate exists because the whole product rests on an unvalidated assumption — that a ~4B model can diagnose hardware faults from live state.
~2.7MB
static aarch64 binary
0
C dependencies
12mA
RP1 per-pin max enforced
55/10
% gate thresholds