谢谢。
佩伊奥
P.D:我尝试将eeprom文件chmod到rwx,但无论如何我收到错误,试图写入eeprom:“bash:eeprom:Permission denied”。
看来eeprom Linux驱动只能实现drivers / misc / eeprom / eeprom.c读取sysfs属性:
https://github.com/torvalds/linux/blob/master/drivers/misc/eeprom/eeprom.c#L117
static const struct bin_attribute eeprom_attr = {
.attr = {
.name = "eeprom",
.mode = S_IRUGO,
},
.size = EEPROM_SIZE,
.read = eeprom_read,
};
一个问题是您使用的eeprom.c驱动程序不支持编写eeprom,因为它没有写入功能。
考虑在24.c使用驱动程序。它具有写入功能,例如at24_eeprom_write()
实际上,此驱动程序的probe()函数将决定该部分是否可写,然后在可写时根据需要设置函数调用。当器件为只读时,写功能不可用。它会自动处理这个问题。
以下是linux内核v3.3的at24.c驱动程序的代码,如下所示:https://elixir.bootlin.com/linux/v3.3/source/drivers/misc/eeprom/at24.c