Skip to content

Hardware backend

Injects into a real board through its debug port. HFIM starts the board's GDB server, a probe, and drives it with GDB: reset, load, halt at the injection point, write the fault, resume, read the result. About 13 s per injection on the PolarFire SoC Discovery Kit. One board runs one injection at a time.

flowchart LR
  subgraph station["Station: the Linux machine the board is plugged into"]
    run["hfim run"]
    gdb["gdb-multiarch"]
    probe["probe server<br/>(OpenOCD)"]
    tty["serial console"]
  end
  subgraph board["Board"]
    harts["harts<br/>registers, RAM"]
    uart["UART"]
  end
  run -- "GDB/MI commands" --> gdb
  gdb -- "RSP over TCP, one port per hart" --> probe
  probe -- "JTAG over USB" --> harts
  uart -- "program output" --> tty
  tty -- "console text" --> run

The backend names no board, probe or vendor. What it needs to know about a board is in the hardware: section of the template's board.yaml. The GDB server and how to start it come from a probe package.

Setup

A template on a board pins a probe package in hfim.yaml, as a QEMU template pins a simulator:

probe: hfim-probe-openocd@0.12.0

The short form, probe: openocd@0.12.0, names the same package. hfim init and hfim run install it into ~/.hfim/probes/<name>/<version>/, and hfim setup checks and repairs it. To install one by hand:

hfim probe install                    # the template's pin
hfim probe install openocd@0.12.0     # that release
hfim probe install openocd            # the newest release
hfim probe list

The command names the kind of package, so openocd is hfim-probe-openocd; the full name works too. hfim probe install outside a campaign repository lists the probe packages HFIM knows.

Package GDB server Used by
hfim-probe-openocd the system's OpenOCD, 0.12 or later; its install.sh only checks the version hfim-template-polarfire-zephyr-hardware
hfim-probe-openocd-esp32 Espressif's OpenOCD build v0.12.0-esp32-20260831 for Linux amd64 or arm64, fetched by its install.sh with a pinned SHA-256 ESP32-C3 boards

A probe package's manifest.yaml names the server command, its arguments and the line it prints when it is ready. {config} is the board's probe configuration (hardware.probe.config) and {root} the installed package:

name: hfim-probe-openocd
version: 0.12.0
core: ">=1.15,<2"
server:
  command: openocd
  args: ["-f", "{config}"]
  ready: "Listening on port \\d+ for gdb connections"
  startup_seconds: 20

hfim probe install --path <checkout> installs a checkout instead of a release.

The station

The station is the Linux machine the board is plugged into. The template lists what it needs in board.yaml:

hardware:
  host:
    packages: [openocd, gdb-multiarch]         # Debian package names
    usb: ["1514:2008"]                         # the probe, vendor:product
    groups: [plugdev, dialout]                 # the user's groups
    udev_rules: [station/70-hfim-flashpro5.rules]
    dkms:                                      # a kernel module built from source
      - {name: ftdi_sio, version: "1", source: station/ftdi_sio}

hfim doctor, inside the campaign repository, checks each item in its station: section; hfim doctor --board <board.yaml> checks only that. Each missing item is marked MISS and followed by the command that fixes it:

  MISS  udev rule /etc/udev/rules.d/60-esp32c3.rules
        sudo install -m 0644 <repository>/60-esp32c3.rules /etc/udev/rules.d/
        sudo udevadm control --reload-rules && sudo udevadm trigger

hfim never runs sudo and changes nothing on the station. A board that is not plugged in is a note, not a missing item, so a station can be prepared before its board arrives. On macOS the section says that a station is Linux: Docker Desktop cannot pass USB to a container, so a Mac builds the benchmarks but does not reach a board.

Parameters

Key Values Default
simulator_backend hardware
probe <package>@<version> of a probe package the template's pin in hfim.yaml
injection_mode breakpoint: the K-th hit of a program counter; timer: a time drawn from the golden window timer behaviour for any mode but breakpoint
inject_at_symbol, inject_at_addr the program counter for breakpoint, one per campaign required for breakpoint
target_core a hart of the cluster, or random
gdb_path the GDB that speaks the board's architecture
timeout seconds required
hardware any key of board.yaml's hardware: section, to override it

breakpoint uses a hardware breakpoint, so it works on code in flash. timer fits a program that runs much longer than one resume of the harts through the probe. All keys: Configuration keys.

What the board sets

board.yaml key Sets
hardware.debug GDB host and port, or one port per hart (ports), the cluster, how harts halt (halt: group or single), breakpoints: hardware or software, the retired-instruction counter, boot_timeout
hardware.probe managed: true: HFIM starts the probe server; config: its configuration, relative to board.yaml
hardware.load gdb_load (GDB loads the ELF), command, or none for a board that boots from flash
hardware.reset the soft reset through GDB, and an optional hard reset command with settle_seconds
hardware.console serial device and baud, tcp, or none
hardware.golden_repeats how many runs measure the golden window
hardware.host what the station needs, for hfim doctor; it changes no build and no golden run

A campaign overrides any of them under its own hardware: key, for example the console device of another board of the same kind.

Fault targets

Target fault Named by
Registers register target_registers
Memory memory target_variable, or a section in memory_start and memory_end

The fault is written through GDB on the target hart and read back; a write that does not read back is an error of the run, not an outcome. Fault models single_bit_flip, multi_bit_count above 1, stuck_at_0 and stuck_at_1 apply to the value read from the board. Board runs cover register flips on the PolarFire U54 and memory flips on the ESP32-C3. Stuck-at and multi-bit models have offline test coverage.

With num_cores above 1, every hart of the cluster halts at the injection point and the fault goes to the hart target_core names. Harts outside the cluster, such as the PolarFire E51 that runs the boot monitor, are never halted.

Results

Same files as QEMU. In results.txt the PROVENANCE block names the probe, Probe: hfim-probe-openocd@0.12.0, instead of a QEMU binary. hfim run names it before it starts:

hardware: the board, through the probe hfim-probe-openocd@0.12.0

The golden run is golden_repeats runs of the program. It records the window from fim_init to fim_exit and, in breakpoint mode, how often each hart reaches the breakpoint.

Limitations

  • No instruction count is exact on a board whose counters run while a hart is halted, so icount mode and an instruction limit for timeout are not available.
  • One injection at a time per board: --workers 1, and no server worker fleet.
  • No checkpoints: every injection starts from a reset of the board.
  • One program counter per breakpoint campaign.
  • No exact replay: a seed draws the same faults, but the board's timing around them varies.