[fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

tsiegel at softcon.com tsiegel at softcon.com
Sat Apr 1 22:08:58 CEST 2023

On unix (and all of it's derivatives, everything is a file, including 
connections to other systems.  You can treat it like a file, and in 
(most) circumstances, it will operate just as if it were a local file.

Some devices require special handling, but for the most part, if it's 
listed as a file on the system, you can read it as one.

Of course, permissions apply, so creating files or reading them may be 
limited by user/group permissions, so there's no guarantee that just 
because the file is there, you'll be able to read it.

On 4/1/2023 3:56 PM, Bo Berglund via fpc-pascal wrote:
> I need to read and write data to an EEPROM connected by I2C on a RaspberryPi4.
> The I2C channel is found in /dev as i2c-1:
> $ ll /dev/i2*
> crw-rw---- 1 root i2c 89, 1 2019-02-14 11:12 /dev/i2c-1
> In this channel the EEPROM CAT24C128 is at address 0x50
> The data on the device is organized as 256 pages of  64 bytes data each AFAIU.
> I can check the EEPROM using i2c-tools, which I have installed, but I am unsure
> if the read is correct...
> Question:
> Can I use Linux file system commands to read/write the data on the i2c EEPROM
> memory device and if so how from fpc?
> I have installed the current versions of Lazarus and Fpc on the RPi4 itself.

More information about the fpc-pascal mailing list