Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect and clear I2C freeze #3664

Closed
TD-er opened this issue Jun 1, 2021 · 11 comments
Closed

Detect and clear I2C freeze #3664

TD-er opened this issue Jun 1, 2021 · 11 comments
Labels
Category: Stabiliy Things that work, but not as long as desired Type: Bug Considered a bug

Comments

@TD-er
Copy link
Member

TD-er commented Jun 1, 2021

It has been reported indirectly on the forum and in some GitHub issues a few times, but I've seen it happen too now on my own boards.

What happens:

  • Communication to any I2C device is no longer possible
  • I2C scan results in errors on all I2C addresses
  • Change pin settings for I2C and change it back (or power cycle) makes I2C available again.

This also happens every now and then on OLED display, which is the only one connected.
This plugin used to be one of the most tested and stable ones for years, so I guess something has changed in the core, or we may trigger some corner case now that we allow to switch frequencies or maybe load a lot more from flash instead of RAM.

It has been suggested on a number of forum posts on other forums that the clock pin or data pin may remain pulled down for unknown reasons.
One of the reported fixes seems to be to toggle the pins for some time and re-set their pull-up resistors, as described here

@TD-er TD-er added Category: Stabiliy Things that work, but not as long as desired Type: Bug Considered a bug labels Jun 1, 2021
@rka-germany
Copy link

Hello, I also often have stuck when displaying the OLED SSD1306 / SH1106 Framed.
I am using the status from 8/8/2020: (ESP_Easy_mega_20200608_dev_ESP8266_4M1M.bin), there are no stuck here yet, the error must have crept in later.
Best regards, Rainer

@TD-er
Copy link
Member Author

TD-er commented Jun 11, 2021

Ah a candidate for testing....
Can you test this PR? #3678

What seems to be happening is that one I2C device still "thinks" it is in the process of sending data.
So it is keeping either the SDA or SCL pin low.
A lot of reports I found online mention this may happen when a microcontroller crashes in the middle of communicating.
But I have seen it happen (hard to reproduce) on my breadboard without it crashing.

Around the time you mention some changes have been made to the core libraries regarding I2C.
I got the impression the older implementation was running at a lower I2C clock even when it was set to 400 kHz.
I did test the clock frequency of the current implementation and it is very close to the set frequency. (max. 400 kHz, even if you set it higher).

Can you also test running at 100 kHz clock to see if it is then more stable.

@marstum
Copy link

marstum commented Jun 22, 2021

Hello, I also often have stuck when displaying the OLED SSD1306 / SH1106 Framed.
I am using the status from 8/8/2020: (ESP_Easy_mega_20200608_dev_ESP8266_4M1M.bin), there are no stuck here yet, the error must have crept in later.
Best regards, Rainer

I am using the same OLED and had only this issue with the one which has difficulties in connecting to WIFI.
All ESPs running on ESP_Easy_mega_20210615_normal_ESP8266_4M1M.

KR marstum

@TD-er
Copy link
Member Author

TD-er commented Jun 22, 2021

Does that unit also crash, or is difficulties with WiFi only resulting in slow responses on the web UI and/or staying connected to WiFi?

@marstum
Copy link

marstum commented Jun 22, 2021

Does that unit also crash, or is difficulties with WiFi only resulting in slow responses on the web UI and/or staying connected to WiFi?

As usual, it depends, and I don't know on what.
Sometimes it crashes completely, and sometimes the other ESP can see this one, but it can't be connected via web UI.

@TD-er
Copy link
Member Author

TD-er commented Jun 22, 2021

The reason I ask is because I have the feeling this stuck I2C may happen due to crashes in the middle of an I2C transfer.

@marstum
Copy link

marstum commented Jun 22, 2021

The reason I ask is because I have the feeling this stuck I2C may happen due to crashes in the middle of an I2C transfer.

I am happy to help, so what do I need to do, in case the OLED is freezing next time, and I would have access to the ESP? I2C scan, or what else?

@TD-er
Copy link
Member Author

TD-er commented Jun 22, 2021

I2C scan is a good first attempt to see if the I2C bus is stuck.
A simple way to get it to work again is to swap the pin configuration in the settings for I2C, so swap SCL and SDA pins and save.
Then swap them back and save and I2C should be working again.

@marstum
Copy link

marstum commented Jun 22, 2021

Ok, I let you know, if this was working.

@marstum
Copy link

marstum commented Jun 23, 2021

The I2C scan doesn't show anything different to yesterday, during the OLED was working as expected, but you are absolutely correct the swap solved the freeze.

@tonhuisman
Copy link
Contributor

This seems to be solved, and since then, fixing I2C connection trouble has been added to the code, so this can be closed.

@TD-er TD-er closed this as completed Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Stabiliy Things that work, but not as long as desired Type: Bug Considered a bug
Projects
None yet
Development

No branches or pull requests

4 participants