1

I am using an embedded device that is running ubuntu.

Normally only root has read and write permissions for i2c devices.

I'm using this command to add i2c r/w permissions for normal user (me):

sudo chmod 777 /dev/i2c-*

But I want to create a udev rule. I created a file in /etc/udev/rules.d/ called 60-i2c-tools.rules and put the following line in it.

KERNEL==”i2c-[0-9]*”, MODE=”0660”

However, when I reboot the device, I don't have access to the I2C device. These are the permissions:

crwxrwxrwx 1 root root 89,  0 Aug 10 12:59 /dev/i2c-0
crwxrwxrwx 1 root root 89,  1 Aug 10 12:59 /dev/i2c-1
crw------- 1 root root 89, 10 Aug 10 12:59 /dev/i2c-10
crw------- 1 root root 89, 11 Aug 10 12:59 /dev/i2c-11
crwxrwxrwx 1 root root 89,  2 Aug 10 12:59 /dev/i2c-2
crwxrwxrwx 1 root root 89,  3 Aug 10 12:59 /dev/i2c-3
crw------- 1 root root 89,  4 Aug 10 12:59 /dev/i2c-4
crw------- 1 root root 89,  5 Aug 10 12:59 /dev/i2c-5
crw------- 1 root root 89,  6 Aug 10 12:59 /dev/i2c-6
crw------- 1 root root 89,  7 Aug 10 12:59 /dev/i2c-7
crw------- 1 root root 89,  8 Aug 10 12:59 /dev/i2c-8
crw------- 1 root root 89,  9 Aug 10 12:59 /dev/i2c-9

I need to run sudo chmod 777 /dev/i2c-* and the permissions change to:

crwxrwxrwx 1 root root 89,  0 Aug 10 12:59 /dev/i2c-0
crwxrwxrwx 1 root root 89,  1 Aug 10 12:59 /dev/i2c-1
crwxrwxrwx 1 root root 89, 10 Aug 10 12:59 /dev/i2c-10
crwxrwxrwx 1 root root 89, 11 Aug 10 12:59 /dev/i2c-11
crwxrwxrwx 1 root root 89,  2 Aug 10 12:59 /dev/i2c-2
crwxrwxrwx 1 root root 89,  3 Aug 10 12:59 /dev/i2c-3
crwxrwxrwx 1 root root 89,  4 Aug 10 12:59 /dev/i2c-4
crwxrwxrwx 1 root root 89,  5 Aug 10 12:59 /dev/i2c-5
crwxrwxrwx 1 root root 89,  6 Aug 10 12:59 /dev/i2c-6
crwxrwxrwx 1 root root 89,  7 Aug 10 12:59 /dev/i2c-7
crwxrwxrwx 1 root root 89,  8 Aug 10 12:59 /dev/i2c-8
crwxrwxrwx 1 root root 89,  9 Aug 10 12:59 /dev/i2c-9
  • 3
    Does your rule really use non-ASCII quotes? if so, that would be the first thing to fix. Beyond that, it's probably better practice to create a user-group for the device and assign that using a udev rule (in a similar way to the dialout group for serial devices) – steeldriver Aug 10 '17 at 17:24
  • 1
    1) If the device is created on boot, the udev rules must be in the initramfs part of the image. Changing them on the harddisk is not enough. 2) Verify with udevadm, modprobe etc. that the rule works as intended. – dirkt Aug 10 '17 at 17:25
  • Why do you want to change permissions of device files? This is crazy, please do not change the permission's of device files. This can cause major damage. Edited to make this point. This was my main point. – Hunter.S.Thompson Aug 10 '17 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.