Skip to Content
Viewing feat/fpga-bringup docs — not the stable branch. Changes vs main · Go to main

Demos

Relevant source files

The demos under userspace/demos/ are executable examples and integration probes, not production tools. Most follow the same pattern: create a map, build a small BPF program from raw instructions, BPF_PROG_LOAD it, BPF_PROG_ATTACH it to a hook, then read results.

Catalog

All except safety_demo are installed in /bin of the rootfs.

BinaryRole (components.toml)PurposePlatform notes
gpio_demoGPIO demoLoads a BPF program attached to GPIO 17 rising edge that toggles an LED on GPIO 18 (button to LED), then runs indefinitelyGPIO attach is Pi 5 only
pwm_demoPWM demoRetired. Prints that PWM observation hooks are unsupported (suggests the actuation audit and external capture) and exits 1. The command name is keptPi 5 PWM
timeseries_demotime-series map demoCreates a TIMESERIES map, loads a producer program attached to the timer, and reads the latest timestamp and value from userspaceTimer attach
iio_demoIIO demoRingbuf map plus a BPF filter attached to IIO device 0 that keeps sensor values within 100 to 900 (the constants MIN_VALUE and MAX_VALUE); event layout must match kernel_bpf/src/attach/iio.rsIIO attach is Pi 5 only
syscall_demosyscall demoExercises malloc, writev, pipe, dup, dup2, read, write and close
sys_exit_demotask-exit probeCreates a ringbuf, loads a program on the sys_exit hook, polls events (syscall_nr, result). Four-step bannerGate: target build and QEMU
sched_switch_demoscheduler demoCreates a ringbuf, loads a sched_switch trace program, attaches it, and prints live scheduler events from the same process
sched_switch_export_demoscheduler export demoSame hook, but pins the ringbuf at /sys/fs/bpf/maps/sched_switch_events with BPF_OBJ_PIN so another process can consume itUsed by smoke-bpf.sh
sched_switch_bridge_demoscheduler bridge demoOpens the pinned ringbuf (BPF_OBJ_GET), launches a workload (fork_test twice and syscall_demo), polls up to 120 times and prints events. Tells you to run the export demo first if the object is missingConsumer half of the pair
file_io_demofilesystem demoReads /bin/init and writes to /dev/null
fork_testprocess lifecycle probefork, child prints and exits 42, parent waitpid checks status. Also the execve target in init’s lifecycle probeGate: target build and QEMU
safety_demosafety-state demo“Legacy BPF reflex demo”: a motor program on the timer (PWM0 channel 1 at 50 percent duty) and a monitored limit-switch reflex on GPIO 17. It states it is not the hard e-stop pathNot in the rootfs (disposition none)

safety_demo prints that it is a monitored BPF reflex path and not the hard e-stop. The hard stop path it points to is SYS_ESTOP, the watchdog, and the GPIO24 bench path.

Typical sequence: scheduler tracing

Each sched_switch event is 40 bytes: cpu_id, prev_pid, prev_tid, next_pid, next_tid, all u64. In the development configuration, init spawns the export demo and then the bridge demo. The UART forwarder reads the same pinned object.

Running a demo

Demos are plain executables in /bin. The README lists a “shell + basic utilities”, but the repository only shows init auto-starting the loader; to launch another demo, spawn it from a program via spawn or spawn_restricted, or use whatever shell the kernel provides. Hook availability matters: GPIO, IIO and PWM attach types are listed as Raspberry Pi 5 only in docs/reference/generated/abi.md.

Last updated on