PCILeechGen icon indicating copy to clipboard operation
PCILeechGen copied to clipboard

code 10 help

Open sthgi opened this issue 8 months ago • 6 comments

Description

for code 10 deeper into this i need a few things from you:

    what device are you cloning? (nvme, ethernet etc, what's the vid/did?)
    which fpga board are you using?
    are you on the latest version of pcileechgen?
    do you see any "overwriting previous definition" warnings in your vivado build log?
    any more detailed error messages in windows event viewer?

tp-link tx201 2.5 gigabit

Image
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
        Subsystem: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller
        Physical Slot: 1-1
        Flags: fast devsel, IRQ 251, IOMMU group 38
        I/O ports at b000 [size=256]
        Memory at bc000000 (64-bit, non-prefetchable) [size=64K]
        Memory at bc010000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, IntMsgNum 1
        Capabilities: [b0] MSI-X: Enable+ Count=32 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Virtual Channel
        Capabilities: [168] Device Serial Number 01-00-00-00-68-4c-e0-00
        Capabilities: [178] Transaction Processing Hints
        Capabilities: [204] Latency Tolerance Reporting
        Capabilities: [20c] L1 PM Substates
        Capabilities: [21c] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
        Kernel driver in use: r8169
        Kernel modules: r8169

I am using CaptainDMA 100T https://captaindma.com/product/captain-dma-100t-7th/

I am always using latest version of PCILeechGen, I have even deleted it and ran clone again.

With this clone device I never get further than this:

root@beelink:~/PCILeechGen# sudo ./bin/pcileechgen build --bdf 0000:03:00.0 --board CaptainDMA_100T
2026/03/10 21:51:14 INFO target device bdf=0000:03:00.0
2026/03/10 21:51:14 INFO collecting donor device data
2026/03/10 21:51:14 WARN sysfs BAR read returned all 0xFF, will retry via VFIO bar=2
2026/03/10 21:51:14 INFO BAR read complete bar=2 bytes=4096
2026/03/10 21:51:14 WARN sysfs BAR read returned all 0xFF, will retry via VFIO bar=4
2026/03/10 21:51:14 INFO BAR read complete bar=4 bytes=4096
2026/03/10 21:51:14 INFO attempting auto-bind to vfio-pci for BAR access
2026/03/10 21:51:14 WARN auto-bind to vfio-pci failed error="failed to unbind from current driver: open ../../../../../../bus/pci/drivers/unbind: no such file or directory"
2026/03/10 21:51:14 INFO BAR profiled bar=2 active_registers=1024
2026/03/10 21:51:14 INFO BAR profiled bar=4 active_registers=1024
2026/03/10 21:51:14 INFO MSI-X detected vectors=32 table_bar=4 table_offset=0x0 pba_bar=4 pba_offset=0x800
2026/03/10 21:51:14 WARN BAR content is all 0xFF - device may be inaccessible or in D3 power state bar=2 bytes=4096 class=0x020000
2026/03/10 21:51:14 WARN BAR content is all 0xFF - device may be inaccessible or in D3 power state bar=4 bytes=4096 class=0x020000
Error: device data collection failed: BAR content for class 0x020000 is all 0xFF (driver "r8169"). The device is not responding - possible causes:
  • device is in D3 (sleep) power state
  • IOMMU/VT-d not enabled or misconfigured
  • PCI Command Register memory space not enabled
  • device requires native driver initialization (e.g. CNVi WiFi, firmware-dependent devices)
Without valid BAR data, Windows will produce Code 10 and DMA will not work

Workarounds:
  1. Try: sudo setpci -s 0000:03:00.0 COMMAND=0x06
  2. For CNVi/WiFi: boot with native driver, dump BAR with a tool, then use --from-json
Usage:
  pcileechgen build [flags]

Flags:
      --bdf string           donor device BDF address (e.g. 0000:03:00.0)
      --board string         target FPGA board name (required, e.g. PCIeSquirrel)
      --from-json string     load donor device data from JSON file (offline build)
  -h, --help                 help for build
      --jobs int             number of parallel Vivado jobs (default 4)
      --lib-dir string       path to pcileech-fpga library (default "lib/pcileech-fpga")
      --output string        output directory (default "pcileech_datastore")
      --skip-vivado          skip Vivado synthesis (only generate artifacts)
      --timeout int          Vivado synthesis timeout in seconds (default 3600)
      --vivado-path string   path to Vivado installation

device data collection failed: BAR content for class 0x020000 is all 0xFF (driver "r8169"). The device is not responding - possible causes:
  • device is in D3 (sleep) power state
  • IOMMU/VT-d not enabled or misconfigured
  • PCI Command Register memory space not enabled
  • device requires native driver initialization (e.g. CNVi WiFi, firmware-dependent devices)
Without valid BAR data, Windows will produce Code 10 and DMA will not work

Workarounds:
  1. Try: sudo setpci -s 0000:03:00.0 COMMAND=0x06
  2. For CNVi/WiFi: boot with native driver, dump BAR with a tool, then use --from-json

I am guessing I should try some other devices because this one obviously doesn't work.

I tried using a wifi device tp-link ax3000:

03:00.0 Network controller: MEDIATEK Corp. MT7922 802.11ax PCI Express Wireless Network Adapter
        Subsystem: AzureWave Device 5916
        Physical Slot: 1-1
        Flags: bus master, fast devsel, latency 0, IRQ 263, IOMMU group 38
        Memory at 7000000000 (64-bit, prefetchable) [size=1M]
        Memory at bc000000 (64-bit, non-prefetchable) [size=32K]
        Capabilities: [80] Express Endpoint, IntMsgNum 0
        Capabilities: [e0] MSI: Enable+ Count=1/32 Maskable+ 64bit+
        Capabilities: [f8] Power Management version 3
        Capabilities: [100] Vendor Specific Information: ID=1556 Rev=1 Len=008 <?>
        Capabilities: [108] Latency Tolerance Reporting
        Capabilities: [110] L1 PM Substates
        Capabilities: [200] Advanced Error Reporting
        Kernel driver in use: mt7921e
        Kernel modules: mt7921e

This one got the furthest of anything I have tested so far.

vivado.log

I flashed and I was able to get successful dma speeds back

Image

If I try to install a driver dma speeds breaks.

Error Type

Code 10 (device cannot start)

Device Context File

device_context.json

Windows Event Log

Nothing shows up in event logs

Device Manager Error Details

Image

Terminal Output


sthgi avatar Mar 11 '26 02:03 sthgi

Image

sthgi avatar Mar 11 '26 03:03 sthgi

rtl8125 ethernet (tx201): the bar reads returning all 0xFF means the device isn't responding to mmio access. this is usually because the device is in d3 (sleep) power state or the r8169 driver holds it locked.

try before building:

sudo setpci -s 0000:03:00.0 COMMAND=0x06

if that doesn't work, try unbinding the driver first:

echo "0000:03:00.0" | sudo tee /sys/bus/pci/drivers/r8169/unbind
sudo setpci -s 0000:03:00.0 COMMAND=0x06

mt7922 wifi (ax3000): the code 10 when installing a driver was caused by the wifi strategy using intel/broadcom register maps (GP_CTL, UCODE_DRV_GP1). the mediatek mt7921e/mt7922 driver expects completely different register handshakes.

this is now fixed mediatek wifi devices (vid 0x14C3) automatically get a mediatek-specific strategy with correct chip id (0x7922), hardware revision, and hardware version registers. please pull latest and rebuild.

note: wfdma registers (0xd4000+) are beyond the 4kb bram window, so the driver may still timeout during firmware download. chip id probe should pass though, which is the first gate for avoiding code 10.

sercanarga avatar Mar 11 '26 03:03 sercanarga

Here is the wifi again. I am going to try another ethernet card.

device_context.json

vivado.log

sthgi avatar Mar 11 '26 06:03 sthgi

enhanced mediatek mt7922 register emulation:

  • added CONN_INFRA_CFG_ID at offset 0x1000
  • added HW_VER to PostInitRegisters
  • cleaned up unused constants

analyzed linux mt7921e driver source (drivers/net/wireless/mediatek/mt76/mt7921/pci.c): driver maps BAR0 only (pcim_iomap_regions(pdev, BIT(0))) probe sequence: fw_pmctrl -> drv_pmctrl -> chip id read -> wfsys_reset -> irq -> dma init wfdma engine registers at 0xd0000+ are beyond 4kb bram full driver probe pass is unlikely without a dedicated sv fsm this fix ensures chip id reads land on the correct bar. full driver compatibility would require trace data to build a mediatek-specific fsm (similar to nvme admin responder). if you can provide windows event log output from the code 10 failure, we can use that as trace data to identify which registers the windows driver reads during probe.

sercanarga avatar Mar 11 '26 13:03 sercanarga

updated pcileechgen and reran everything

device_context.json

vivado.log

This is the only thing I am seeing when I hook up the flashed 100t

Image

If I remove the driver and 100t goes back to a network controller with yellow shield nothing shows up in the windows event system logs. in this state dma test speeds work. applying any sort of driver breaks dma speed test.

Image

sthgi avatar Mar 11 '26 15:03 sthgi

the chip identification registers in the mediatek wifi bar0 emulation had incorrect values:

  • TOP_HW_CHIPID was 0x00007922, real hardware reports 0x79220010 (asic revision from dmesg)
  • TOP_HW_SW_VER was 0x00000001, real hardware reports 0x8A108A10
  • conn_infra cfg id write at offset 0x1000 was beyond 4kb bram and never actually written fixed in mediatek_wifi.go the mtkwlex driver should no longer throw event 5006 "version number is incorrect".

note: code 10 is still expected because the wfdma engine registers (0xd0000+) are far beyond the 4kb bram limit. full driver initialization for mt7922 would require significantly larger bar emulation.

sercanarga avatar Mar 11 '26 19:03 sercanarga