Skip to main content

PCILeech Firmware Generator

CI/CD Status

CI Security E2E Release

Quality Metrics

codecov Python Version License Latest Release Downloads

Discord

Generate PCIe DMA firmware from real donor hardware. The tool reads a donor card's configuration over VFIO and builds a PCILeech FPGA bitstream from it.

Build Pipeline

The generator runs three stages:

  1. Stage 1 (Host): Collects PCIe device data via VFIO. This includes config space, BARs, the capability chain, MSI-X tables, and register behavior learned by tracing the native driver with mmiotrace (skip with --no-mmio-learning).
  2. Stage 2 (Container or local): Renders SystemVerilog, TCL, and COE files from the collected data. The container has no VFIO access.
  3. Stage 3 (Host): Runs Vivado through build_all.tcl, the only Stage 3 entry. Routed timing, clock coverage, DRC, and CDC checks must pass before the bitstream is written. Stage 3 is optional (--templates-only stops after Stage 2).

See Host-Container Pipeline for details.

Key Features

  • Donor analysis: Real PCIe configuration and register maps from live hardware via VFIO.
  • Register learning: Native driver behavior captured with mmiotrace during Stage 1.
  • Config-space shadow: Full 4 KB shadow in BRAM with an explicit writemask policy.
  • MSI-X: Served from the donor's own BAR, including multi-BAR layouts. Overview and limits are in MSIX_STATUS.md.
  • Offline capture: Collect once, then render later without the donor (see below).
  • Interactive TUI: Textual-based interface for device selection and builds.
  • Flashing: USB flashing of a .bin image through usbloader.

Quick Start

Installation (Ubuntu 22.04+ / Debian 12+)

Modern Linux requires a virtual environment:

# Create and activate virtual environment
python3 -m venv ~/.pcileech-venv
source ~/.pcileech-venv/bin/activate

# Install with TUI support
pip install pcileechfwgenerator[tui]

# Verify installation
pcileech version

Running with Root Access (Required for VFIO)

VFIO requires root. Use the venv's Python directly with sudo:

# Add this alias to ~/.bashrc for convenience:
echo "alias pcileech-sudo='sudo ~/.pcileech-venv/bin/python3 -m pcileechfwgenerator.pcileech_main'" >> ~/.bashrc
source ~/.bashrc

# Load VFIO modules
sudo modprobe vfio vfio-pci

# Now run commands with pcileech-sudo:
pcileech-sudo tui                                                    # Interactive TUI
pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1   # CLI build
pcileech-sudo check --device 0000:03:00.0                            # VFIO diagnostics

For complete setup including IOMMU configuration, see the Installation Guide.

Requirements

  • Python 3.11 or newer
  • Linux with VFIO support (Stage 1)
  • A donor PCIe card (any inexpensive NIC, sound, or capture card)

Optional:

  • Podman, for isolated Stage 2 templating
  • A PCILeech DMA board (for example pcileech_75t484_x1, pcileech_35t325_x4, or pcileech_100t484_x1)
  • Vivado 2022.2 or newer for Stage 3

CLI Commands

# Interactive TUI (recommended for first-time users)
pcileech-sudo tui

# Full 3-stage build
pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1

# Stage 1 only (collect device data, then exit)
pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1 --host-collect-only

# Run Stage 2 locally (skip the container)
pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1 --local

# Full build with an explicit Vivado install
pcileech-sudo build --bdf 0000:03:00.0 --board pcileech_35t325_x1 \
    --vivado-path /tools/Xilinx/2025.1/Vivado --vivado-jobs 8 --vivado-timeout 7200

# Opt-in build flags (see `pcileech build --help`)
#   --writable-bar-fallback  emulate writable RAM for a served BAR with no learned register model
#                            (default is read-only; this is not donor behavior)
#   --ft601-legacy-phy       legacy FT601 PHY instead of the MMCM one (CaptainDMA 100T only)
#   --no-mmio-learning       skip the mmiotrace driver capture in Stage 1
#   --force-recapture        redo MMIO capture even if cached models exist

# Check VFIO configuration
pcileech-sudo check --device 0000:03:00.0

# Flash a firmware image (.bin, written through usbloader)
pcileech-sudo flash firmware.bin --board pcileech_35t325_x1

# Show version information (no sudo needed)
pcileech version

Offline Captures

Saved donor captures need matching, versioned device-context and MSI-X files. Older or incomplete captures must be collected again into a fresh --datastore, because collection never overwrites an existing capture. Reuse checks the requested PCI address and the current device identity. See the capture format and migration guide.

The CLI provides capture collect, capture validate, capture import, and build --from-capture DIR --templates-only. Complete captures include measured BAR lengths and can be rebuilt without the donor, on the machine that collected them. See the offline workflow and its limits.

Version Updates

CLI builds check for newer versions. Set PCILEECH_DISABLE_UPDATE_CHECK=1 to disable the check, or run pcileech version to see the current version.

Development from Repository

# Clone with the board submodule
git clone --recurse-submodules https://github.com/voltcyclone/PCILeechFWGenerator.git
cd PCILeechFWGenerator

python3 -m venv .venv && source .venv/bin/activate
pip install -e .

# From a checkout, run the root script
sudo -E python3 pcileech.py tui
  • If you cloned without --recurse-submodules, run git submodule update --init --recursive. The lib/voltcyclone-fpga submodule holds the board definitions and synthesis sources.
  • The container clones voltcyclone-fpga during the image build and needs no submodule.
  • pip installs bundle the board files (installed under pcileechfwgenerator/voltcyclone_fpga), so they need no checkout. Only a source checkout needs --recurse-submodules.

Troubleshooting

See the Troubleshooting Guide for VFIO setup, installation problems, BAR detection, and locked IP cores.

Common Issues

"externally-managed-environment" Error

Use a virtual environment:

python3 -m venv ~/.pcileech-venv
source ~/.pcileech-venv/bin/activate
pip install pcileechfwgenerator[tui]

"ModuleNotFoundError: No module named 'textual'"

Install with TUI support:

pip install pcileechfwgenerator[tui]

TUI build settings and older profiles

The TUI uses the shared CLI pipeline in the active Python environment. Select a real board and choose local or container templating. Both modes collect and run Vivado on the Linux host. Unsupported legacy profile settings fail before collection. See the TUI build contract and migration guide.

"Permission denied" / VFIO Errors

Use the venv's Python with sudo:

sudo ~/.pcileech-venv/bin/python3 -m pcileechfwgenerator.pcileech_main tui

Quick Diagnostic

pcileech-sudo check --device 0000:03:00.0 --interactive

The docs are managed in the site repo and served by Cloudflare.

Output Files

Artifacts go to the datastore (default pcileech_datastore/):

pcileech_datastore/
├── device_context.json       # Stage 1: collected device data
├── msix_data.json            # Stage 1: MSI-X capability data
└── output/                   # Stage 2 and 3 artifacts, including a per-board directory
    ├── pcileech_top.sv       # Top-level SystemVerilog module
    ├── device_config.sv      # Device configuration module
    ├── build_all.tcl         # Stage 3 entry script
    └── *.bit                 # Bitstream (only after Stage 3)

Board vivado_*.tcl project scripts are not staged. build_all.tcl is the only Stage 3 entry.

Cleanup and Safety

  • Rebind donors to their original drivers through the TUI or CLI after collection.
  • Keep generated firmware private. It contains real device identifiers.
  • Build in an isolated environment, never on a production system.

Acknowledgments

  • PCILeech Community: For feedback and contributions
  • @Simonrak for the writemask implementation

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

  • Use dedicated, separate hardware for builds.
  • Follow responsible disclosure for any security research, and see SECURITY.md to report a vulnerability.

Metadata

Release files for PCILeechFWGenerator 0.20.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PCILeechFWGenerator 0.20.2
File Size Uploaded Provenance Actions
pcileechfwgenerator-0.20.2.tar.gz 6.3 MB With provenance Details for pcileechfwgenerator-0.20.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PCILeechFWGenerator 0.20.2
File Interpreter ABI Platform Actions
pcileechfwgenerator-0.20.2-py3-none-any.whl Python 3 none any Details for pcileechfwgenerator-0.20.2-py3-none-any.whl

Total release size: 12.2 MB

Release files / pcileechfwgenerator-0.20.2.tar.gz

Download URL pcileechfwgenerator-0.20.2.tar.gz
Size 6.3 MB
Tags Source
SHA-256 checksum
How to use checksums
ffecbeb6d8584c6b9a102dcf2899f6d9441fce23b24aa224daf2671ff5edaa51
BLAKE2b-256 checksum
How to use checksums
e502797be3a0b04548fed31fa9a4e583b3afd1afbc509905c10a9d4204ebb84b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / pcileechfwgenerator-0.20.2-py3-none-any.whl

Download URL pcileechfwgenerator-0.20.2-py3-none-any.whl
Size 6.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
59d55047cb74c1f41370d8a96ff937bda2ca9a22dffcd488f7e65257ac1f4032
BLAKE2b-256 checksum
How to use checksums
d7486b4c71e752239239ca0892762f012ea252de7b519b211e4cff4cadf8b601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for PCILeechFWGenerator 0.20.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pcileechfwgenerator-0.20.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.20.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page