Skip to content

Extending HFIM

To add Implement
Motor or plant A feeder executable in your campaign repository. The firmware exchanges samples with it over a simulated serial port.
Board A template containing the board configuration, startup code, benchmarks, campaigns and package pins.
GDB-compatible probe A probe package with a manifest and launch parameters. Keep station settings with the physical board.
Server connection A command transport to open the route or a command credential helper to return an access token. Select the helper in the server entry.
Simulation engine A core backend controller and a simulator package. The controller selects targets, runs the simulation and returns campaign results. The package provides installation and runtime settings.

Package names

Each kind of package has a repository prefix: hfim-sim- for a simulator, hfim-probe- for a probe and hfim-template- for a template. The SDK is one package, hfim-sdk. The command or the key already names the kind, so a reference leaves the prefix out:

Written Names
hfim sim install ovp@0.6.9 release 0.6.9 of hfim-sim-ovp
hfim sim install ovp the newest release of hfim-sim-ovp; in a campaign repository whose template pins that package, the pinned release
hfim probe install openocd the newest release of hfim-probe-openocd
simulator: gem5@<version> that release of hfim-sim-gem5, in hfim.yaml or a campaign file
probe: openocd@0.12.0 release 0.12.0 of hfim-probe-openocd
hfim init nezha-c906-qemu <dir> the template hfim-template-nezha-c906-qemu
hfim sdk install '>=1.3,<2' the highest hfim-sdk release in the range; the SDK takes no name

The full name is an alias of the short name: hfim-sim-ovp@0.6.9 and ovp@0.6.9 install into the same ~/.hfim/simulators/hfim-sim-ovp/0.6.9, read the same HFIM_SIM_OVP root and resolve the same pin. A name that starts with hfim- is always the full name. A package registered from a checkout under a name without the prefix, acme-emu, keeps resolving by that name while no hfim-sim-acme-emu is installed. Names ignore case; a version is the package's release tag v<version> and is matched exactly. Install hints print the full name.

hfim sim install with no name outside a campaign repository lists the simulator packages of the package index (qemu, qemu-xuantie, gem5, ovp), and hfim probe install lists the probe packages (openocd, openocd-esp32). A name outside the index resolves by the same prefix rule, so a new package installs by name once its repository has a release tag.

Package index

The public repository HI-REST/hfim-index lists the packages HFIM knows by name, one YAML file per entry:

# simulators/qemu.yaml
kind: simulator           # template, simulator, probe or sdk
name: qemu                # the short name
repo: https://github.com/HI-REST/hfim-sim-qemu
description: Upstream QEMU 9.2 with the SD-card fix the PolarFire HSS needs; generic RV64 CPU
tier: official            # official or community

The index holds no versions: those are each package's release tags. Its build.py checks the entries and writes index.yaml, every entry in one file. hfim init with no template, and hfim sim install and hfim probe install with no name, read that file from https://raw.githubusercontent.com/HI-REST/hfim-index/main/index.yaml with a timeout of a few seconds. When it cannot be read, they use the copy built into hfim (fim/install/index.yaml, updated at each release), without a message. HFIM_INDEX_URL names another index file, https:// or file://; HFIM_INDEX_URL=off uses only the built-in copy. All other descriptions come from the built-in copy or from the installed package's manifest.

Every entry today is an official HI-REST package. Entries for packages from other publishers will be added by pull request to the index with tier: community; its README says how.

Package metadata

A package's manifest.yaml must carry name (the repository name), version (the tag without the v) and core (the HFIM versions it works with, for example ">=1.15,<2"). A simulator package adds runtime and backends, which say how it runs and which backend controllers drive it; a probe package adds server. HFIM decides what a package does from these keys, never from its name.

These keys are optional and describe the package without changing how it installs or runs:

Key Value
kind simulator, probe or sdk
license the SPDX expression of the package's own files, for example MIT
homepage the package's repository or documentation page
maintainers a list of people or organisations
schema the manifest format version, 1
description one line on what the package is; hfim sim install and hfim doctor print it
protocol the driver protocol: an integer (protocol: 5), or one per backend (protocol: {ovp: 5})

Prebuilt images

A simulator package with a Docker form can name an image that a maintainer built and pushed to a registry. hfim sim install and hfim setup then download that image instead of building it. The key sits under runtime.docker, next to image:

runtime:
  docker:
    image: hfim-sim-gem5:23.2.0
    prebuilt:
      ref: ghcr.io/hi-rest/hfim-sim-gem5@sha256:<64 hex digits>
      platforms: [linux/amd64, linux/arm64]
Key Value
prebuilt.ref <registry>/<repository>@sha256:<digest>. A tag is refused, because a tag can move to another image. prebuilt: <ref> without platforms is the short form.
prebuilt.platforms optional: the hosts that download the image, as Docker names them (docker version, Server.Os/Server.Arch). Another host builds the image. Without the list, every host downloads it.

The list names hosts, not the image's own platform. An image that is linux/amd64 on every host, such as one whose compiler exists only for x86-64, also lists linux/arm64: an Apple Silicon Mac runs it emulated, as it runs the image a build there makes. An image that runs natively on each host it lists is either a multi-platform index, from which Docker takes the host's image, or a single image listed for its own platform only.

The install runs docker pull <ref>, checks that Docker holds the image under the pinned digest, and runs docker tag <ref> <image>. Every later command finds the image under the name in runtime.docker.image, as if this machine had built it. The registry entry (~/.hfim/simulators/<name>/<version>) holds the same manifest as after a build, plus .hfim-prebuilt with the reference the image came from. hfim doctor prints that reference, and a campaign records it in provenance.json as image_prebuilt, next to image.

When the pull fails (no network, no access to the registry, a host the list leaves out, a key that is not pinned by digest), the install prints one line with the reason and builds the image. When Docker reports a digest other than the pinned one, the install stops and registers nothing: it neither uses that image nor builds one in its place. A checkout installed with --path is always built.

To publish the image of a release, build it with the package's build.sh, then run scripts/publish-sim-image.sh <checkout> <version> from the core repository. The script tags the image as ghcr.io/hi-rest/<name>:<version> (HFIM_IMAGE_REGISTRY names another registry), pushes it, and prints its digest and the lines to add to the manifest. Add them, commit, and tag the release on that commit: an install reads the key from the release tag. A new registry package must be public, or every install without a registry login builds the image.

Publishing a package of your own

  1. Name the repository by the prefix rule, for example hfim-sim-myqemu.
  2. Add a manifest.yaml whose name is the repository name, with version, core and the keys of its kind. See Simulator manifests.
  3. Tag each release v<version>, the version in its manifest.

Install it from a checkout with hfim sim install --path <checkout> (or hfim probe install --path <checkout>). To install its release tags by name, point HFIM_PACKAGE_ORG at the organisation or directory of bare repositories that holds it: HFIM_PACKAGE_ORG=https://github.com/acme hfim sim install myqemu. HFIM_PACKAGE_ORG names where every package comes from, the SDK and hfim included, so the organisation must hold those too. A template of your own needs neither: hfim init <git URL> <dir> copies it from its repository.

A reference with an owner or a source, acme/myqemu or github:acme/my-sim, stops with a message that names these two ways.

Coming next

A later release adds owner names (acme/myqemu), source names (github:acme/my-sim) and community entries in the package index that hfim searches, so a package of your own installs by name without HFIM_PACKAGE_ORG.

A model connected over serial

Define the first message, message boundaries, the reply that advances one time step, and the timeout behavior. Select a breakpoint inside the firmware work loop when waiting for a reply makes its instruction count variable. Run the feeder where it can open the pseudo-terminal allocated by QEMU.

See Feeder-driven benchmarks for the campaign keys.

Integration references

  • Boards documents existing templates and supported board combinations.
  • Hardware setup describes the probe package and station configuration.
  • Adding a server shows transport and credential settings.
  • Simulator manifests describes the version, build target, runtime and configuration paths a package declares.
  • Classification explains how a campaign determines its outcome.