SuperAPIAI Directory

flashgate

github.com · Other AI tools

flashgate is a hardware-in-the-loop verification gate tool for embedded firmware, whose core purpose is to answer "can the firmware that was just compiled actually run once it is flashed onto the board?". It automatically performs the build, flashes via ST-Link, waits for the board to report its identity (a serial banner or a 64-byte signature at a fixed RAM address), then sends real commands over serial and asserts hardware register readback values; if any step fails, it exits with a non-zero exit code and gives the reason. Every verification, whether it succeeds or fails, leaves behind an evidence record containing per-item check conclusions, raw evidence, and artifact hashes. It can be used as a Claude Code Stop hook to block an agent's "done" claim when the firmware it modified has not passed real-hardware verification; it also provides an MCP server, a remote bench service, and an OpenOCD backend. The repository includes a complete buildable example for the ALIENTEK Apollo STM32H743.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS · Linux

About this tool

flashgate is a hardware-in-the-loop (HIL) verification gate tool used to confirm whether freshly built firmware can actually run on the target development board. It chains the build, flashing, boot verification, and functional probes into one automated pipeline; if any step fails, it exits with a non-zero exit code and gives the reason.

Purpose and positioning It solves a specific problem: an agent or developer cannot claim firmware is usable based merely on "it compiles"; the board itself must provide testimony. flashgate automates this judgment and can serve as a mandatory gate before release or before a session ends.

Main capabilities

  1. Full-pipeline verification: build → flash via ST-Link → wait for the board to report its identity → send real commands over the console and assert hardware register readback values (such as TIM3 CCR), rather than relying on the firmware's self-report.
  2. Dual evidence channels: the board can print its identity over the console UART, or publish a 64-byte signature at a fixed RAM address (magic + git sha + build time + CRC32); the latter can be read using only ST-Link, with no serial cable needed. Both channels carry the git sha, and are marked -dirty when the working tree differs from HEAD.
  3. Evidence records: every verification (success or failure) generates a JSON record under <firmware>/.flashgate/records/, containing per-item check conclusions (build / flash / boot / identity / probe:*), raw evidence (banner lines, SWD signature fields, console tail, failed probe records), the artifact sha256, and the tree + profile + tool version identity corresponding to this conclusion. The record also includes a coverage block explaining what this PASS proves and what it does not prove.
  4. Stop hook: hooks/flashgate_stop.py is a Claude Code Stop hook. When an agent tries to end a session after modifying monitored firmware files, the hook fingerprints the tree and board profile; if that exact state has already passed hardware verification, it allows the stop immediately (about 0.7 seconds cached); otherwise it runs the full verification on the real board, and on failure blocks the stop and feeds the board's testimony back to the agent. The same bad tree is blocked at most twice, after which it is allowed with a warning.
  5. MCP server: provides board_info, doctor, build,Tools such as flash, verify, probe, console_send, and console_read; any MCP-capable agent can drive the board directly. Each tool returns a structured result envelope (status, stable code, summary, CLI exit_code, log). Supports mcp 1.x and 2.x.
  6. Remote bench: expose the bench to the network via Arm's device-connect protocol, providing four RPCs — describe_bench / start_verify / get_operation / cancel_operation — plus the verify_completed event. start_verify returns an op_id immediately, and only one verification is allowed at a time.
  7. Switchable debug backend: flash.adapter in the board profile can select cubeprogrammer (default), openocd (no ST toolchain required, suitable for Linux/ARM64 benches such as Raspberry Pi), or fake (scripted testing).
  8. Record export: flashgate records lists retained records, and --export exports them as a single sendable page (supports --all, --redact), making it easy to hand off to vendor support.

Usage After installing as a Claude Code plugin, use the /flashgate command within Claude Code. The Stop hook requires FLASHGATE_BOARD to point to a board yaml (or use the default profile under boards/ in the repository); when no profile is present, the gate stays idle and explains why. A board profile is one yaml per board, defining the build command, artifacts, flash addresses, serial adapter hints, banner template, probes, and watch globs. Serial port resolution order is explicit serial.port / FLASHGATE_SERIAL_PORT, VID/PID hints, unique serial port, and finally banner matching as proof of identity.

Applicable scenarios Suitable for stages of embedded firmware development that require real-hardware verification, especially scenarios where an agent has automatically modified firmware and hardware confirmation is mandatory, pre-release CI gates, and teams that need to share a bench remotely for verification.

Limitations and caveats Requires ST-Link; a USB-TTL adapter on the console UART can add probe capability. Windows is preferred; Linux/macOS untested. D2D mode has zero authentication — anyone on the same LAN can discover the bench and trigger flashing, and descriptions and records carry local paths, so it is only suitable for home benches; shared environments should be placed behind authenticated infrastructure. Remote discovery may not traverse all wired/wireless routers; switch to unicast and open the corresponding ports. Only one bench-serve instance can run per bench. Record write failures only warn and do not change the exit code. Git-ignored files and nested git repositories are outside the gate's scope.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools