analogdevicesinc / libiio

A cross platform library for interfacing with local and remote Linux IIO devices
http://analogdevicesinc.github.io/libiio/
GNU Lesser General Public License v2.1
493 stars 318 forks source link

File not found when connecting to device #1217

Open HassanSlim opened 1 day ago

HassanSlim commented 1 day ago

Hi, I am building a yocto kirkstone image on xilinx zynq 7020 device. I am facing the following error when trying to read from a register.

File "util/fpga_util.py", line 16, in read_modify_write
    old_value = reg_access.reg_read(addr)
  File "util/iio.py", line 1181, in reg_read
    _d_reg_read(self._device, reg, _byref(value))
  File "util/iio.py", line 62, in _check_negative
    raise OSError(-result, _strerror(-result))
FileNotFoundError: [Errno 2] No such file or directory

The IIO versions that I tried till now are:

The python version which is used in zeus is 3.7, while in kirkstone is v3.10 (if this plays a role) Running iio_info in kirkstone I get the following:

$ iio_info
Library version: 0.23 (git tag: 92d6a35)
Compiled with backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.23 (git tag: 92d6a35)
Backend description string: Linux 5.15.36-xilinx-v2022.2 #1 SMP PREEMPT Mon Oct 3 07:50:07 UTC 2022 armv7l
IIO context has 2 attributes:
        local,kernel: 5.15.36-xilinx-v2022.2
        uri: local:
IIO context has 3 devices:
        iio:device0: xadc
                9 channels found:
                        .... (I removed them because not related to my question)
        iio:device1: datacap (buffer capable)
                        .... (I removed them because not related to my question)
        iio:device2: streaming_core (buffer capable)
                1 channels found:
                        voltage0: position_stream (input, index: 0, format: le:U32/32>>0)
                        1 channel-specific attributes found:
                                attr  0: label value: position_stream
                2 device-specific attributes found:
                                attr  0: data_lost value: 0
                                attr  1: enable_queue ERROR: Permission denied (13)
                3 buffer-specific attributes found:
                                attr  0: data_available value: 4096
                                attr  1: length_align_bytes value: 8
                                attr  2: watermark value: 512
                No trigger on this device

The device that I am trying to access is the streaming_core . Any help is appreciated.

Best regards, Hassan

mhennerich commented 1 day ago

Typically iio_info emits:

X debug attributes found: debug attr 0: direct_reg_access value: 0x90262

Did you mount debugfs? Does your device expose a debugfs direct_reg_access attribute?

Can you check: root@analog:~# ls /sys/kernel/debug/iio/iio\:device2/

HassanSlim commented 23 hours ago
$ ls /sys/kernel/debug/iio/iio:device2/
ls: /sys/kernel/debug/iio/iio:device2/: No such file or directory

I didn't mount debugfs, I didn't expect that debugfs is required for normal operation of IIO

mhennerich commented 23 hours ago

Reading and writing registers is not a normal operation. Therefore it's part of debugfs, and needs to be specifically mounted by root.

https://elixir.bootlin.com/linux/v6.13-rc1/source/Documentation/ABI/testing/debugfs-iio-backend