PolarFire Zephyr on the board¶
Template hfim-template-polarfire-zephyr-hardware. The same SoC and software as PolarFire Zephyr, Zephyr SMP on the four U54 cores, on the physical Microchip PolarFire SoC Discovery Kit instead of QEMU. HFIM reaches the board through its embedded FlashPro5 and OpenOCD, on the hardware backend. Every injection is a real register bit flipped in a running U54.
hfim init polarfire-zephyr-hardware my-campaigns
cd my-campaigns
hfim doctor
hfim run campaigns/zephyr_pi_register.yaml --local --workers 1
hfim init installs the probe package the template pins. hfim doctor then checks the station, the Linux machine the board is plugged into, and prints the command for each thing it lacks (Station).
Board¶
| Property | Value |
|---|---|
| Board | Microchip PolarFire SoC Discovery Kit |
| SoC | MPFS095T, JTAG idcode 0x0f8181cf |
| Harts | 1 E51 (RV64IMAC) and 4 U54 (RV64IMAFDC) |
| Clusters | 0: the E51, which runs the HSS from eNVM; 1: the four U54s, which run Zephyr |
| Debug | embedded FlashPro5 on USB connector J4, one GDB port per hart: E51 3333, U54 3344, 3355, 3366, 3377 |
| Hardware breakpoints | 10 per U54 |
| Console | MMUART4, FlashPro5 interface 2, 115200 baud |
One run:
- OpenOCD resets the whole SoC. The HSS boots again on the E51 and trains the DDR.
- HFIM halts the four U54s, loads the Zephyr ELF into low DDR over JTAG and starts them at its entry.
- A hardware breakpoint on
inject_at_symbolstops the four U54s together when one of them arrives there. - HFIM flips one bit of a register of the target U54, checks that the write stuck, and lets the run go on to
fim_exit. - It reads the observables through GDB and the console from MMUART4, and classifies the run against the golden run.
The E51 is never halted: it keeps running the HSS. The counters of a halted hart keep running (dcsr.stopcount = 0), so no instruction count is exact on this board and the campaigns use injection_mode: breakpoint.
Requirements¶
| Package | Version | Install |
|---|---|---|
| hfim | >=1.15,<2 |
hfim update |
hfim-probe-openocd |
0.12.0 |
hfim init or hfim run |
OpenOCD and gdb-multiarch |
Debian's, OpenOCD 0.12 or later | hfim doctor prints the apt-get line |
| Docker | usable by your user, for the build | only when ZEPHYR_BASE is unset (Build) |
The template pins a probe package, not a simulator: probe: hfim-probe-openocd@0.12.0 in hfim.yaml. The package names the GDB server and how to start it; its install.sh only checks that the system's OpenOCD is 0.12 or later. The OpenOCD configuration is the template's, probe/mpfs-per-hart.cfg. Microchip's SoftConsole OpenOCD and its fpServer are not used: OpenOCD 0.12 drives the FlashPro5 as the FTDI chip it is.
Station¶
The station is the Linux machine the board is plugged into. One USB cable carries JTAG and three UARTs. What the station needs is listed in board.yaml under hardware.host, and hfim doctor checks each item in its station: section:
station: what this machine needs for the board (board.yaml)
ok package openocd
ok package gdb-multiarch
ok package dkms
ok package linux-headers-7.2.9+deb13-amd64
ok kernel module ftdi_sio 1 (DKMS) for 7.2.9+deb13-amd64
ok udev rule /etc/udev/rules.d/70-hfim-flashpro5.rules
ok user <user> in group plugdev
ok user <user> in group dialout
ok board: USB 1514:2008 plugged in
ok console /dev/serial/by-id/usb-Microsemi_Embedded_FlashPro5_<SERIAL>-if02-port0
| Need | Why |
|---|---|
openocd, gdb-multiarch |
the GDB server and the debugger |
ftdi_sio from station/ftdi_sio/, built with DKMS, and so dkms and the running kernel's headers |
the stock driver leaves the FlashPro5's UARTs unbound; this one binds interfaces 1 to 3 and leaves interface 0, JTAG, to OpenOCD |
station/70-hfim-flashpro5.rules |
lets the user open the FlashPro5 |
groups plugdev and dialout |
JTAG through libusb, and the UARTs |
USB 1514:2008, the console device |
the board itself; reported as a note when it is unplugged |
hfim changes nothing on the station. Each missing item is marked MISS and followed by the exact command that fixes it, sudo included, for whoever administers the machine. Log in again after a group change. hfim doctor --board <board.yaml> prints only this section, for any board file.
Build¶
hfim run builds a benchmark when it needs one, with tools/build.sh. Zephyr v4.0.0 has no Discovery Kit; the board files are the template's, in zephyr/boards/. The image is linked at 0x81200000, inside the 32 MiB of low DDR the HSS maps.
| Mode | When | Toolchain |
|---|---|---|
| Docker | ZEPHYR_BASE unset |
the image tools/Dockerfile.build defines: Zephyr v4.0.0, Zephyr SDK 0.16.8 |
| Native | ZEPHYR_BASE set |
Zephyr v4.0.0 at ZEPHYR_BASE, the SDK at ZEPHYR_SDK_INSTALL_DIR, a Python with west at ZEPHYR_PYTHON |
The Docker build was verified on macOS. On the tested Linux station CMake configuration failed inside Docker; use the native build there. toolchain: in hfim.yaml identifies the native toolchain by the compiler binary, Zephyr's commit and west's version. Switching mode measures the golden run again.
With ZEPHYR_BASE set, hfim doctor does not ask for Docker.
Contents¶
| Path | Contents |
|---|---|
hfim.yaml |
template name, the core range, board, the probe pin, build, build_inputs, toolchain |
board.yaml |
harts and clusters, and hardware:: debug ports, probe config, load, reset, console, host |
probe/embedded_flashpro5.cfg, probe/mpfs-per-hart.cfg |
the OpenOCD configuration: the FlashPro5 as an FTDI adapter, and one GDB port per hart with no target smp |
station/ftdi_sio/ |
the ftdi_sio fix: fetch.sh takes the source of the running kernel's version, fix.patch adds the FlashPro5, dkms.conf builds it |
station/70-hfim-flashpro5.rules |
the udev rule |
benchmarks/zephyr_pi/ |
the benchmark |
benchmarks/common/ |
fim_zephyr.c and fim_zephyr.h: fim_init, fim_exit |
zephyr/ |
the Discovery Kit board files, smp_4cpu.conf, discovery_u54.conf (the link address) |
tools/build.sh, tools/Dockerfile.build |
the build and its image |
campaigns/ |
the campaigns below |
Benchmarks¶
| Benchmark | Zephyr sample | Work | Observables |
|---|---|---|---|
zephyr_pi |
samples/arch/smp/pi |
16 threads each compute 240 digits of pi, spread over the 4 U54s | th_buffer, uint8_t[3856]: the 16 results |
Campaigns¶
| Campaign file | Target | Injection | timeout |
|---|---|---|---|
zephyr_pi_register.yaml |
x1, x2, x8 to x15 of a random U54 |
breakpoint at test_thread, the function each of the 16 threads runs |
60 |
Every campaign includes campaigns/shared/discovery.yaml (the backend, gdb-multiarch, the U54 cluster, ZEPHYR FATAL ERROR as the crash text) and campaigns/zephyr_pi/zephyr_pi.yaml (the benchmark and its observables). A key the campaign states itself wins.
# campaigns/zephyr_pi_register.yaml
include: [zephyr_pi/zephyr_pi.yaml, shared/discovery.yaml]
campaign_name: "zephyr_pi_register"
target_core: random
seed: 1234
num_injections: 20
injection_mode: "breakpoint"
inject_at_symbol: "test_thread"
target_types: ["register"]
target_registers: ["x1", "x2", "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15"]
fault_model: "single_bit_flip"
timeout: 60
output_dir: "results/zephyr_pi_register"
The timed trigger is not used: zephyr_pi is shorter than one resume of the four U54s over the FlashPro5, 0.24 s, so a timed halt lands after fim_exit.
One board runs one injection at a time, so run with --workers 1. The first run measures the golden run: three runs, the window from fim_init to fim_exit, and the arrivals at the breakpoint symbol. A masked injection takes about 13 s. A crash or a hang takes about 69 s, because the run waits for timeout.
Another Discovery Kit¶
The console device in board.yaml names one board by its FlashPro5 serial number. Set another board's in the campaign:
hardware:
console:
device: /dev/serial/by-id/usb-Microsemi_Embedded_FlashPro5_<SERIAL>-if02-port0
Limitations¶
- The reset is OpenOCD's system reset; there is no power cycle. A board that stops answering JTAG needs its USB cable plugged in again.
- Only the U54s are targets. A fault in the E51 would disturb the HSS and its watchdog service.
- No instruction count is exact, so
injection_mode: icountand an instruction limit fortimeoutare not available.