I am using a verdin imx8mm on a yavia carrier board.
In my application, I am trying to create an iio_buffer but it is giving permission errors.
I have tried using privileged mode, used cap_add ALL and given direct access to /sys/bus/iio/devices folder.
reading raw channels and enabling channels works fine from inside the application. The sensor I am working with is an ads1015 which is built in.
The code is as follows for general reference:
// Example adjustment for debugging
for (auto& d : devices) {
if (iio_device_is_trigger(d.trigPtr) < 0) {
SPDLOG_ERROR("Device {} does not support trigger operations", d.name);
} else {
SPDLOG_INFO("Device {} supports trigger operations", d.name);
}
size_t sample_size = iio_device_get_sample_size(d.ptr);
size_t num_samples = 10; // Example: buffer 10 samples
size_t buffer_size = sample_size * num_samples;
SPDLOG_INFO("Attempting to create a buffer of {} bytes for device {}", buffer_size, d.name);
iio_buffer* bufPtr = iio_device_create_buffer(d.ptr, num_samples, true);
if (!bufPtr) {
SPDLOG_ERROR("Failed to create IIO buffer for device {}. Sample size: {}, Buffer size: {}", d.name,
sample_size, buffer_size);
SPDLOG_ERROR("Error: {}", strerror(errno));
continue;
}
device_buffers[d.ptr] = bufPtr;
}
trying from ssh:
torizon@verdin-imx8mm-14756428:/sys/bus/iio/devices/iio:device0/buffer0$ cat length
240
torizon@verdin-imx8mm-14756428:/sys/bus/iio/devices/iio:device0/buffer0$ echo 1 > enable
-sh: enable: Permission denied
torizon@verdin-imx8mm-14756428:/sys/bus/iio/devices/iio:device0/buffer0$ sudo echo 1 > enable
-sh: enable: Permission denied
trying iio_info from container built with iio_utils:
root@d39b042be0d1:/# iio_info
Library version: 0.24 (git tag: v0.24)
Compiled with backends: local xml ip usb
IIO context created with local backend.
Backend version: 0.24 (git tag: v0.24)
Backend description string: Linux d39b042be0d1 5.15.129-6.5.0-devel+git.6f8fd49366db #1-TorizonCore SMP PREEMPT Fri Dec 22 11:15:52 UTC 2023 aarch64
IIO context has 2 attributes:
local,kernel: 5.15.129-6.5.0-devel+git.6f8fd49366db
uri: local:
IIO context has 1 devices:
iio:device0: ads1015 (buffer capable)
9 channels found:
voltage0-voltage1: (input, index: 0, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 0
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage0-voltage3: (input, index: 1, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 0
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage1-voltage3: (input, index: 2, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 0
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage2-voltage3: (input, index: 3, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 0
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage0: (input, index: 4, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 340
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage1: (input, index: 5, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 291
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage2: (input, index: 6, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 290
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
voltage3: (input, index: 7, format: le:s12/16>>4)
3 channel-specific attributes found:
attr 0: raw value: 290
attr 1: sampling_frequency value: 1600
attr 2: scale value: 1.000000000
timestamp: (input, index: 8, format: le:S64/64>>0)
3 device-specific attributes found:
attr 0: current_timestamp_clock value: realtime
attr 1: sampling_frequency_available value: 128 250 490 920 1600 2400 3300
attr 2: scale_available value: 3 2 1 0.5 0.25 0.125
1 buffer-specific attributes found:
attr 0: data_available value: 0
ERROR: checking for trigger : Input/output error (5)
Any pointers would be welcome.
Best Regards.