Boards¶
A template is a repository that holds everything needed to run campaigns on one board: the board description, the boot code, benchmarks and example campaigns. hfim init copies a template into a new directory, the campaign repository. Campaigns, golden runs and results are made in that copy.
SoC block diagrams with the injectable parts marked: Board diagrams.
Available templates¶
| Template | hfim init name |
Board | CPU | Simulator | Page |
|---|---|---|---|---|---|
hfim-template-nezha-c906-qemu |
nezha-c906-qemu |
Allwinner Nezha D1 | XuanTie C906 (QEMU c906fdv), RV64, 1 hart, bare metal |
hfim-sim-qemu-xuantie@9.0.2 |
nezha-c906.md |
hfim-template-nezha-c906-gem5 |
nezha-c906-gem5 |
Allwinner Nezha D1 | XuanTie C906 as gem5 MinorCPU, RV64, 1 hart (2 on Ruby), syscall emulation |
hfim-sim-gem5@23.2.0 |
nezha-c906-gem5.md |
hfim-template-polarfire-zephyr-qemu |
polarfire-zephyr-qemu |
Microchip PolarFire SoC Icicle Kit | 1 E51 and 4 U54, RV64, Zephyr SMP on the U54s | hfim-sim-qemu@9.2.4 |
polarfire-zephyr.md |
hfim-template-polarfire-zephyr-hardware |
polarfire-zephyr-hardware |
Microchip PolarFire SoC Discovery Kit, the physical board | 1 E51 and 4 U54, RV64, Zephyr SMP on the U54s | none: the board, through the probe hfim-probe-openocd@0.12.0 |
polarfire-zephyr-hardware.md |
A template's name ends in the backend that runs it: -qemu, -gem5, or -hardware for a template on a real board. The Simulator column is the package the template pins in hfim.yaml (a -hardware template pins a probe package instead); a campaign takes it unless it states its own (Use another simulator). A pin may also use the short name, qemu-xuantie@9.0.2 for hfim-sim-qemu-xuantie@9.0.2; both name the same package.
Create a campaign repository¶
- Create a campaign repository from the template.
hfim initcopies it, installs the packages it pins, checks the machine withhfim doctor, and prints the commands to run next.
hfim init nezha-c906-qemu my-campaigns
cd my-campaigns
With no template, on a terminal, hfim init lists the templates to pick from and asks for the folder.
- Run a campaign from
campaigns/.
hfim run campaigns/fibonacci/register.yaml
hfim init takes a short name from the table, a full template repository name, or a git URL. --no-install only copies the template; hfim run then installs what is missing before it runs. hfim setup checks each pin, says what it is, and installs what is missing with the full build output; hfim doctor also reports the template name, whether the simulator pinned in hfim.yaml is installed, and whether the installed SDK is inside the range hfim.yaml pins.
hfim init removes the template's git history, runs git init, writes .hfim/template.yaml, and makes a first commit named Start from <template> at <commit>. When git has no user.name or user.email, the repository is created without that commit and hfim init prints the commands to make it.
Bring in template fixes¶
hfim template update, run from the top directory of the campaign repository, applies the changes the template received since hfim init copied it.
git add -A && git commit -m "Before template update"
hfim template update --dry-run # list what would change
hfim template update
git diff # review; nothing is committed
| Option | Effect |
|---|---|
--dry-run |
list the changes without writing any file |
--base <commit> |
the template commit the repository was copied from, when .hfim/template.yaml has none |
--allow-dirty |
update with uncommitted changes present; the update then mixes with them in git diff |
How each changed file is handled:
| File in the campaign repository | Result |
|---|---|
unchanged since hfim init |
replaced by the template's new version |
| changed locally | merged with git merge-file; conflicts are marked in the file and listed |
| removed by the template, unchanged locally | removed |
| removed by the template, changed locally | kept, and listed |
under results/, golden/, build/, logs/, .git/, .hfim/ |
never touched |
Without a .hfim/template.yaml, the command reads template: from hfim.yaml and needs --base.
Template files¶
| Path | Contents | Read by |
|---|---|---|
hfim.yaml |
what the template is and what it needs installed | hfim doctor, hfim build, hfim run, hfim template update |
board.yaml |
the board: CPU, harts, memory map, and how HFIM runs it | HFIM, when a campaign or golden run starts |
startup/<arch>/ |
bare-metal boot code: start.S and the linker script |
the SDK build script |
benchmarks/<name>/ |
one benchmark: its code and its own build files only | hfim build, hfim run |
campaigns/ |
every configuration file: one campaign or one batch per file, and the files they include, in any folders | hfim run |
.hfim/template.yaml |
template name, URL and the commit hfim init copied |
hfim template update |
.gitignore |
keeps the per-injection tree, builds and logs out of git | git |
hfim.yaml and board.yaml configure no campaign. Campaign keys go in the campaign file: Campaign configuration. A benchmark: Writing a benchmark.
hfim.yaml¶
template: hfim-template-polarfire-zephyr-qemu
version: 0.2.0
description: >-
Microchip PolarFire SoC, Zephyr SMP on the 4 U54 cores, booted by a
patched HSS off an SD-card GPT image, on QEMU: upstream QEMU with the SD
fix (hfim-sim-qemu), machine microchip-icicle-kit, whose own E51 and U54
CPUs run (a firmware boot passes no -cpu).
core: ">=1.14,<2"
simulator: hfim-sim-qemu@9.2.4
board: board.yaml
build: tools/build_all.sh
build_inputs: [benchmarks/common, zephyr, hss, tools/build_all.sh]
# results_store: ssh://user@host/srv/hfim/results-archive
| Key | Value | Effect |
|---|---|---|
template |
repository name | printed by hfim doctor; read by hfim template update when .hfim/template.yaml is missing |
version |
template version | descriptive |
description |
text | descriptive |
core |
version range, for example ">=1.11.12,<2" |
the HFIM versions the template works with |
simulator |
<package>@<version> |
hfim doctor reports whether this package is installed. A campaign runs on the simulator: of its own file, so keep both in step |
sdk |
hfim-sdk@<version> |
hfim doctor reports an installed SDK older than this |
board |
path to board.yaml |
how HFIM finds the board description |
startup |
arch, dir, start, linker, build_target |
the boot layer the template ships. The SDK links start.S and link.ld from startup/<arch>/ (or startup/) by its own rule; a block naming another place refuses the build instead of describing a build that does not happen |
build |
a command | hfim build and hfim run compile a benchmark by running this command from the repository root with the benchmark directory as argument, instead of the SDK's build.sh |
build_inputs |
list of paths | files and directories the build command reads besides the benchmark directory; hfim run rebuilds when any of them changes |
toolchain |
image, native_when, native |
how the build's compilers are identified: by the Docker file in image, or, when the variable in native_when is set, by the binaries, git commits and command outputs listed under native |
results_store |
ssh:// or file:// URI |
where hfim results push sends the per-injection tree; makes --store optional |
toolchain, build and build_inputs enter the build's identity: changing them rebuilds the benchmarks. The other keys change no build and no golden run. A key outside this table is read by nothing; loading a campaign warns about it.
HFIM finds board.yaml through hfim.yaml: it looks for hfim.yaml in the campaign file's directory and up to three levels above it. A campaign can name a board description directly with board_spec: path/to/board.yaml.
board.yaml¶
Most of board.yaml describes the board for the reader: board, memory_map, caches, injection_targets, and the pipeline, TLB and memory blocks. HFIM acts on the keys below.
cpu:
cores: 5
clusters: 2
clock_hz: 600000000
harts:
- {hart: 0, core: "E51", cluster: 0}
- {hart: 1, core: "U54_1", cluster: 1}
- {hart: 2, core: "U54_2", cluster: 1}
- {hart: 3, core: "U54_3", cluster: 1}
- {hart: 4, core: "U54_4", cluster: 1}
emulation:
exit_device: none
boot_seconds: 90
# timing: icount
# icount_shift: 1
requires_qemu_patches: [sdhci-v4-sdma]
| Key | Value | Effect | New golden run |
|---|---|---|---|
cpu.cores |
integer | harts one injection runs, so host threads one QEMU uses; sets how many injections a server runs at once: min(host cores, workers) / cpu.cores |
no |
cpu.clusters |
integer | above 1, each cluster is its own GDB inferior: HFIM attaches the targeted one, resumes all on every continue, and polls for stops | yes |
cpu.harts[] |
hart, core, cluster |
which harts belong to each cluster, for target_core: random; core names the hart in the per-hart table of results.txt |
yes |
cpu.clock_hz |
Hz | with timing: icount and no icount_shift, the shift is the power of two nearest to this clock |
yes |
emulation.exit_device |
none, sifive_test, psci |
none: a run ends at a breakpoint on fim_exit and the exit code is read from a0. Other values: QEMU exits when the program calls fim_exit |
yes |
emulation.boot_seconds |
seconds | the longest wait before the program runs, for a board that boots firmware first; the minimum wait for the injection point | no |
emulation.timing |
icount |
adds -icount shift=N,align=off,sleep=off to every QEMU of the campaign and its golden run; the guest clock follows instructions, not the host |
yes |
emulation.icount_shift |
integer N |
each instruction is 2^N ns of guest time | yes |
emulation.requires_qemu_patches |
list of names | QEMU fixes the simulator package must carry; HFIM refuses to start when the package's manifest.yaml does not list one under qemu_patches |
yes |
cache.line_size, cache.<level>.size, cache.<level>.assoc |
bytes, size, ways | gem5 cache campaigns check cache_set and cache_way against this geometry |
A property outside this table and outside the descriptive blocks (board, memory_map, caches, injection_targets, tlb, memory, interrupt_controller, peripherals, and cpu.model, cpu.pipeline, cpu.voltage, cpu.clock) is read by nothing; loading a campaign warns about it, so a misspelt emulation.timming does not pass for a setting. The hardware: block is checked by the hardware backend.
A board that declares none of these runs with the defaults: one cluster, an exit device, the host clock. A board that declares neither cpu.clusters nor emulation.exit_device, with campaigns that set firmware_path, runs as two clusters with no exit device, and HFIM warns that the declaration is missing.
A QEMU that does not come from a simulator package
With `qemu_path` in the campaign, or the QEMU from the toolchain configuration, HFIM cannot read a `manifest.yaml`. It warns and runs that QEMU without checking `requires_qemu_patches`. A package that misses a fix is rebuilt with `hfim sim update`, or with its `install.sh` for a native install. The manifest that counts is the one installed with the build, so an updated checkout that was not rebuilt is still refused.Results in a campaign repository¶
The small files of a campaign are committed with the repository: injections.csv, faultlist.json, metadata.json, provenance.json, report.tsv, results.txt. The per-injection tree stays out of git through .gitignore and goes to a results store:
hfim results --store ssh://user@host/srv/hfim/archive push <campaign_id> results/<campaign_id>
hfim results --store ssh://user@host/srv/hfim/archive fetch <campaign_id> ./restored
With results_store set in hfim.yaml, --store is optional. Every file: Output files.