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

[TW#15976] When I2C hangs restarting ESP doesn't usually help #1133

Closed
chanibal opened this issue Oct 18, 2017 · 8 comments
Closed

[TW#15976] When I2C hangs restarting ESP doesn't usually help #1133

chanibal opened this issue Oct 18, 2017 · 8 comments

Comments

@chanibal
Copy link
Contributor

chanibal commented Oct 18, 2017

Some background: I'm integrating a SSD1306 128x64 OLED driver and I2C seems to be randomly failing on i2c_master_cmd_begin with error 263 (ESP_ERR_TIMEOUT). This seems to be related to #680.

The real issue is this is not fixable by a restart of the ESP - the error persists. I have tried four ways of restarting the ESP with different results:

  1. using esp_restart() - does not help, error remains after restart
  2. hanging the ESP32 on a critical section and waiting for the watchdog to restart - does not help, error remains after restart
  3. using idf_monitor's reset functionality (ctrl+R) - usually helps
  4. going to deep sleep and waking up with a gpio attached button - usually helps, but the I2C seems to hang again quicker than with method 3

A bit more about the I2C hang: it happens randomly while updating the screen, can be easily triggered by restart method 2 mentioned above (hang in a critical section, be restarted by watchdog).
image
image
Reconnecting the I2C peripherial doesn't help.

IDF version v3.0-dev-396-g6d2a597
WROOM32 ESP32D0WDQ6 (revision 0)

@me-no-dev
Copy link
Member

We have this to coop with that issue in Arduino. I did get reports that it does not help 100% of the time though...

@FayeY
Copy link
Collaborator

FayeY commented Oct 20, 2017

Hi @chanibal , did the above suggestion help you resolve the issue?

@chanibal
Copy link
Contributor Author

@FayeY , sorry, couldn't get around to fixing this. Just updated IDF to newest and still crunching out other issues. Will try this workaround ASAP.

@FayeY FayeY changed the title When I2C hangs restarting ESP doesn't usually help [TW#15976] When I2C hangs restarting ESP doesn't usually help Oct 23, 2017
@chanibal
Copy link
Contributor Author

Temporarily reverted to IDF version from top comment because of the issues in newer one (still haven't lost hope, just will return to upgrade at a later time).

Using the workaround @me-no-dev mentioned doesn't help by itself, but in combination with power cycling (disconnecting VCC) of the I2C OLED it works. Double checked that without disabling/enabling the peripherial, power cycling is useless.

And for completeness, a few other things I tried, without success:

  • Just upgrading to WROVER32 ESP32D0WDQ6 (revision 1) did not seem to have an effect.
  • Also tried i2c_reset_tx_fifo and i2c_reset_rx_fifo, but they do not seem to have any effect on the issue.

Still, resetting the ESP from external programmer does reset I2C properly without power cycling the OLED and the same OLED itself worked well for a long time on a arduino nano - so I don't think this is the OLED's fault.

Will not repeat tests on WROOM32, but I'll try to update the IDF and run them again.

@negativekelvin
Copy link
Contributor

01befe4

@chanibal
Copy link
Contributor Author

@negativekelvin will try patch as soon as I get newest IDF working.

In an question unrelated to this issue, if I make a pull request to esp-idf, should I create an issue describing it separately or is the pull request itself sufficient?

@chanibal
Copy link
Contributor Author

Tried with esp-idf v3.0-dev-944-gba971a3 and it works with power cycling.
Tried with esp-idf v3.0-dev-1028-g2c95a77 (that contains 01befe4) and it seems to work without power cycling - but will leave for the night to be sure.

@chanibal
Copy link
Contributor Author

Left it for the night, it still works in the morning with some timeout errors, but nothing breaking.

Added some stats on how frequently the timeout error occurs:

count:          64
mean:          686 sec. = 0.1906 hour
Q1:            164 sec. = 0.0455 hour
median:        420 sec. = 0.1167 hour
Q3:            921 sec. = 0.2558 hour

The display was updating all the time with around 70% bandwidth being used:
image

With this fixed, this issue probably doesn't make sense anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants