0

I have an EEPROM chip which is connected to the PC through I2C interface. The question is following: "What should be done to have a possibility to write into the EEPROM chip files and directories as it is regularly done while using any hard drive".

As I understand, block device driver should be written. After that device file may be mounted.

Please correct me if I'm wrong or give the detailed information if no.

1 Answers1

0

There are already device drivers available in the Linux kernel that allow you to read/write from/to an EEPROM. The available drivers are located in drivers/misc/eeprom.

What you need to access them is typically a device tree node with the corresponding I2C address that is then registered with the corresponding EEPROM driver. The documentation for the eeprom device tree bindings can be found in Documentation/devicetree/bindings/eeprom/eeprom.txt eeprom.txt.

Longfield
  • 1,505
  • 1
  • 12
  • 24
  • thank you for answer, but I'm in doubt if it is complete one. So, I need to clarify. Do you mean, that after creating device tree file for i2c eeprom driver (which should be previously compiled and "insmoded") we can have device file (for example, /dev/eeprom_drive) which may be used as drive device file (for example, by command "mkdosfs -F 16 /dev/eeprom_drive")? Please correct me if I'm wrong! – Victor Signaevskyi Nov 04 '16 at 13:05
  • Yes that's exactly what I mean. If you take the example from the device tree documentation that I have linked in my answer, since the I2C address of the eeprom would be 0x52, you would have this file: `/sys/bus/i2c/devices/0-0052/eeprom`. I assumed that you were working in embedded Linux and that you already had a device tree for your board. – Longfield Nov 04 '16 at 13:19
  • I've compiled & "insmoded" "eeprom.ko" module. As a result, file "/sys/bus/i2c/devices/0-0056/eeprom" was created. When I checked command "i2c-detect 0" I have found that 56th i2c device was registered on bus ("UU"). Using i2cdump utility i2c eeprom memory now may be easily read. But again I have a question. Why do I need to use mentioned device tree node? Will it give me an opportunity to mount i2c eeprom chip? I'm not sure... – Victor Signaevskyi Nov 07 '16 at 08:43
  • If to say more shortly, your advises lead to the creation of the character device. It cannot be mounted and used as filesystem. – Victor Signaevskyi Nov 07 '16 at 08:48
  • No, the device tree will not help with the filesystem. Actually you don't need the device tree since the kernel was able to register the driver with the EEPROM. Now you can access the EEPROM with the char device. Do you really need filesystem for your EEPROM ? I don't think so, but there is already a [similar question about this](http://stackoverflow.com/questions/24744662/is-it-worth-to-implement-small-filesystem-for-an-eeprom) – Longfield Nov 07 '16 at 13:26
  • Thank you for your answer! Yes, I do need filesystem for EEPROM SoC, because a lot of libraries already uses standard file operations API. It will be the best solution. Shared link contains only different opinion about idea to use, or not to use filesystem on EEPROM. It is pity, but it doesn't contains any concrete information concerning Linux. – Victor Signaevskyi Nov 07 '16 at 15:26