I'm trying to access the ram in a PCIe fpga device using python and pypcie,This is my code:
from pypcie import Device#Defining the pci extended BDF connection id of the target deviced=Device("0000:01:00.0")#Set bar mapping valuebar = d.bar[2]#Write bar.write(0x0000, 0x00000001)
Rather simple and similar to the example they have given on their git page.
But when I run the code I encounter the Error
Traceback (most recent call last): File "/home/lab/Desktop/PCIE_playground/pcie_bar_access.py", line 4, in <module> d=Device("0000:01:00.0") ^^^^^^^^^^^^^^^^^^^^^^ File "/home/lab/.local/lib/python3.12/site-packages/pypcie/device.py", line 23, in __init__ self.bar[barnum] = Bar(resfile) ^^^^^^^^^^^^ File "/home/lab/.local/lib/python3.12/site-packages/pypcie/bar.py", line 17, in __init__ fd = os.open(filename, os.O_RDWR) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^PermissionError: [Errno 13] Permission denied: '/sys/bus/pci/devices/0000:01:00.0/resource0'
From this I assume its just a permission issue so I go into the console to try and give everyone permission to RW the file though I assumed I would have permission to do so since I am the only user on the PC, but when I run chmod 666 resource0
in the corresponding directory
it returns the following error instead:
chmod: changing permissions of 'resource0': Operation not permitted
I tried googling for ways to change the permission but nothing seems to work.
I am working on a Ubuntu 20.04.6 LTS