Linux: 从用户实例化-space : eeprom new_device
Linux: Instantiate from user-space : eeprom new_device
环境:x86/Ubuntu14.04
我想获得类似于
的东西
&i2c0 {
eeprom: eeprom@50 {
compatible = "at,24c32";
reg = <0x50>;
};
};
但因为在 x86 中没有可用的设备树,我在 Linux 内核中遵循 i2c/instantiating-device
文档并使用 "Method 4: Instantiate from user-space".
实例化进程:
- 加载 at24 驱动程序
- 加载 i2c-dev 驱动程序
实例化:
# echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-0/new_device
内核在 dmesg 中的响应:
i2c i2c-0: new_device: Instantiated device eeprom at 0x50
创建目录“0-0050”。在 /sys/bus/i2c/devices/i2c-0/0-0050
中找到
- 此目录包含多个文件,但其中没有名为 "eeprom" 的文件。
为什么没有创建 "eeprom" 个文件?
P.S:
目录包含:
root@peio-t52r:~/etxoh# ls -la /sys/bus/i2c/devices/i2c-0/0-0050
total 0
drwxr-xr-x 3 root root 0 sep 25 15:06 .
drwxr-xr-x 5 root root 0 sep 25 14:48 ..
-r--r--r-- 1 root root 4096 sep 25 15:06 modalias
-r--r--r-- 1 root root 4096 sep 25 15:06 name
drwxr-xr-x 2 root root 0 sep 25 15:06 power
lrwxrwxrwx 1 root root 0 sep 25 15:06 subsystem -> ../../../../../bus/i2c
-rw-r--r-- 1 root root 4096 sep 25 15:06 uevent
文件 "name" 包含:
root@peio-t52r:~/etxoh# cat /sys/bus/i2c/devices/i2c-0/0-0050/name
eeprom
实例化 I2C 设备时使用“24c32”而不是 "eeprom"。
# echo 24c32 0x50 > /sys/bus/i2c/devices/i2c-0/new_device
在我的带有 AT24C02 SPD EEPROM 的开发板中,在总线 2 上实例化 AT24C02
# echo 24c02 0x50 > /sys/class/i2c-adapter/i2c-2/new_device
内核消息显示
[21230.868376] at24 2-0050: 256 byte 24c02 EEPROM, writable, 1 bytes/write
[21230.868423] i2c i2c-2: new_device: Instantiated device 24c02 at 0x50
目录包含
root@:/sys/bus/i2c/devices/i2c-2/2-0050# ls
2-00500/ driver@ eeprom modalias name power/ subsystem@ uevent
eeprom文件是
root@:/sys/bus/i2c/devices/i2c-2/2-0052# hexdump -C eeprom
00000000 23 11 0c 03 45 21 00 08 00 60 00 03 02 03 00 00 |#...E!...`......|
00000010 00 00 07 0d f8 0f 00 00 6e 6e 6e 11 00 6e f0 0a |........nnn..n..|
00000020 20 08 00 05 00 f0 2b 34 28 00 78 00 14 3c 00 00 | .....+4(.x..<..|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 16 36 0b 35 |.............6.5|
00000040 16 36 0b 35 00 00 16 36 0b 35 16 36 0b 35 00 00 |.6.5...6.5.6.5..|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000070 00 00 00 00 00 00 9c b5 00 00 00 00 e7 d6 0b e3 |................|
00000080 0f 11 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 db 08 |................|
00000100
环境:x86/Ubuntu14.04
我想获得类似于
的东西&i2c0 {
eeprom: eeprom@50 {
compatible = "at,24c32";
reg = <0x50>;
};
};
但因为在 x86 中没有可用的设备树,我在 Linux 内核中遵循 i2c/instantiating-device
文档并使用 "Method 4: Instantiate from user-space".
实例化进程:
- 加载 at24 驱动程序
- 加载 i2c-dev 驱动程序
实例化:
# echo eeprom 0x50 > /sys/bus/i2c/devices/i2c-0/new_device
内核在 dmesg 中的响应:
i2c i2c-0: new_device: Instantiated device eeprom at 0x50
创建目录“0-0050”。在
/sys/bus/i2c/devices/i2c-0/0-0050
中找到
- 此目录包含多个文件,但其中没有名为 "eeprom" 的文件。
为什么没有创建 "eeprom" 个文件?
P.S:
目录包含:
root@peio-t52r:~/etxoh# ls -la /sys/bus/i2c/devices/i2c-0/0-0050
total 0
drwxr-xr-x 3 root root 0 sep 25 15:06 .
drwxr-xr-x 5 root root 0 sep 25 14:48 ..
-r--r--r-- 1 root root 4096 sep 25 15:06 modalias
-r--r--r-- 1 root root 4096 sep 25 15:06 name
drwxr-xr-x 2 root root 0 sep 25 15:06 power
lrwxrwxrwx 1 root root 0 sep 25 15:06 subsystem -> ../../../../../bus/i2c
-rw-r--r-- 1 root root 4096 sep 25 15:06 uevent
文件 "name" 包含:
root@peio-t52r:~/etxoh# cat /sys/bus/i2c/devices/i2c-0/0-0050/name
eeprom
实例化 I2C 设备时使用“24c32”而不是 "eeprom"。
# echo 24c32 0x50 > /sys/bus/i2c/devices/i2c-0/new_device
在我的带有 AT24C02 SPD EEPROM 的开发板中,在总线 2 上实例化 AT24C02
# echo 24c02 0x50 > /sys/class/i2c-adapter/i2c-2/new_device
内核消息显示
[21230.868376] at24 2-0050: 256 byte 24c02 EEPROM, writable, 1 bytes/write
[21230.868423] i2c i2c-2: new_device: Instantiated device 24c02 at 0x50
目录包含
root@:/sys/bus/i2c/devices/i2c-2/2-0050# ls
2-00500/ driver@ eeprom modalias name power/ subsystem@ uevent
eeprom文件是
root@:/sys/bus/i2c/devices/i2c-2/2-0052# hexdump -C eeprom
00000000 23 11 0c 03 45 21 00 08 00 60 00 03 02 03 00 00 |#...E!...`......|
00000010 00 00 07 0d f8 0f 00 00 6e 6e 6e 11 00 6e f0 0a |........nnn..n..|
00000020 20 08 00 05 00 f0 2b 34 28 00 78 00 14 3c 00 00 | .....+4(.x..<..|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 16 36 0b 35 |.............6.5|
00000040 16 36 0b 35 00 00 16 36 0b 35 16 36 0b 35 00 00 |.6.5...6.5.6.5..|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000070 00 00 00 00 00 00 9c b5 00 00 00 00 e7 d6 0b e3 |................|
00000080 0f 11 02 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 db 08 |................|
00000100