I2c device udev rule not firing

I am testing a simple udev rule to add symlink for an eeprom device.

  looking at device '/devices/3180000.i2c/i2c-2/i2c-10/10-0053':

The rule is like this:

SUBSYSTEM=="i2c", KERNEL=="10-0053", ACTION=="add", SYMLINK+="eeprom0"

When I run “udevadm test /sys/bus/i2c/devices/10-0053”, I see the rule was read, but no triggered.

Reading rules file: /etc/udev/rules.d/04-test.rules
Reading rules file: /etc/udev/rules.d/99-tegra-mmc-ra.rules
rules contain 98304 bytes tokens (8192 * 12 bytes), 18084 bytes strings
5505 strings (53743 bytes), 4549 de-duplicated (36616 bytes), 957 trie nodes used
IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:14
IMPORT builtin 'hwdb' returned non-zero
RUN 'kmod load $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5
run: 'kmod load i2c:24c02'
Unload module index
Unloaded link configuration context.

at24 driver is built in to the kernel, I can see the sysfs node:

$ls /sys/bus/i2c/devices/10-0053
10-00530  driver  eeprom  modalias  name  of_node  power  subsystem  uevent

I tested a couple of simple rules such as usb block device, iio device, the rules all got fired, but I just can’t get a simple i2c device to work. What did I miss here?
Thanks for the help.

you may see-also… I2C Device Permissions - ddcutil Documentation

Thanks for the reply, Jerry.
I checked out the link you provided, it has rules to change i2c bus group and permissions. I can achieve that too, using i2c-dev subsystem to match, however for i2c end devices, like an eeprom or other custom devices, I can’t make them to match using SUBSYSTEM==“i2c”.
I googled around, can’t find any sample rule using that, I am wondering how i2c is handled differently from other type of devices in udev?

How about using this?


I did test with “i2c-dev”, but it only works on i2c buses, not end devices.

My understanding is that udev is for busses and devices than support autoconfig: These are

  • PCIe
  • USB

All other busses and devices (SPI, I2C, CAN, …) don’t support auto-config. They get enumerated statically though the device tree. The device tree is a compiled list of processor peripherials, busses, and devices present in the system.

The bootloader loads

  • Kernel
  • Initial Ramdisk
  • Device Tree

Wenn the Linux Kernel starts it reads the device tree entry by entry and loads and configures each driver and device in this list. This is only done once during boot.

Your eeprom needs to be added to the device tree. udev is the wrong place.


Thanks for the reply. To clarify, I am putting all the i2c devices in the device tree. And they works fine. What I am trying to achieve here:

  1. give the i2c devices proper group and permission.
  2. give it a consistent path, the default sysfs path could change for different revisions of PCBs.
    I understand I could write a script to create symbolic link and change the permissions, but I thought udev maybe a better way to do this?