Open Source

Red Hat engineer uses Claude to reverse-engineer Linux drivers from Windows binaries

Christian Schaller fed Claude Code a Windows driver and USB traffic captures, then released hw-harness, an open-source toolkit that lets AI agents generate Linux drivers for unsupported hardware.

5 min read
His scanner wouldn’t work on Linux — so he let Claude study the Windows driver

Christian Schaller, an engineering director at Red Hat and longtime contributor to GNOME and Fedora, faced a familiar problem: a Plustek OpticFilm 8200i scanner that worked on Windows but had no Linux support. The manufacturer had swapped in a Genesys GL128 chipset that existing Linux drivers didn't recognize. After months of struggling to get Claude Code to generate a working driver from scratch, Schaller tried a different strategy—one that would yield results in hours.

Inspired by a post from Tom Crider (known as Glorious Eggroll) describing how an AI agent had fixed a mouse driver using a Windows machine as reference, Schaller devised a new approach. He gave Claude access to the manufacturer's Windows software running in a virtual machine, captured the USB traffic it generated, and had Claude compare that against what his experimental Linux driver was sending. The AI agent could then identify discrepancies and iterate on fixes.

The results were striking. Within hours, Schaller had his first recognizable scan. Within days, the driver supported infrared scanning as well. As Schaller noted, Claude "doesn't get bored"—a quality that proved essential for the painstaking work of reverse-engineering undocumented device protocols from USB captures and register values.

From proof of concept to open-source release

Schaller's finished driver outperformed the upstream SANE implementation in at least one metric: a full-resolution scan completed in 34.6 seconds, compared to 54.4 seconds for the official version. His implementation also added features like infrared dust removal and exposure adjustments for dense negatives, with scanning options ranging from 300 to 7,200 dpi.

Rather than maintain a competing driver, Schaller decided to release the underlying methodology as an open-source project. The toolkit, called hw-harness and published under an MIT license, bundles the tools needed to capture device behavior, compare working and broken implementations, and feed that information to a coding agent tackling unsupported hardware.

The scanner project also motivated Schaller to build a companion application. Negative Vibes, a GNOME app written in Rust with Claude's assistance, preserves the original 16-bit scan data including the infrared channel. Users can remove dust, adjust images without modifying originals, calibrate colors using ArgyllCMS, and export results as TIFF, JPEG, PNG, or DNG files.

Fixing camera problems on a ThinkPad

Schaller applied the same technique to another hardware compatibility issue: the camera on his Lenovo ThinkPad X1 Carbon Gen 14 Aura Edition. Under Linux, images appeared too dark with noticeably darker corners and a yellow-green color cast. The laptop's Sony IMX471 sensor and Intel IPU7 imaging system lacked the USB traffic that had proven so useful for the scanner project.

Schaller worked around this limitation by feeding Claude the Windows driver's configuration files, registry entries, ACPI tables, and device properties. He also connected a USB webcam to provide a working reference for comparison. By day's end, he had patches for both the Linux kernel and libcamera.

The kernel fixes addressed three distinct issues: a crop-selection bug that caused libcamera to use the wrong pixel area, an incorrectly defined test-pattern register, and an analog gain limit that reduced camera sensitivity by approximately 1.8 stops. Claude also identified problems in libcamera's image processing pipeline: missing lens-shading correction darkened the corners by about 2.7 stops relative to the center, while a calculation mismatch between sensor data and black levels threw off white balance.

In Schaller's low-light testing, frame brightness jumped from 31.1 to 90.9, and color ratios moved substantially closer to the reference webcam. However, the blue channel still runs about 17% below the reference in low light, and neither patch set has been merged into the upstream projects. Kate Hsuan, an AI developer technology engineer at Nvidia, is reviewing the kernel changes, while Wim Taymans, a principal software engineer at Red Hat, is handling the libcamera work. A separate Claude-generated Linux page-cache fix encountered a race condition during review.

The hw-harness toolkit

The released version of hw-harness differs from the exact setup Schaller used for his scanner and camera projects. The toolkit runs the manufacturer's Windows driver inside a KVM virtual machine with the physical device passed through to the guest. Claude operates the Windows session remotely while usbmon captures traffic on the Linux host. The developer then switches the device back to Linux, repeats the operation with the experimental driver, and has Claude compare the traces.

The repository includes several components: winctl for controlling the Windows VM, usbcap for capturing traffic, hostdev for switching devices between host and guest, and hwdbg for Linux-side debugging. PowerShell scripts collect device descriptors, registry entries, ACPI tables, and INF files.

He says the approach can produce a driver that "a maintainer can actually merge."

Licensing questions remain unresolved, and the generalized harness has not yet been tested across a broad range of hardware. Still, the toolkit represents a novel approach to a persistent problem: bringing Linux support to devices for which manufacturers provide only Windows drivers.

Source: The New Stack · Reporting supplemented by The Silicon Ledger staff.