Skip to content

Deadlock in SERCOM::startTransmissionWIRE() #65

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

Open
sampscl opened this issue Feb 6, 2019 · 8 comments
Open

Deadlock in SERCOM::startTransmissionWIRE() #65

sampscl opened this issue Feb 6, 2019 · 8 comments

Comments

@sampscl
Copy link

sampscl commented Feb 6, 2019

In SERCOM.cpp the startTransmissionWIRE() function does some setup, transmits the slave address, and waits on completion. In the current GitHub version (cf28026aef2f65e2ddc5c631d2b01a144ff0a068), this is on line 529. There are circumstances in which the MB flag will never be set, in particular when the bus is in an "unknown" state. I've run across the case where startTransmissionWIRE() deadlocks on the MB flag when addressing an SMBUS device on a SAMD21G18 MCU.

A temporary fix for me was to add a check for sercom->I2CM.INTFLAG.bit.ERROR and return false if that is set while waiting on MB. I didn't want to mod the code and do a pull request since I don't have a good way of verifying that my changes work in all circumstances and on all supported variants.

@ivankravets
Copy link
Member

See platformio/platformio-pkg-framework-arduinosam#8

Is this issue fixed in the latest 1.2.9 core by Adafruit? We plan to update it soon.

@sampscl
Copy link
Author

sampscl commented Feb 8, 2019

Bottom line up front: I'm going to work with the Arduino project for this. I attached a logic analyzer capture of the "offending" bus activity. At the end of the attached capture, the bus state in the SAMD21 SERCOM is "busy" and it never leaves that state. Looking at the signals, there is never a "stop" condition on the bus -- so the SERCOM is correct. The problem is that there is no way for a calling program to detect this condition -- and that is where I'll start with the Arduino folks.

i2c-smbus-fail

@ivankravets
Copy link
Member

Please re-test with upstream version https://docs.platformio.org/en/latest/platforms/atmelsam.html#upstream

@sampscl
Copy link
Author

sampscl commented Feb 20, 2019

Please re-test with upstream version https://docs.platformio.org/en/latest/platforms/atmelsam.html#upstream

I still have a problem with the upstream version. It showed up in a different location, but the end result is the same. DDD screen capture attached for reference.

ddd-i2c-busyloop

@sampscl sampscl closed this as completed Feb 20, 2019
@sampscl sampscl reopened this Feb 20, 2019
@sampscl
Copy link
Author

sampscl commented Feb 20, 2019

I didn't mean to close the issue!

@ivankravets
Copy link
Member

Does it work with Arduino IDE?

@sampscl
Copy link
Author

sampscl commented Feb 21, 2019

Does it work with Arduino IDE?

If I get time, I will try it. My project is pretty tightly coupled with platformio/cmake/gitlab. I've honestly never used the Arduino IDE.

In the meantime, I've got a fork and branch of ArduinoCore-samd at github that worked nicely overnight last night.

@ivankravets ivankravets transferred this issue from platformio/platformio-pkg-framework-arduinosam Jul 9, 2019
@ivankravets
Copy link
Member

Could you reproduce this issue with the latest release of dev/platform?

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

No branches or pull requests

2 participants