Utilizing Synthetic Intelligence to reverse engineer {hardware}


After my mom handed away I ended up with an enormous field stuffed with previous movie negatives containing pictures from childhood household journeys and comparable. So I made a decision to purchase a detrimental picture scanner and located that the Plustek 8200i was supported underneath Linux so I purchased that. Only to find that the chipset within the scanner had modified to 1 that wasn’t supported underneath Linux anymore. So I had some success making Linux configuration instruments for a few of my {hardware} utilizing Claude code, like my Dell Camera controller app so I assumed, perhaps Claude might help me get a working SANE driver. I principally received caught and received nowhere for the longest time and even principally gave up on the mission for a number of Months.

Then I noticed a post on X from Tom Crider aka Glorious Eggroll speaking about how he had managed to repair a mouse driver utilizing AI tooling. He principally described how he set it up in order that the AI agent had full management of a Windows occasion to seize information wanted to repair the driving force. So I pasted his tweet into Claude and requested it to assist me arrange a home windows digital machine to do the identical issues Tom as doing for my scanner. I feel the mixture of being able to run scans underneath home windows and seize the USB information whereas doing so labored wonders, most likely mixed with enhancements to Claude code made an enormous distinction. Within a number of hours I had my first ever working scan underneath Linux, positive with some high quality points, however 100% recognizable because the picture within the detrimental. Some days later I had a close to good driver, together with help for Infrared scanning able to go, solely to find that within the time between me giving up after which attempting once more somebody had dedicated code to SANE to help the scanner already…..it occurs generally. I additionally used Claude to put in writing an utility for doing detrimental scanning, which I named Negative Vibes, thought that was a cute title.

Anyway, with the success of my scanner effort I assumed, I ponder if I can use this to lastly repair the final points with MIPI digicam help on my laptop computer. So I informed claude to re-use the harness I had created and attempt to repair the MIPI digicam on my laptop computer by updating the kernel driver and libcamera as wanted. I began the job within the morning and by the tip of the day I had a much improved situation with patches for each the kernel and libcamera prepared.

So I assumed that this is perhaps worthwhile sharing with the globe, and whereas anybody might begin from scratch I did ask Claude to make the harness generic and doc it to make the pathway for anybody else who desires to do that on their {hardware} a bit simpler. Writing a driver for undocumented {hardware} has at all times been tedious. You seize bus visitors, stare at hex dumps, and type hypotheses about what every register or management switch does. You then check them one after the other, often for weeks. None of it’s conceptually onerous, but it surely takes plenty of endurance and abilities.

That form of work fits an AI mannequin properly. It can learn 1000’s of strains of USB seize, discover {that a} sequence repeats with one byte altering, and suggest what that byte means. It can write the check to verify it, and it doesn’t get bored. The human nonetheless decides what to construct and checks that it really works on actual {hardware}, however the slog shrinks lots.

hw-harness

Be conscious that I didn’t use hw-harness on this type for my initiatives as this was principally bespoke code at the moment, so this mission is an try to make the harness extra generic and shareable from the scripts I used to be utilizing whereas doing the work. What hw-harness is supposed to assist your Claude or Codex session with:

1. Record a reference session. Run the seller’s Windows driver in a KVM digital machine, with the actual machine handed by means of to the visitor.
2. Capture from exterior the VM. Record the visitors on the Linux host with usbmon. It sits beneath the passthrough layer, so the visitor can’t see it.
3. Repeat the identical operation on Linux with your individual driver, and seize that the identical manner.
4. Diff the 2 traces. Both come from the identical instrument, in order that they examine instantly. The variations are your checklist of driver bugs.

For gadgets with no bus to faucet, similar to an inside MIPI digicam, the harness makes use of Windows-side inspection as an alternative. That means INF recordsdata, registry information, ACPI tables and machine properties.

The method needs to be fantastic within the sense it doesn’t depend on copying any code as an alternative it observes what the {hardware} does and solely extract configuration information from the Windows drivers, so each fixed within the new driver traces again to one thing recorded.

So for these I’ve 3 quick descriptions of the initiatives I did and what was wanted.

Project 1: a SANE backend for the Plustek OpticFilm 8200i

Comparing the driving force output of two drivers accessible.

The first mission is a SANE backend for the newer Plustek OpticFilm 8200i. It makes use of the Genesys GL128 controller (USB 07b3:1825) and had no Linux help. The older mannequin with the identical title makes use of a GL845 and is already dealt with by SANE.

The backend helps:

  • Color, grey, infrared and shade+infrared modes
  • Resolutions from 300 to 7200 dpi, at 8 or 16 bits per channel
  • Dust and scratch elimination from the infrared channel
  • An publicity multiplier for dense negatives

It’s packaged as a Fedora RPM, constructed routinely on each push. I principally examined it with my very own Negative Vibes utility as there should not that many choices underneath Linux for detrimental scanning.

Upstream SANE’s genesys backend additionally gained help for this scanner in September 2026, so I in contrast the 2. Both resolve the identical fantastic element at 3600 dpi. Mine is quicker at full decision (34.6 s towards 54.4 s) and helps infrared mud elimination. Upstream affords extra decision steps. The webpage has an interactive side-by-side comparability you’ll be able to take a look at. These are single-unit, single-frame outcomes, so deal with them as one information level. Check out the interactive page I made exhibiting the present state of the 2 drivers, hopefully the discoveries I made can be utilized by the SANE mission to repair some smaller objects within the upstream driver. Anyway, I put this mission up extra as a proof of idea because of that since I anticipate everybody together with myself will use the upstream driver as soon as it reaches parity with this one.

Project 2: Negative Vibes

Full scan of detrimental accomplished together with infrared cleansing of picture.

A driver alone isn’t a lot use if scanning negatives remains to be painful, so I constructed Negative Vibes. It’s a GNOME app, written in Rust, for scanning color and black-and-white negatives and slides on any film-capable SANE scanner.

The scan is stored precisely because the scanner delivered it: 16-bit, linear, with the infrared aircraft. Everything else is a stack of non-destructive settings on high, so you’ll be able to change the look and export once more. It contains:

  • Density-space detrimental inversion with movie base and dye-crosstalk correction
  • Roll-wide settings with per-frame overrides
  • Infrared and software program mud elimination
  • IT8 calibration by means of ArgyllCMS
  • Export to TIFF, JPEG, PNG and DNG, with ICC profiles and metadata

It ships as a Flatpak that features the scanner backend. It’s examined on the 8200i thus far. The objective is to help any movie scanner SANE helps. For that, SANE wants a typical technique to expose infrared channels, which it doesn’t have but.

Project 3: Fixing the MIPI camera on my ThinkPad

Showing MIPI output before and after fixes. Colors are better than they look as I was sitting in a relatively dark room by the end of the session.

Showing MIPI output earlier than and after fixes. Colors are higher than they give the impression of being as I used to be sitting in a comparatively darkish room by the tip of the session.

The digicam in my Lenovo ThinkPad X1 Carbon Gen 14 (Aura Edition) makes use of a Sony IMX471 sensor behind an Intel IPU7. On Linux it produced darkish photos with heavy vignetting and a powerful yellow-green forged. mipi-fixes-x1-aura collects the fixes. It’s solely related to this laptop computer, which is why it isn’t one of many greater packaged initiatives, however I’ve already submitted the kernel patches to Kate Hsuan and the libcamera patches is being reviewed by Wim Taymans for submission to Libcamera.

Kernel (IMX471 driver):

  • A crop-selection bug returned an error earlier than storing the crop rectangle, so libcamera assumed the complete pixel array.
  • The test-pattern register was declared with the improper width.
  • The analogue acquire cap was too low, which price about 1.8 stops of sensitivity.

libcamera software program ISP:

  • Lens shading correction was lacking totally, leaving the corners about 2.7 stops darker.
  • White-balance statistics had been summed on the sensor’s native bit depth towards an 8-bit black degree. That skewed white stability, and the repair applies to any RAW10/RAW12 sensor.

In a managed low-light check, body brightness rose from 31.1 to 90.9. The pink/inexperienced and blue/inexperienced ratios moved from 0.890 and 0.672 to 1.047 and 0.823, near a USB webcam reference. Blue remains to be about 17% quick in low gentle, which I put right down to grey-world white stability. Fedora 44 RPMs are on the releases web page.

What I realized

  • Reference captures are an enormous step. Having the AI examine a known-good hint towards a failing one turns a imprecise “it doesn’t work” right into a concrete checklist of variations. For instance for the MIPI digicam having a USB digicam additionally related so Claude might examine the 2 captures was essential.
  • The AI is nice on the tedium. That covers decoding captures, writing probes and cross-checking constants. I nonetheless need to be the one holding the bodily {hardware}.
  • Real {hardware} is the one choose. Every declare above was checked on the precise scanner or laptop computer.

If you’ve {hardware} with no Linux driver, attempt hw-harness. Thanks once more to Glorious Eggroll for the inspiration.

NOTE: I’m not claiming that my scans or MIPI digicam is ideal now, however the scanner offers me first rate wanting scans and the MIPI digicam seems lots higher than earlier than. So over time I’m positive we have the ability to tweak and polish additional, however I’m joyful that it allowed me to maneuver the needle regardless of missing the in-depth information for any such work.

—



Source link