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

applet.interface.i2c_initiator: timeout & error message when SCL stuck low #187

Open
electroniceel opened this issue Mar 1, 2020 · 2 comments
Labels
i2c-initiator Applet: i2c-initiator

Comments

@electroniceel
Copy link
Member

how to reproduce:

  • connect any port IO to GND (like A0)
  • issue any command that uses this io as i2c initiator SCL (like "glasgow run i2c-initiator --port A -V 3.3 scan")
  • glasgow is waiting endlessly for SCL to go high

I suggest to add a generous, but still reasonable timeout (like 1 second) for this case. Also return an explicit error message like "timeout, SCL stuck low" or similar.

I think this kind of error is not uncommon when testing or developing. Cases that come to mind are:

  • wrong IO pin selected
  • flaky connection
  • external pullup resistors not connected or forgotten to enable the internal ones
  • DUT misbehaving

It would be nice to add some similar detection for SDA too, currently you get back all zeros.

@electroniceel electroniceel added gateware Component: gateware software Component: software labels Mar 1, 2020
@whitequark whitequark added i2c-initiator Applet: i2c-initiator and removed gateware Component: gateware software Component: software labels Mar 5, 2020
@whitequark
Copy link
Member

whitequark commented Mar 5, 2020

Yes, that's pretty common. We can add a timeout for USB requests, which is already supported by the streaming code we have, and raise an exception in I2CInitiatorInterface. The state machine in the applet gateware will remain stuck, and that's OK because recovering from this state ~always requires a full reset, often even a power on reset.

I2C doesn't require a timeout (unfortunately, IMO) so it'll have to be optional, but having it something like 1 second by default seems generally OK.

(Aside: gateware and software tags are for base Glasgow code, applets get a per-applet label. I think you should be able to create them.)

@whitequark
Copy link
Member

whitequark commented Jul 30, 2023

This will become far easier with #354.

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

No branches or pull requests

2 participants