How to read i2c eeprom Atmel AT24C128B with RPi
Posted: Sun Mar 10, 2013 12:47 am
Hello. I am trying to read atmel eeprom AT24C128B chip using RPi and i2c interface (two-wire interface)
I see chip at 0x50 address as /dev/i2c-1 :
root@raspberrypi:/home/pi# i2cdetect -y -a 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
root@raspberrypi:/home/pi#
Then I tried to compile and run code from
http://www.lm-sensors.org/browser/i2c-t ... r/eeprom.c
with various combinations of parameters:
But when I run binary file I can read only 256 bytes of eeprom chip
And I can never read more then 256 bytes, although eeprom chip is 128K.
Maybe sources are not for such "big" memory chips and need to be rewritten...
If someone already faced such a quest I will appreciate any help and hints!
I see chip at 0x50 address as /dev/i2c-1 :
root@raspberrypi:/home/pi# i2cdetect -y -a 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
root@raspberrypi:/home/pi#
Then I tried to compile and run code from
http://www.lm-sensors.org/browser/i2c-t ... r/eeprom.c
with various combinations of parameters:
Code: Select all
#define DEFAULT_I2C_BUS "/dev/i2c-1"
#define DEFAULT_EEPROM_ADDR 0x50 /* the 24C16 sits on i2c address 0x50 */
#define DEFAULT_NUM_PAGES 64 /* we default to a 24C16 eeprom which has 8 pages */
#define BYTES_PER_PAGE 256 /* one eeprom page is 256 byte */
#define MAX_BYTES 16
Code: Select all
root@raspberrypi:/home/pi# ./eeprom
base-address of eeproms : 0x50
number of pages to read : 64 (0x50 .. 0x8f)
i2c-devicenode is : /dev/i2c-1
on filedescriptor : 3
Positioned pointer in eeprom at 0x50 to offset 00000000
Read 16 bytes from eeprom at 0x50, offset 00000000
<omitted here>
Positioned pointer in eeprom at 0x50 to offset 000000f0
Read 16 bytes from eeprom at 0x50, offset 000000f0
ioctl(): Input/output error
ioctl returned -1
root@raspberrypi:/home/pi#
Maybe sources are not for such "big" memory chips and need to be rewritten...
If someone already faced such a quest I will appreciate any help and hints!