3

I'm using an Up squared computer. I connect a device via the i2c port in the HAT connector. When using i2cdetect I detect the same device (identified by the address) on different ports. Changes occur between reboots.

To my understanding, I may be able to resolve this by setting a rule in etc/udev/rules.d, but I'm not sure how to do this. Specifically, I'm not sure how to filter the sensor to create the rule. The kernel I see is i2c-2, but I wonder if this will change on the next reboot.

LAR marine
  • 31
  • 1

2 Answers2

2

I have encountered the same problem with you when I work with seeed ODYSSEY board. I worked it out by add a rule file 71-i2c.rules to /etc/udev/rules.d/

The detail code of 71-i2c.rules

SUBSYSTEM=="i2c-dev", KERNELS=="i2c_designware.1", SYMLINK+="i2c-10"

I use this code to create a symlink to the specific i2c I want. And I can alway get the correct data by operate on /dev/i2c-10.

How to get the specific data of the i2c bus you want? You can get it by this command:

udevadm info -a /dev/i2c-1

In the output of this command, you need to find the specific data that only the i2c bus you want having.

BBear
  • 36
  • 2
1

As far as I know, the i2c number is assigned dynamically so it could change. As a result, I don't think you can use it statically.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Rasoul
  • 11
  • 1