A hardware engineer handed Claude Code a single prompt, a schematic, a user manual and a debugger cable plugged into a 121GW handheld multimeter. Less than a day later, the agent had reconstructed the meter's entire application firmware as plain, readable C, verified it in an emulator it wrote itself, and produced a 90 KB binary that boots on the real meter, measures a 10 V reference at 9.9998 V, auto-ranges normally and streams live data over Bluetooth to the official Windows companion app. The run also exposed the main weakness of autonomous agents: left unsupervised, Claude Code spent thousands of tokens on verification nobody asked for.
The goal: plain C, not assembly
The 121GW runs on an STM32 microcontroller from STMicroelectronics paired with a Hycon HY3131 analog front end, the chip that does the actual measuring. The firmware was originally compiled with the IAR toolchain, and the shipped binary is 124 KB.
A community contributor had already produced an open-source port of the meter's firmware in hand-written ARM Thumb-2 assembly, along with a desktop emulator for macOS, Windows and Linux, in roughly 48 hours using local AI models with Claude supervising verification. That build works well on hardware and auto-ranges almost instantly. But assembly is hard for a community to extend. The objective of this project was different: decompile the binary into vanilla C, with C++, Python and Rust explicitly ruled out, so that anyone could modify and recompile it.
Preparing the hardware
To let the agent flash and test repeatedly, the engineer connected an ST-LINK/V2 programmer over a five-pin SWD cable (SWD is the chip's debug and programming interface). The meter's stock programming header sits at the top edge of the PCB and the battery springs only make contact when the rear case is on, so a disassembled meter loses power. The fix was to solder a right-angle five-pin header to the programming pads and mill small notches in both case halves so the pins poke out of an otherwise fully assembled meter. The meter stays powered by its AA cells and the dial can be turned by hand while the debugger is attached.
One caveat applies: exposed conductor pins void the meter's CAT high-voltage safety rating, so this modification belongs only on a dedicated bench unit, never on a meter kept in regular service.
Backing up everything first
Claude Code drove the STM32CubeProgrammer command-line tools over the ST-LINK. It confirmed the chip's readout protection was at Level 0, meaning memory can be read without restriction, and mapped the boot chain:
| Region | Role | Size |
|---|---|---|
| ST system bootloader (ROM, 0x1FFFF000) | Factory bootloader, cannot be modified | about 8 KB |
| Custom bootloader (flash, 0x08000000) | Reads FAT microSD cards for user firmware updates | 24 KB partition, 20.3 KB of code (20,212 bytes) |
| Application | The multimeter firmware, version 2.05 | 124 KB |
The agent dumped the flash, the system bootloader ROM, the EEPROM and the option bytes into separate binary files. The EEPROM copy matters most: it holds each meter's factory calibration constants, which cannot be recreated if they are wiped. It dumped the flash twice and compared checksums to rule out a corrupt read over the debug link.
Configuring the agent
The session used the Claude Opus 3.5 model with the effort setting on High (not the medium default and not the maximum setting, which consumes tokens far faster), running on a standard monthly subscription rather than an enterprise tier. Plan mode was enabled so the model would lay out a strategy before executing commands, and the run used local execution rather than a cloud sandbox, giving the agent full access to the file system and the hardware toolchain.
The prompt described the hardware, the ST-LINK connection, the three firmware regions and the two-phase goal: reverse-engineer into plain C, then recompile and confirm identical behavior before open-sourcing. It attached the schematic, the user manual and the HY3131 datasheet. One line turned out to be essential: the agent was told to ask questions rather than make assumptions.

▲ Claude Code asking for toolchain and source decisions
What the agent decided on its own
Claude Code began by surveying the workstation. It scanned an entire project archive drive, found old 121GW source snapshots from around December 2017, and asked whether to use them as a base, as reference, or not at all. The engineer chose a clean-room approach from the dumped binary only. The discovery was useful but also unsettling; an agent with local access may roam across every drive it can reach unless it is confined to a working directory or container.
The agent then proposed, and the engineer approved, a toolchain of GCC, CMake, Ninja and headless Ghidra 11 (a free disassembler and decompiler) over IDA Pro, and a roadmap of setup, binary acquisition, static analysis, C reconstruction and equivalence verification. It suggested merely documenting the factory ROM bootloader rather than decompiling code that can never be changed. It asked permission before downloading Ghidra (432 MB), Temurin OpenJDK 21 (192 MB) and Python packages, then installed Ninja 1.12.1 and ARM CMSIS 5.9.0 headers and committed its plan into README.md and memory-map.md.
Milestone 2: the bootloader
After 57 minutes and about 57,000 tokens (41 percent of the session quota), Claude Code had rebuilt all 234 bootloader functions as C. Rather than flash immediately, it wrote an emulation harness modeling the STM32F102, its registers and an SD card, and ran ten scenarios, including normal power-on, brown-out, update mode and corrupt SD files, matching the original down to clock cycles. It deliberately preserved quirks such as the bootloader ignoring a 512-byte status word in certain sector reads, on the principle that equivalence means reproducing the oddities too. The generated files, such as lcd.c, read as ordinary, uncluttered C.
Milestone 3: the application
Ghidra identified 794 functions in the 124 KB application. The agent committed an initial batch of 40 with unit tests, then asked which physical buttons mapped to pin PG9 for the power-on update sequence. It moved through the HY3131 driver, RMS math, measurement scaling, EEPROM calibration storage and peak-hold routines in chunks of 15 to 20 functions per cycle, reaching 132 verified functions as session usage climbed from 86 percent toward 98 percent and a rate-limit warning appeared. The engineer let it run to the limit, then instructed it to continue overnight with a rule to monitor usage and pause at 95 percent.
The overnight report
By morning the agent reported the whole application rebuilt and committed, with the build it produced during emulation reported at 144,460 bytes:
| Metric | Result |
|---|---|
| Functions accounted for | 796 |
| Rebuilt in C | 691 |
| Matched to standard libraries (e.g., FAT file system) | 64 |
| Interrupt handlers | 41 |
| Equivalence tests passed | 591 of 591 |
| Simulated runtime | over 40 seconds |
Each rebuilt routine was executed from identical pseudo-random starting states and compared against the original's RAM and peripheral writes. The harness also injected deliberate errors to prove that the comparison would catch deviations. The simulation reproduced boot, startup screens, display driving and key presses.
Along the way the agent found a real bug: a 1 ms startup countdown was polled in a tight loop without the volatile qualifier, so GCC optimized it into a stale register read. It fixed that, kept several undocumented behaviors intact, and listed remaining work: flash only the app partition without touching the bootloader, option bytes or EEPROM, convert hard-coded RAM addresses into proper C globals, and pick an open-source license.
Flashing, and the cost of an overcautious agent
Asked to flash app.bin over the ST-LINK, Claude Code did not simply flash. It compacted 651,400 tokens of context, then ran a long pre-flight sequence: checking target voltage, reading existing sectors, re-verifying the bootloader, EEPROM and peripheral settings, rebuilding the binary and re-checking the memory map, consuming roughly 4,600 and then 5,800 tokens. Loading the file onto an SD card would have taken seconds.
Then it disassembled its own clock initialization code and found a second genuine problem: GCC's output ran faster than the original IAR build, so the CPU reached the clock switch before the external crystal had stabilized and hung at boot. Diagnosing and fixing that took over 11 minutes and another 8,700 tokens. After the engineer chose "Yes, flash the fix," the actual write took about 22 seconds and the LCD lit up.

▲ First boot of the rebuilt firmware on real hardware
The agent immediately started unprompted post-flash diagnostics, sampling the program counter, reading RAM and inspecting live LCD registers, until the engineer interrupted it after another 2,700 tokens of redundant checks. The log confirmed a full flash match against the fixed build and a clean startup showing version 2.05.
Results on the bench
With the debugger unplugged, the meter was tested standalone:
| Test | Result |
|---|---|
| Resistance and continuity (fingers across probes) | Responsive, ADC loop working |
| Ohms auto-ranging | Settles at normal factory speed |
| 10 V precision reference | 9.9998 V |
| 10 kOhm precision resistor | Passes |
| Internal temperature | 26.6 degrees Celsius |
| Bluetooth Low Energy | Windows companion app connects instantly, live readings match the LCD |
The Bluetooth result is notable because packet framing, parameter formatting and parsing all have to be exactly right for the companion app to work at all.
The final compiled app.bin measures 90 KB, compared with the 124 KB factory image and the roughly 142 KB community assembly build. Flashing that file through the normal route, an SD card and the bootloader button combination at power-on, also worked.
What the repository contains
The output directory holds modular C sources such as main.c, measure.c and hy3131_tables.c, the last packed with calibration tables and register definitions recovered from binary structures. Markdown architecture documents describe chip registers, peripheral interfaces, memory boundaries and dispatch maps. The agent converted the HY3131 PDF datasheet to plain text for its own analysis and extracted the LCD glass layout with segment definitions. Producing documentation of that depth by hand would plausibly take an engineer weeks or months. The full codebase is slated for GitHub so the community can audit and extend it.
What this means for embedded developers
The experiment suggests an agent with local tool access can now handle an entire decompile-rebuild-verify loop for a mid-sized commercial firmware image from one prompt, which looks like a significant shift in how embedded work gets done, and a reason for software students to adapt. The same run also shows the limits: a human still had to modify the hardware, turn the dial, judge the results and, repeatedly, tell the agent to stop. Automated testing of a physical range switch would need a servo or stepper rig.
Practical lessons from the run:
- Back up flash, EEPROM, option bytes and the system ROM byte-for-byte, dump twice and compare checksums, before flashing anything experimental.
- Use High effort and plan mode for complex multi-step work, attach schematics and manuals, and instruct the agent to ask rather than guess.
- Confine the agent to a working directory or container if you do not want it reading every drive it can see.
- Before leaving an agent running unattended, set a token threshold or auto-pause; uncapped agents can produce surprise bills.
- Tell the agent explicitly to perform direct operations such as flashing without extra verification loops when speed and cost matter, and interrupt it once a milestone is reached.
- When porting between compilers, expect timing differences; mark variables shared with interrupts as volatile and add explicit waits for oscillator stabilization.
- Validate the result with precision references, the internal temperature sensor and the manufacturer's companion software, and compare binary size against the original.
Used that way, the agent removes most of the drudgery of firmware reverse engineering; used without constraints, it spends your budget verifying things you could have checked by hand in seconds.


