ArduinoCore-samd icon indicating copy to clipboard operation
ArduinoCore-samd copied to clipboard

Bad i2c dev recovery

Open sampscl opened this issue 6 years ago • 3 comments

This fixes the issue I reported to platformio. The downside is that startTransmissionWIRE() will immediately return an error on a multi-master I2C bus when another master currently owns the bus. Previous behavior was to wait indefinitely until the other master released the bus.

sampscl avatar Feb 22 '19 14:02 sampscl

From the logic POW this patch looks fine; @sampscl do you have any test case that can help reproducing the issue in a specially crafted misbehaving multimaster setup?

facchinm avatar Mar 06 '19 08:03 facchinm

I will work on it, maybe next week or the week after I'll have something?

Some history: I originally found this when I put an SMBUS battery we had laying around the lab onto my existing I2C bus so I could develop a smart battery interface. It turns out that SMBUS devices are multi-master and this particular one has some bug that causes it to inhibit the I2C stop condition in very rare circumstances (recently charged to 100%, drained a little bit maybe 97%, then start charging again and simultaneously queried for it's current battery state -- at least this was the most common condition when I saw the Arduino I2C deadlock). Check out my attached logic analyzer capture for reference. I'll probably need to write some software to intentionally cause the issue so that it can be repeatedly observed outside my lab.

i2c-smbus-fail

sampscl avatar Mar 06 '19 14:03 sampscl

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: sampscl
:x: asserta6
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 09 '21 13:04 CLAassistant