PCILeech Firmware Generator
CI/CD Status
Quality Metrics
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:
- 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). - Stage 2 (Container or local): Renders SystemVerilog, TCL, and COE files from the collected data. The container has no VFIO access.
- 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-onlystops 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
mmiotraceduring 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
.binimage throughusbloader.
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, orpcileech_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, rungit submodule update --init --recursive. Thelib/voltcyclone-fpgasubmodule holds the board definitions and synthesis sources. - The container clones
voltcyclone-fpgaduring 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
Documentation Links
- Installation Guide
- Quick Start Guide
- Host-Container Pipeline
- Container Builds
- Troubleshooting Guide
- Device Cloning Process
- Firmware Uniqueness
- Manual Donor Dump
- PCILeech Configuration
- Development Setup
- TUI Documentation
- Config Space Shadow
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.
Legal Notice
- 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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pcileechfwgenerator-0.20.3.tar.gz | 6.3 MB | With provenance | Details for pcileechfwgenerator-0.20.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pcileechfwgenerator-0.20.3-py3-none-any.whl | Python 3 | none | any | Details for pcileechfwgenerator-0.20.3-py3-none-any.whl |
Total release size: 12.2 MB
Release files / pcileechfwgenerator-0.20.3.tar.gz
| Download URL | pcileechfwgenerator-0.20.3.tar.gz |
|---|---|
| Size | 6.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e13af745495e404456fa90375d40db157cf6311d22e39d98c2715e9dc882e5a9
|
|
BLAKE2b-256 checksum How to use checksums |
3e97183769b3d14eca521d606b1266a630f28b6e949850792d18584ef03b739b
|
| 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 logRelease files / pcileechfwgenerator-0.20.3-py3-none-any.whl
| Download URL | pcileechfwgenerator-0.20.3-py3-none-any.whl |
|---|---|
| Size | 6.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d92efa42727f7f418c5c3e92e8644fb01b154c8448ca30aca00f464ea0a2175
|
|
BLAKE2b-256 checksum How to use checksums |
308d382f013cb265ab91e7efab952bc6df5b4d2e03f72faa1c8914b743a68c4a
|
| 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 logSecurity for PCILeechFWGenerator 0.20.3
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.
Attestation for pcileechfwgenerator-0.20.3.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 logA 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.