我无法从 Linux 写入 24fc512 i2c 内存芯片

问题描述 投票:0回答:1

几天来,我一直在努力从 Linux 向 24fc512 i2c 芯片的内存中写入一些数据。我尝试了 Raspberry Pi 4 和 Beaglebone Black。 该 IC 在 SCL 和 SDA 上有 4.7 KOhm 上拉电阻。 它在总线上被检测到,地址为 0x50(0x52 是一个类似的芯片,具有相同的行为;而且 0x54 和 0x56 应该是相同类型的芯片,但我猜这些地址是由 Beaglebone Black 上的其他一些设备获取的,但它们显示在 RPi4 上):

ebian@BeagleBone:~$ i2cdetect -y 2
Warning: Can't use SMBus Quick Write command, will skip some addresses
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                                                 
10:                                                 
20:                                                 
30: -- -- -- -- -- -- -- --                         
40:                                                 
50: 50 -- 52 -- UU -- UU -- -- -- -- -- -- -- -- -- 
60:                                                 
70:

...以及 Python 的尝试:

>>> from smbus2 import SMBus
>>> bus = SMBus(2)
>>> bus.read_byte_data(0x50,0) # read one byte of data from address 0
2 # I wrote this to the chip using an Arduino
>>> bus.read_byte_data(0x50,1) # read one byte of date from address 1
255
>>> bus.write_byte_data(0x50, 1, 0) # write one byte of data from address 1
>>> bus.read_byte_data(0x50,1) 
255
>>> # nothing happened ... the same is valid for read/write_block_data()
>>> bus.close()
>>> 

我做错了什么?

谢谢你,

embedded-linux i2c beagleboneblack raspberry-pi4
1个回答
0
投票

调试如下:

  1. 检查WP引脚状态 24fc512有一个写保护引脚,写之前请确保WP引脚为高电平

  2. 检查驱动程序支持 检查你的linux defconfig文件,在Device Drivers--> Misc devices-->EEProm support-->I2C EEPROM中选择24fc512驱动程序 将 eeprom 设备添加到 dts 中的 I2C 控制器节点,如下所示:

    &i2c3 { 时钟频率 = <400000>; pinctrl-名称=“默认”; pinctrl-0 = <&pinctrl_i2c3>; 状态=“好的”;

    at24@50 {
        compatible = "atmel,24c512";
        pagesize = <64>;
        reg = <0x50>;
    };
    

    };

  3. 测试eeprom 24fc512将创建为/dev/eeprom,您可以使用open/read/write来读写eeprom,也支持cat/echo,例如: 猫/dev/eeprom dd if=xxx of=dev/eeprom bs=512

© www.soinside.com 2019 - 2024. All rights reserved.