There are two common I2C errors: I2C ACK error, I2C timeout 1. I2C ACK errorIf the ACK signal is not received when it should be, the i2c controller will generate an ACK error interrupt to tell the i2c driver that an ACK error has occurred. Usually, this is a problem with the slave itself. 1. Check whether the device exists and whether the i2c bus number and device address are correct. The example is as follows: i2c number is 6, addr is 0x28: [ 31.092951 ][ xxx ] i2c i2c-6 : addr : 0x28 , ACK error 2. Check whether the device has been powered on and enabled, and whether it has been inited correctly. 3. Check if the i2c speed is compatible. If the speed is greater than the max speed supported by the device, it will also cause ACK Error. Reduce the speed. If it still works, it means it is a clk-related problem. 4. Check whether the i2c device signal level matches that of the AP. 5. GPIO check The following parts:
According to the i2c spec, NACK is normal in the following situations. I2C WriteWhen the host sends data to the slave, the slave may or may not respond to the last byte of data, but the host can generate a stop condition in either case. If the host detects that the slave does not respond when sending data to the slave (even including the slave address), the transmission will be stopped in time. I2C ReadWhen the host receives data from the slave, the host does not respond to the slave at the last byte of data, that is, NACK. 2. I2C timeoutWhen an I2C transmission times out, the kernel log will generally print something like this: [48.197718][xxx]i2c i2c-1: addr:0xa,transfer timeout 1. GPIO check the following parts.
2. Check the slave order.
After reproducing the problem, you can manually remove the corresponding peripherals to confirm which peripheral is holding the i2c bus. Then communicate with the supplier, debug the status of the IC, and figure out the reason why the i2c bus is being held. 3. i2c-toolsi2c-tools is also very useful. I wrote about this tool last time. Please refer to the following article: Teach you how to use i2c-tools step by step. 4. Frequently Asked Questions1. The i2c addr of all peripherals on the same i2c bus must be different(1) Conflict when registering the same address. [ 2.059184 ][ xxx ] i2c i2c-1 : Failed to register i2c client 24c02 at 0x51 ( -16 ) The corresponding error code is -16. /kernel-5.10/include/uapi/asm-generic/errno-base.h You can execute ls /sys/bus/i2c/devices to check whether there is a peripheral with the same address registered under the corresponding i2c-1. If -11, -EAGAIN is returned, it means the bus is busy or the bus lock cannot be obtained. If the bus is busy, please retry and wait, or check which device is sending all the time. If the bus lock cannot be obtained, please check whether i2c_transfer is called in an interrupt function or atomic context. (2) Hidden i2c address, that is, the peripheral has multiple i2c addrs or the peripheral HW bug, resulting in i2c communication abnormalities. Example: EEPROM registers address 0x50 on i2c-1, and although Type C registers address 0x60, it can also respond to 0x50. Type C pulls SDA low, resulting in a timeout. debug method:
2. There are glitches on the ACK of the oscilloscopeAfter the slave generates an ACK response at the 9th clk, the glitch is generated when the master end is switched to control. This glitch will not affect the read and write timing of the I2C bus and does not need to be processed. That is, the slave and master control bus switching interval, no one controls the bus, resulting in glitches. 3. Half high levelIn the case of an external pull-up resistor, there is an enable internal pull-down resistor, resulting in a half-high level on the bus. 4. The level on the bus cannot be pulled to ground
5. RK platform I2C debugDerived from firefly. https://wiki.t-firefly.com/zh_CN/Firefly-RK3399/driver_i2c.html I2C communication failed, log: "timeout, ipd: 0x00, state: 1" appears Please check whether the hardware pull-up is powered. Calling i2c_transfer returns a value of -6? A return value of -6 indicates a NACK error, which means that the other device does not respond. This is usually a problem with the peripheral device. The following are common situations:
What should be done when the peripheral device requires a stop signal instead of a repeat start signal in the middle of the read timing? At this time, you need to call i2c_transfer twice, and split I2C read into two times. Modify as follows: static int i2c_read_bytes ( struct i2c_client * client , u8 cmd , u8 * data , u8 data_len ) { struct i2c_msg msgs [ 2 ]; I believe the above I2C debug method can solve most of the problems for you. If it still doesn’t solve the problem, it is usually a chip problem or a bug in the original factory’s underlying code. You can seek support from the chip manufacturer. |
<<: Cisco Launches AppDynamics Cloud to Build Superior Digital Experiences
>>: Thinking about the Boundary Expansion of Web Front-end in the 5G Era
During the COVID-19 pandemic, industries across t...
ZJI was founded in 2011 as Weixiang Host, a well-...
edgeNAT has launched a promotional event for the ...
Power over Ethernet (PoE) has revolutionized the ...
According to CCTV reports, the 46th "Statist...
The process of transferring data remotely involve...
RAKsmart has launched a new month of promotions, ...
With the development of the Internet and the incr...
1. As for the reason why 5G was over-promoted bef...
Amid the global digitalization, the IT industry i...
CloudCone also released a special package for Chi...
At present, edge computing has been widely recogn...
The 2017 Internet Security Conference with the th...
If 5GToC helped operators achieve a return to bas...
The hottest news during the New Year's Day wa...