You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 18, 2025. It is now read-only.
Pavel A edited this page Nov 21, 2016
·
3 revisions
Accessing BARs and configuration space of PCI device in Python
This is a pure Python implementation of accessing physical memory of a device thru /sys/bus/pci. It does not call libdevmem (the C library) - but uses standard Python library modules: mmap, ctypes and others.
The memory can be accessed by 32-bit, 16-bit and 8-bit units.
The device is located by PCI vendor and device ID.
Root access is required.
There are two Python modules: one deals with finding a PCI device and its BARS, the other module maps selected BAR (or config. space) and provides memory access functions.
Instead of finding the device by PCI ID and mapping the BARs, you can make a variant of the first module, that uses a fixed physical address and maps part of the /dev/mem file.