Device Tree Overlay for a Custom FPGA Peripheral

Load a bitstream and its driver binding at runtime on PetaLinux without rebuilding the image.

Owner: Rafael CostaEmbedded PlatformsContact ownerAdded 29 Sep 2026Updated 2 Oct 2026
  • Runs out of the box: no
  • Tests: yes
  • CI: no
  • Docs: yes
  • Used in production: no

Purpose#

A worked example of attaching a custom programmable-logic peripheral to a running Linux system. A Vivado project produces a bitstream for a small register block; a device tree overlay declares the peripheral; a minimal platform driver exposes it through sysfs.

The example loads the bitstream and applies the overlay from a script, then unloads both, so peripheral changes can be tested without rebuilding or reflashing the whole image.

What you will learn#

  1. Generate a bitstream and hardware description for a custom register block
  2. Write a device tree overlay and apply it at runtime
  3. Bind a minimal platform driver and expose registers through sysfs

Technologies & features#

Technologies
VHDLCZynq-7000PetaLinuxVivado
Features
Device Tree ConfigurationFPGA Bitstream Integration
Topics
Embedded/Linuxprimary

Lessons learned#

  • Worked

    Loading the overlay at runtime shortened the edit-test loop for the register map from a full image rebuild to under a minute.

  • Limitation

    Unloading the overlay while a userspace process holds the device open can hang; the script refuses to unload while the device is in use.

  • Note

    The overlay's compatible string must match the driver exactly; a one-character mismatch fails silently, so the load script now checks that the driver bound.

Try it#

Shell
git clone https://git.example.internal/embedded-platforms/fpga-overlay-demo.git
cd fpga-overlay-demo
petalinux-build   # needs the PetaLinux tools
# on the board:
./scripts/load-peripheral.sh demo_regs.bit demo_regs.dtbo
cat /sys/devices/platform/demo-regs/version

Commands come from the owner’s README. Credentials are never stored here.

Resources#

Contributes to

StatusReference
OwnerRafael Costa
TeamEmbedded Platforms
Last commit1 Oct 2026
Slugdevice-tree-overlay-fpga
Report a problem to the owner