I2C bus_busy set on startup/reboot and no recovery option

longtimer
Posts: 9
Joined: Wed Sep 27, 2017 3:18 pm

I2C bus_busy set on startup/reboot and no recovery option

Postby longtimer » Wed Sep 27, 2017 3:39 pm

Hi,

I have been fighting with a repeatable problem in the I2C subsystem that happens on startup and reboot. In a number of cases, the system will start with the I2C hardware state machine in an indeterminate state manifesting itself with the bus_busy flag of the i2c_dev_t structure already set prior to any I2C messages having been sent. This prevents all subsequent use of the I2C until a manual reset is performed. Even a soft reboot of the chip is insufficient to set the I2C state machine to a known starting state.

I have tried different methods to restart/reset the state machine such as:
- reconfiguring the I2C to operate in slave mode and then back into master mode
- running through the I2C startup steps again
- trying to change bus_busy flag to 0 manually
- trying to clear interrupt flag bits
- clearing the command buffer
- setting the done flag of the failed command in command buffer.
- adding clock toggle on the SCL line

Is there any known sequence of steps to get the subsystem into a known state or to restart via code?

Without a software solution, we will be forced to abandon the use of the module in production. It is working well in other respects and that would be unfortunate.

Thanks,

Jason

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby ESP_Sprite » Thu Sep 28, 2017 1:44 am

Strange... can you see if a combination of periph_module_disable(PERIPH_I2C0_MODULE); periph_module_enable(PERIPH_I2C0_MODULE); gets the FSM working again?

longtimer
Posts: 9
Joined: Wed Sep 27, 2017 3:18 pm

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby longtimer » Thu Sep 28, 2017 7:22 pm

Thank you, that worked once I did these steps and reinitialized the I2C configuration. I did not see that specific information in the documentation or the forum search. It would be helpful to have it explicitly defined in the documentation here:

http://espressif.com/sites/default/file ... ual_en.pdf

Thanks,

Jason

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby ESP_Sprite » Fri Sep 29, 2017 1:49 am

Agreed. I'll see if I can get the dev who's looking at it to talk to the doc team to add this to the TRM and/or ECO.

novalight
Posts: 40
Joined: Tue Apr 19, 2016 1:13 pm

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby novalight » Fri Sep 29, 2017 10:10 am

When should these bugfix be applied, can you run it at every boot? Could it be integrated in idf or arduino-esp32 by default? How would a code snippet look like?

This problem was also hitting me a few times!

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby ESP_Sprite » Fri Sep 29, 2017 12:41 pm

There should be no issue running it on every boot; as far as I can see, you may loose the state of the i2c peripheral but on boot there's nothing useful inthere anyway. We're still looking into the source of the issue, so we'll probably have some workaround in the future in esp-idf, but I can't tell you what one and when it'll be finished.

novalight
Posts: 40
Joined: Tue Apr 19, 2016 1:13 pm

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby novalight » Fri Sep 29, 2017 1:20 pm

Good to hear! You can for post an update in this thread when a fix appears in idf/docs. I will add it now to my main.
Do I delay/NOP between the calls?

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby ESP_Sprite » Sat Sep 30, 2017 1:04 am

No need to, the reset should happen in a single clock cycle.

longtimer
Posts: 9
Joined: Wed Sep 27, 2017 3:18 pm

Re: I2C bus_busy set on startup/reboot and no recovery option

Postby longtimer » Sat Sep 30, 2017 6:53 am

A reset method is now available in the Arduino master for the Wire library. You can use it as a part of recovery of the I2C under your own control.

Who is online

Users browsing this forum: No registered users and 70 guests