PCILeechGen icon indicating copy to clipboard operation
PCILeechGen copied to clipboard

Warning could not read BAR content

Open sthgi opened this issue 8 months ago • 15 comments

Tried 3 devices so far USB, Ethernet and WiFi

[pcileechgen] Stage 1: Collecting donor device data... [donor] Warning: could not read BAR content: failed to read BAR2 content: read /sys/bus/pci/devices/0000:03:00.0/resource2: input/output error

All of them give the same error.

I am using this with a minipc would that matter? https://captaindma.com/product/thunderbolt-to-pcie-expansion-device/

sthgi avatar Mar 06 '26 17:03 sthgi

USB Device

root@beelink:~/PCILeechGen# ./bin/pcileechgen check --bdf 0000:03:00.0
Checking device 0000:03:00.0...

[OK] Device found: 1912:0014 USB controller
[OK] Config space readable: 4096 bytes
[OK] IOMMU is enabled
[OK] VFIO modules loaded
[OK] IOMMU group: 20
[OK] No driver bound

Capabilities (4):
  [01] Power Management at offset 0x50
  [05] MSI at offset 0x70
  [11] MSI-X at offset 0x90
  [10] PCI Express at offset 0xa0

Extended Capabilities (2):
  [0001] Advanced Error Reporting at offset 0x100
  [0018] Latency Tolerance Reporting at offset 0x150

BARs:
  BAR0: mem64 at 0xbc000000, size 8 KB

--- Board Compatibility ---
Donor Link: Gen2 (5.0 GT/s) x1
[WARN] Donor has no DSN capability (serial number won't be emulated)

Compatible boards:
  [OK] PCIeSquirrel           xc7a35tfgg484-2 x1 (exact match)
  [OK] ScreamerM2             xc7a35tcsg325-2 x1 (exact match)
  [OK] pciescreamer           xc7a35tfgg484-2 x1 (exact match)
  [OK] EnigmaX1               xc7a75tfgg484-2 x1 (exact match)
  [OK] CaptainDMA_M2_x1       xc7a35tcsg325-2 x1 (exact match)
  [OK] CaptainDMA_M2_x4       xc7a35tcsg325-2 x4
  [OK] CaptainDMA_35T         xc7a35tfgg484-2 x1 (exact match)
  [OK] CaptainDMA_75T         xc7a75tfgg484-2 x1 (exact match)
  [OK] CaptainDMA_100T        xc7a100tfgg484-2 x1 (exact match)
  [OK] ZDMA                   xc7a100tfgg484-2 x4
  [OK] GBOX                   xc7a35tfgg484-2 x1 (exact match)
  [OK] NeTV2_35T              xc7a35tfgg484-2 x1 (exact match)
  [OK] NeTV2_100T             xc7a100tfgg484-2 x1 (exact match)
  [OK] ac701_ft601            xc7a200tfbg676-2 x4
  [OK] acorn                  xc7a200tfbg484-3 x4
  [OK] litefury               xc7a100tfgg484-2 x4
  [OK] sp605_ft601            xc6slx45tfgg484-2 x1 (exact match)

Total: 17 boards

--- Check complete ---

Ethernet Device:

root@beelink:~/PCILeechGen# ./bin/pcileechgen check --bdf 0000:03:00.0
Checking device 0000:03:00.0...

[OK] Device found: 10ec:8125 Ethernet controller
[OK] Config space readable: 4096 bytes
[OK] IOMMU is enabled
[OK] VFIO modules loaded
[OK] IOMMU group: 20
[OK] No driver bound

Capabilities (5):
  [01] Power Management at offset 0x40
  [05] MSI at offset 0x50
  [10] PCI Express at offset 0x70
  [11] MSI-X at offset 0xb0
  [03] Vital Product Data at offset 0xd0

Extended Capabilities (7):
  [0001] Advanced Error Reporting at offset 0x100
  [0002] Virtual Channel (No MFVC) at offset 0x148
  [0003] Device Serial Number at offset 0x168
  [0017] Unknown at offset 0x178
  [0018] Latency Tolerance Reporting at offset 0x204
  [001e] L1 PM Substates at offset 0x20c
  [000b] Vendor Specific at offset 0x21c

BARs:
  BAR0: io at 0xb000, size 256 B
  BAR2: mem64 at 0xbc000000, size 64 KB
  BAR4: mem64 at 0xbc010000, size 16 KB

--- Board Compatibility ---
Donor Link: Gen2 (5.0 GT/s) x1
Donor DSN:  0x01000000684CE000

Compatible boards:
  [OK] PCIeSquirrel           xc7a35tfgg484-2 x1 (exact match)
  [OK] ScreamerM2             xc7a35tcsg325-2 x1 (exact match)
  [OK] pciescreamer           xc7a35tfgg484-2 x1 (exact match)
  [OK] EnigmaX1               xc7a75tfgg484-2 x1 (exact match)
  [OK] CaptainDMA_M2_x1       xc7a35tcsg325-2 x1 (exact match)
  [OK] CaptainDMA_M2_x4       xc7a35tcsg325-2 x4
  [OK] CaptainDMA_35T         xc7a35tfgg484-2 x1 (exact match)
  [OK] CaptainDMA_75T         xc7a75tfgg484-2 x1 (exact match)
  [OK] CaptainDMA_100T        xc7a100tfgg484-2 x1 (exact match)
  [OK] ZDMA                   xc7a100tfgg484-2 x4
  [OK] GBOX                   xc7a35tfgg484-2 x1 (exact match)
  [OK] NeTV2_35T              xc7a35tfgg484-2 x1 (exact match)
  [OK] NeTV2_100T             xc7a100tfgg484-2 x1 (exact match)
  [OK] ac701_ft601            xc7a200tfbg676-2 x4
  [OK] acorn                  xc7a200tfbg484-3 x4
  [OK] litefury               xc7a100tfgg484-2 x4
  [OK] sp605_ft601            xc6slx45tfgg484-2 x1 (exact match)

Total: 17 boards

--- Check complete ---

sthgi avatar Mar 06 '26 17:03 sthgi

hey, thanks for reporting this with the full outputs, super helpful.

the problem was twofold: when no driver is bound, bar memory isn't accessible via sysfs, and the vfio fallback wasn't kicking in because it only worked if the device was already on vfio-pci. on top of that, the tool was treating missing bar data as a hard failure for every device class, even though it's only actually critical for nvme and usb controllers.

pushed a fix that auto-binds to vfio-pci when needed and relaxes the bar validation for non-critical device classes. that said, this hasn't been tested on real ethernet/wi-fi hardware yet, would appreciate it if you could give it a try and let me know how it goes.

i strongly recommend going with the network card as it has a dsn number

sercanarga avatar Mar 06 '26 18:03 sercanarga

updated PCILeechGen

root@beelink:~/PCILeechGen# sudo ./bin/pcileechgen build --bdf 0000:03:00.0 --board CaptainDMA_100T
[pcileechgen] Target device: 0000:03:00.0
[pcileechgen] Stage 1: Collecting donor device data...
[donor] Warning: could not read BAR2 content: failed to read BAR2 content: read /sys/bus/pci/devices/0000:03:00.0/resource2: input/output error
[donor] Warning: could not read BAR4 content: failed to read BAR4 content: read /sys/bus/pci/devices/0000:03:00.0/resource4: input/output error
[pcileechgen] Target board: CaptainDMA_100T (xc7a100tfgg484-2)
[pcileechgen] Output: pcileech_datastore
[pcileechgen] Device: 10ec:8125 Ethernet controller (rev 04)
[pcileechgen] Config space: 4096 bytes
[pcileechgen] Capabilities: 5 standard, 7 extended
[pcileechgen] BARs: 6

sthgi avatar Mar 06 '26 18:03 sthgi

was the build not completed?

sercanarga avatar Mar 06 '26 23:03 sercanarga

was the build not completed?

Sorry thought because it showed "Warning: could not read BAR" it did not work.

device_context.json

vivado.log

sthgi avatar Mar 07 '26 00:03 sthgi

Image

speedtest fails as well

sthgi avatar Mar 07 '26 01:03 sthgi

try again please

sercanarga avatar Mar 07 '26 02:03 sercanarga

https://github.com/sercanarga/PCILeechGen/commit/399d6c4ddc178c41f7cc71ec931411c5c8249499 some improvements have been made. check please

sercanarga avatar Mar 07 '26 18:03 sercanarga

several bar register offsets in the ethernet model weren't dword-aligned (0xDA, 0x3E, 0xE2), which caused duplicate verilog case labels in the generated firmware. the driver couldn't read phyar/eriar properly code 10.

fixed in latest commit. also added build-time validation so this can't happen again. pull latest and try again when you get a chance.

sercanarga avatar Mar 07 '26 23:03 sercanarga

you are using an old version of the tool. need to update it

sercanarga avatar Mar 08 '26 02:03 sercanarga

the root cause was that the tool couldn't read bar content because vfio-pci wasn't bound to the device. i've fixed this with a series of commits:

1508f8b the tool now automatically binds vfio-pci when a bar read fails, and relaxes validation for non-critical device classes so the build can still complete.

8810942 switched the ethernet profile from intel gbe to realtek rtl8125 since that's the more common target.

399d6c4 added full rtl8125 compatibility with proper bar model, register emulation, and correct bar selection (uses bar2 mmio instead of bar0 io).

8e3a509 fixed ethernet bar register offsets to be dword-aligned and added build-time offset validation to catch similar issues early.

sercanarga avatar Mar 08 '26 19:03 sercanarga