-
Notifications
You must be signed in to change notification settings - Fork 76
solve issues #69 I2C init bug Jetson #70
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
Conversation
exact description of the error and solution here: adafruit#69
please look at the full history of this file for the many times this has come up, it has gone back and forth a few times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution is not general: some devices don't respond to a read when trying to poll them. We have found a write to be the best way to poll.
A solution that always waits for an error is not really nice. Waiting for the error is slower than waiting for the scan. And even more so on the Nvidia Jetson. 10 seconds make Adafruit's I2c library unusable.
This is also the reason why I described the history so extensively in the issue #69 . |
i wish each linux board did not have this problem, but they are not consistent. if you change it and other boards fail, thats not a solution either :) you could try and add specific code to Blinka to handle this if you like, but it does not go in this library that works great except for jetson. please tell nvidia to fix this issue in their i2c driver. |
Editing the i2c driver would shorten the wait for the error, but it would still be a slower method than scanning for each of the addresses. According to my understanding with the construction of the libraries. "Adafruit_CircuitPython_BusDevice" is not called by "blinka". Instead, "Adafruit_CircuitPython_BusDevice" is used via the individual sensors library. Which makes it difficult to rewrite "blinka".
I would really be interested which ones they are. |
It looks like you basically you want to revert aea9d07, which changed the probe from a single-byte read to an empty write attempt. If the write fails, it tries the read. So you want to go back to just a read first. As mentioned in #22 (comment), doing the read first causes at least one I2C sensor (VEML6075) to not work. So we abandoned that. Instead of modifying the BusDevice library here, I think the code in adafruit-blinka (which is called by this library) could be changed to error on a zero-byte write immediately. Ideally the Jetson driver could be fixed. We have seen issues with zero-byte I2C writes on the RPi RP2040 chip. That chip uses an I2C peripheral licensed from Synopsis, and it does not handle zero-byte writes. We worked around that by bit-banging zero-byte writes. I don't know whether the I2C peripheral on the Jetson is the same and has this same issue, but possibly. |
It is the other way round. Blinka implements the low-level I2C routines ( |
Yes I know. Therefore the init write command would always be called and would then have to be fixed with zero-byte write like with the RPi RP2040 chip. It would be much nicer if you could prevent init writing via a bool. |
I have read through the documentation for VEML6075 and it is also clear that it does not support "read only" without writing. But why is this not handled on the sensor VEML6075 library. It is a property of the sensor not of the I2C. I don't know if it is a good trade off to move the special features of the sensors into the I2C library and thus to slow down the I2C connection. |
This enables probing with I2C-read (without write) from the sensor libraries.
@ladyada I can understand your concerns and have now made a new commit ea17818 in which you could switch on reading without writing via a bool. I think probing should be a property of the sensor libraries not of the I2C librarie or blinka librarie. |
Can someone explain why "All checks have failed". What do I have to change in the code? |
Click on the "Details" link. You'll see that it is failing the It is a good idea to use |
@dhalbert I have never worked with |
This guide https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library gives all the details. Look at https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/black for |
My mistake read it over that |
Is that okay? Can you then merge into the current version? |
@tokiAi We do want to solve this in a general way, and may change the scanning technique on Linux boards only from write to read, due to Linux limitations. Our microcontroller experience is that 0-byte writes are in general the best, but not always available, as you have seen. So use a fork as needed for now for your work, and we will put this on our to-do queue, with not necessarily this exact solution, but with a solution. |
Closing this for now as we're waiting for a more general solution. |
exact description of the error and solution here:
#69