Device node getting created but device driver not getting linked - linux

I have written a simple device driver. Only loading the module my device file is getting created. But when my application tries to open the device file I am getting an error -1 (operation not permitted). When I have tried to look at device characteristics by executing the command:
$udevadm info -a -p /sys/class/char/<devname>
I get the output:
KERNEL=="<devname>"
SUBSYSTEM=="char"
DRIVER==" "
So apparently my device node is not getting linked to the device driver.
Can anybody please help me out with this.
Thanks

Have you checked the permissions on the device node udev created?
Udev manages the permissions of those device nodes, and unless you're running as root it's quite likely you're not allowed to read/write from/to the device node.
Edit
If you're running as root the permissions on the device node won't be a factor. Please show us the content of /proc/devices, the output of ls -la /dev/my-device-node and your code.

Related

how to give permission to intel realsense camera on Ubuntu

OS:Ubuntu 18.04
camera: Intel realsense D415
I can use cheese to show the compound image of the camera. But when I run
import pyrealsense2 as rs
pipeline = rs.pipeline()
pipeline.start()
It throws out error access failed for 8086:ad6 uid: 1-1-12
Is anyone that knows how to solve this? Thanks!
You need to install Intel Realsense permission scripts located in librealsense source directory.
For that, first, git clone the librealsense to a local folder
git clone https://github.com/IntelRealSense/librealsense
Next, run the following commands to copy the 99-realsense-libusb.rules files to the rules.d folder
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
And, then udevadm control to modify the internal state of the running udev dameon to reload rules. Also, udevadm trigger to request device events from the kernel.
sudo udevadm control --reload-rules
sudo udevadm trigger
Update: I recently faced the Runtime error: backend-v412.cpp:988 - Frames didn't arrived within 5 seconds. Seems like the pipeline is not able to handle the framebuffers, and there is quite a lot of drop in the frames, specifically above 720p, 15 frames/sec.
Any resolutions?
Update 2:
Resolution: As suspected it is a pipelining issue w.r.t the amount of the data the USB port can carry. To prevent frame drop or overload of data through the USB, it has to be connected to a Motherboard that has USB 3.1 Gen 1 specifications. Refer to page 78 of this document https://www.intelrealsense.com/wp-content/uploads/2020/06/Intel-RealSense-D400-Series-Datasheet-June-2020.pdf

Vfio 0000:41:00.0: failed to open /dev/vfio/32: No such file or directory - QEMU

I have a NVME M.2 SSD that I would like to pass-through to my Virtual Machine as a boot, My SSD works fine with the Virtual Machine Manager, but when I attempt to the Qemu:Console, I get the following message Saying it is not a existing file?!
checked if it the pass-through worked!
This is the Qemu Console command I am using
-device vfio-pci,host=41:00.0
Reading on I found it was a QEMU Console Permission error. I can't find a way to set the vfio permission for manjaro, I heard something of setting a udev perms up, PCI Passthrough is working for other devices, Like my GT710 is working fine.
I then noticed that it was attached to the host and I could not find anyway to remove it, as seen here.
Please Help me!
You need bind your PCI device to the vfio-pci driver.
Unbind pci device from its previous driver
echo "0000:00:14.0" > /sys/devices/pci0000:00/0000:00:14.0/driver/unbind
Bind to vfio-pci driver
echo 8086 a36d > /sys/bus/pci/drivers/vfio-pci/new_id
Where 8086 is the vendor id of the PCI device, and a36d is device id of the PCI device
Check and vfio group should be present, and Qemu can run.
ls -l /dev/vfio/

Serial port unavaliable arduino

Trying to upload a code to arduino, but whether in the Arduino IDE or Arduino Create, both return this erro while uploading. Running on Linux Tara(mint 19 cinnamon).
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:mega:cpu=atmega2560 -build-cache /tmp -build-path /tmp/716441957/build -verbose -libraries /tmp/716441957/custom -libraries /tmp/716441957/pinned /tmp/716441957/sketch_oct8a
Sketch uses 8280 bytes (3%) of program storage space. Maximum is 253952 bytes.
Global variables use 443 bytes (5%) of dynamic memory, leaving 7749 bytes for local variables. Maximum is 8192 bytes.
Programming with: Serial
Flashing with command:/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/bin/avrdude -C/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/etc/avrdude.conf -q -q -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino-create-agent734074237/sketch_oct8a.hex:i
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device
1#
First, check the port in your IDE. In Arduino tools->port
If the port is hidden or you can not move the cursor over this then run this commands in your terminal.If everything ok then skips this and follow the second part.
sudo apt-get install librxtx-java -y
sudo usermod -aG dialout $USER
sudo apt-get install gnome-system-tools
2#
After this again check the first method. If it is not working then run this commands
ls -l /dev/ttyACM*
sudo usermod -a -G dialout <username>
You probably have another program running which is already using this port.
You should close most other programs like putty or another serial monitor app.
Otherwise, try to reconnect the Arduino to the PC.
I know that these ideas below come from using a Teensy, but they may help you.
Sometimes there are the ACM* ports listed in the Arduino IDE. Try looking at the ser ports. I know when I am running my Teensy, sometimes I have them switched and need to select the correct one.
Also, from my experience with the Teensy, you might need to add a udev rule to allow permissions to access the port from non-root user. Here is the link that shows the udev file.
There is no direct way to solve this issue. In addition to it, you are not using an IDE. I will list the things you need to check, I am sure this will solve your problem.
I am not good at Linux environment so I will refer to applications names as window, you go the corresponding application in Linux.
Go to linux device manager and see for your arduino board. It should have proper naming like "arduino uno at port 3", then use the correct port in your command. If this name does not come properly then it means Driver is not available in your machine. So, go to step2.
Find the driver online and install it in your system, I am not sure about the support of linux with arduino, once it is done please repeat step1.
So, I conclude in short that you do not have the proper driver (which is strongly believe) or pointing the wrong port. I am not an expert with the udev rules, but it is definitely an issue you can experience with these kinds of micro-controllers.

libusb calls without sudo using udev-rules

Tested on Kubuntu 16.04 64 bit only. I have an application which source is not under my control. It uses some libusb calls which ends up in e.g.:
libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/001/031: Permission denied
libusb: error [_get_usbfs_fd] libusb requires write access to USB device nodes.
When running the above mentioned application as root, it works as expected.
When I change the permissions of the regarding file like:
sudo chmod a+w /dev/bus/usb/001/031
then the application will work with standard user rights (until I disconnect / reconnect my usb device).
Now I'm looking for a way, to e.g. automatically execute the chmod a+w each time when the specific usb device is plugged in.
Might this be possible by writing a specific udev rule?
Maybe other solutions the libusb calls without root rights?
Solution: Based upon David Grayson's answer, I'd now added an additional line with SUBSYSTEM=="usb" to my rule file. My rules file now finally looks like this:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666"
I suggest that you add a new file in /etc/udev/rules.d named usb.rules. It should have the following contents:
SUBSYSTEM=="usb", MODE="0666"
This will make all USB devices readable and writable by all users.
You could also narrow it down to specific USB devices using idVendor and idProduct attributes mentioned in Ignacio's answer.
Assuming Kubuntu 16.04 uses PolicyKit, put the following in a file in /etc/udev/rules.d, naming it similarly to the files that already exist there:
ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="xxxx", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1"
Replace the two sets of "xxxx" with the vendor ID and product ID of the device respectively.
Oldie but goldie. Help me to solve my issue with sharing the usb with virtual machines under AQEMU. Thanks a lot.
I added to the /etc/udev/rules.d file usb.rules with this line
SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666"
and virtual machine can see USB stick being connected life.

Connecting to ALSA

When I try to connect to the ALSA sound system as another user on one of our machines I get the following message- "ALSA lib pcm_dmix.c:975:(snd_pcm_dmix_open) unable to create IPC semaphore". The machine has been logged in as another user in our system. It doesn't matter if I use aplay or my application I get the same message. If I run as root the application connects to the ALSA system and plays the sound. If I su to the user who is logged into the console I get the same failure.
Does anyone have any ideas? I have tried to use setcap on my program but this failed due to "Operation not supported". This maybe because my application is on a NFS mounted partition.
Try setting ipc_key_add_uid in your .asoundrc file. see ALSA documentation on pcm plugins for more information.

Resources