root@android:$ ls -l /dev/i2c-dev
crw------- root root 10, 54 2012-09-28 08:26 i2c-dev
以下是另外一个设备的/dev/目录,这个有i2c-0, i2c-1,主设备号为89,这才是我想要的,
/********************************************************************/
/ # ls -l /dev
crw------- root root 89, 1 2020-09-28 14:42 i2c-1
crw------- root root 89, 0 2020-09-28 14:42 i2c-0
/ # ls -l /sys/bus/i2c/devices/
lrwxrwxrwx root root 2012-09-28 10:42 0-0001 -> ../../../devices/i2c-0/0-0001
lrwxrwxrwx root root 2012-09-28 10:42 0-0021 -> ../../../devices/i2c-0/0-0021
lrwxrwxrwx root root 2012-09-28 10:42 1-0018 -> ../../../devices/i2c-1/1-0018
lrwxrwxrwx root root 2012-09-28 10:42 2-0034 -> ../../../devices/i2c-2/2-0034
lrwxrwxrwx root root 2012-09-28 10:42 i2c-0 -> ../../../devices/i2c-0
lrwxrwxrwx root root 2012-09-28 10:42 i2c-1 -> ../../../devices/i2c-1
lrwxrwxrwx root root 2012-09-28 10:42 i2c-2 -> ../../../devices/i2c-2
/********************************************************************/
但在我的设备上为什么没有呢?
查看bus总线:
root@android:$ ls -l /sys/bus/i2c
drwxr-xr-x root root 2012-09-28 10:23 devices
drwxr-xr-x root root 2012-09-28 10:23 drivers
-rw-r--r-- root root 4096 2012-09-28 10:23 drivers_autoprobe
--w------- root root 4096 2012-09-28 10:23 drivers_probe
--w------- root root 4096 2012-09-28 10:23 uevent
root@android:$ ls -l /sys/bus/i2c/devices
lrwxrwxrwx root root 2012-09-28 10:23 0-001a -> ../../../devices/platform/rk29_i2c.0/i2c-0/0-001a
lrwxrwxrwx root root 2012-09-28 10:23 0-001c -> ../../../devices/platform/rk29_i2c.0/i2c-0/0-001c
lrwxrwxrwx root root 2012-09-28 10:23 0-004c -> ../../../devices/platform/rk29_i2c.0/i2c-0/0-004c
lrwxrwxrwx root root 2012-09-28 10:23 1-0033 -> ../../../devices/platform/rk29_i2c.1/i2c-1/1-0033
lrwxrwxrwx root root 2012-09-28 10:23 2-0001 -> ../../../devices/platform/rk29_i2c.2/i2c-2/2-0001
lrwxrwxrwx root root 2012-09-28 10:23 2-0051 -> ../../../devices/platform/rk29_i2c.2/i2c-2/2-0051
lrwxrwxrwx root root 2012-09-28 10:23 i2c-0 -> ../../../devices/platform/rk29_i2c.0/i2c-0
lrwxrwxrwx root root 2012-09-28 10:23 i2c-1 -> ../../../devices/platform/rk29_i2c.1/i2c-1
lrwxrwxrwx root root 2012-09-28 10:23 i2c-2 -> ../../../devices/platform/rk29_i2c.2/i2c-2
lrwxrwxrwx root root 2012-09-28 10:23 i2c-3 -> ../../../devices/platform/rk29_i2c.3/i2c-3
从上面看出有i2c-0, i2c-1...为什么在/dev/目录下面就没有呢?怎样才能read/write这个i2c-0呢?
8 个解决方案
#1
mdev
#2
使用mknod命令手工创建设备文件,或者修改驱动源程序自动创建设备文件。
#3
楼上两位都正解
#4
谢谢大侠们的指点, 但现在这个板子是客户的,里面没有mdev和mknod命令,我现在做个应用程序,去读写i2c设备,在/dev目录下找不到设备,除了dev/目录下,还有其它办法去ioctl这个i2c设备吗?
#5
求大神们指点啊,小弟先谢谢各位了!
#6
在/sys/devices/目录下也没有吗?
#7
/sys/devices/下面没有 芯片是rk2906
#8
您好,我现在在写一个应用程序,也碰到这个问题,请问您最后是怎么解决的呢,还请不吝赐教
#1
mdev
#2
使用mknod命令手工创建设备文件,或者修改驱动源程序自动创建设备文件。
#3
楼上两位都正解
#4
谢谢大侠们的指点, 但现在这个板子是客户的,里面没有mdev和mknod命令,我现在做个应用程序,去读写i2c设备,在/dev目录下找不到设备,除了dev/目录下,还有其它办法去ioctl这个i2c设备吗?
#5
求大神们指点啊,小弟先谢谢各位了!
#6
在/sys/devices/目录下也没有吗?
#7
/sys/devices/下面没有 芯片是rk2906
#8
您好,我现在在写一个应用程序,也碰到这个问题,请问您最后是怎么解决的呢,还请不吝赐教