I2C bus stuck/hangs

Hello,

I am facing I2C bus stuck/hanging issue on Rock Pi S i2c1. The rock pi is master and is communicating with a microcontroller slave. Whenever there is some interruption in i2c communication such as MCU restart, the i2c bus hangs and does not resolve until reboot.

Although the microcontroller is handling i2c bus issues and resets its i2c peripheral in such conditions.

I am using Debian Buster latest image from Radxa Downloads. One thing I should add is that this problem never occurs on Armbian.

dmesg output when this problem happens:

[ 532.655488] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 533.666998] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 533.680332] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 534.690960] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 534.705165] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 535.719102] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 535.733401] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 536.747064] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 536.760990] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 537.775020] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 537.788316] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 538.803066] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 538.817181] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 539.835024] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 539.848923] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 540.866968] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 540.880194] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 541.891005] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 541.891770] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 542.890890] rk3x-i2c ff050000.i2c: timeout, ipd: 0x80, state: 1
[ 543.890947] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 543.891700] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 544.891022] rk3x-i2c ff050000.i2c: timeout, ipd: 0x80, state: 1
[ 545.890920] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 545.891686] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 546.890953] rk3x-i2c ff050000.i2c: timeout, ipd: 0x80, state: 1
[ 547.890940] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 547.891764] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 548.895070] rk3x-i2c ff050000.i2c: timeout, ipd: 0x80, state: 1
[ 549.894856] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 549.895536] rk3x-i2c ff050000.i2c: unexpected irq in STOP: 0x90
[ 550.894953] rk3x-i2c ff050000.i2c: timeout, ipd: 0x80, state: 4
[ 551.894936] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 551.895714] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0
[ 552.907072] rk3x-i2c ff050000.i2c: timeout, ipd: 0x80, state: 1
[ 553.918868] rk3x-i2c ff050000.i2c: timeout, ipd: 0x81, state: 3
[ 553.932057] rk3x-i2c ff050000.i2c: irq in STATE_IDLE, ipd = 0xb0

Hi,

I have the same problem too. I installed an RTC on I2C-0 and everything works perfectly.

I moved RTC to I2C-1, on this bus I get the same error.

The I2C bus stalls and no longer works.

[   46.366621] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   47.366603] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   48.366629] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   49.366596] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   50.366595] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   51.366763] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   52.366629] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   53.366688] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   54.366605] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1
[   55.366608] rk3x-i2c ff050000.i2c: timeout, ipd: 0x00, state: 1

Tested with last image available for Rock PI S, activating the appropriate overlay.

Any help to solve?

I did some tests with I2C3 and this channel works.

I have Rock PI S Hardware V12 that have:

I2C: x3, I2C0/I2C1/I2C3

I2C0 - working
I2C1 - NOT working
I2C3 - working

If I want to maintain compatibility with the Raspberry PI Pinout, I would like to use the I2C1 bus.

How can I get the I2C1 bus to work ?

Thanks very much.

debugasm

I have found my problem with I2C-1 bus.

The 1-wire bus configuration was causing problems for the I2C-1 bus.

After activating 1-wire with overlay on file “uEnv.txt”:

overlays=rk3308-uart0 rk3308-w1-gpio rk3308-i2c1
param_w1_pin=GPIO0_C1

On boot, an incorrect configuration is applied from the script “rockchip-fixup.scr”:

Applying kernel provided DT fixup script (rockchip-fixup.scr)
## Executing script at 05000000
tmp_pinctrl=0
tmp_bank=C
tmp_pin=1
GPIO0_C1 ---> pinctrl = 0
GPIO0_C1 ---> bank = 10
GPIO0_C1 ---> pin = 11
GPIO0_C1 ---> tmp_pinctrl = /pinctrl/gpio0@ff220000
GPIO0_C1 ---> tmp_phandle = 0x00000075

This configuration modifies the pin “gpio-11” instead of the pin “gpio-17”.

The pin “gpio-11” is I2C1 SDA.

I removed the pin configuration “param_w1_pin = GPIO0_C1” from the “uEnv.txt” file, leaving only the overlay:

overlays=rk3308-uart0 rk3308-w1-gpio rk3308-i2c1

Now I2C1 works perfectly too.

debugasm

Hi,
I have a similar issue:

rk3x-i2c ff070000.i2c: timeout, ipd: 0x00, state: 1

I2C-1 is always working, on board pullups 1.2K
I2C-3 is working after power-up, no pullups ( external 2K pullups )

After starting a Qt5 app, I2C3 stops working and shows timeout error.
This is not recoverable.

An other apps like fbtest does not show this problem. Qt5 apps does.
I assume that this may have something to do for probing a touch panel somewhere in the libs or drivers Qt5 is calling.
On Raspberry the PIN 11 ( SDA ) is use as pen-interrupt. Mybe there are something to do with that.

Maybe someone knows how to reset I2C to clear this timeout situation ?