-
Notifications
You must be signed in to change notification settings - Fork 214
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
Surprising I2C TimeOut
[ESP32-C3]
#2026
Comments
The repo is here. See I will next:
|
Tried with @liebman 's PR. While it's undoubtably good for other purposes, it does not change the timeout behaviour I'm observing. Thus, I hope it's not used to "close this issue". |
I happen to own such a sensor but I'm unable to get your code to build (I already spent a bit too much time on that). However, I started an attempt to port the C driver to Rust some time ago (never finished that - but at least it downloads the FW to the sensor and can read the device-id etc.) and I don't run into those timeouts Have you tried your setup with known working code (e.g. Arduino, MicroPython or ESP-IDF code)? Just to rule out any HW problems |
@bjoernQ This is nice to hear!
I haven't. The reason is a bit like your "already spent a bit too much". I don't have interest in C or ESP-IDF but you are right. That can be one way further. I offer to help you get the code compiling, and obviously I'd be interested to learn about your C/Rust attempt. Until then, I plan to check this out on an ESP32-C6. Which MCU did you use?
|
I tried on C3 and C6 I also verified things with this C code: https://github.com/RJRP44/VL53L5CX-Library (just had to increase the stack size, change the I2C port to 0 and just in case I lowered the frequency to 100kHz for the example to work)
I just power-on the thing - my breakout board doesn't even have a reset pin. It's some generic thing from AliExpress not made by ST |
This just came in: #2045 He's done a bit more digging but it's certainly the same issue.
This explains why in my tests I got panics with 1000. The new issue is clearer and deeper, in my opinion than this one. I'm fine closing this in favor of it. In the mean time,
Same wiring. |
The below tables are from the ESP32 Technical Reference Manual:
|
Any chance you have access to a logic analyzer or a scope where you can capture the end of the transaction? |
Seems I cannot repeat this problem any more. I had moved to using ESP32-C6-DevKitM-01, developed further, and something must have fixed it also for ESP32-C3-DevKitC-02. Tried a bit to tease it back, but didn't succeed.
I would, once a week at a hacklab, but since things now work it's pointless for me. @yanshay You still have the problem?
|
I started seeing this again. Steps to reproduce
The first block of 252 bytes (+ 2 for an index) = 254 writes well. The second one gets the I'll be moving to ESP32-C6 (which fixed the situation last time; for an unknown change that happened). Just reporting this since... still happening. Also ESP32-C3 in this case (as was last time). |
As before, ESP32-C6 does not suffer from this (same code works there). |
There have been two I2C related bugfix PRs since 0.20.1 - could you try the main branch and see if it makes a difference? |
Sure. And a curious thing happens. TL;DR It's not ##Longer background I have two setups for developing; both using USB/IP for accessing the MCU. One route shares it to Mac (where I use Rust Rover IDE) and another shares it (locally) to a Windows laptop's WSL2 shell. I can develop in both. The I had noticed Another experiment. If I press This is good stuff to know - at least for me! Since there are plenty of ways to go around it (not use C3; not use Thanks for the help! -- Edit: It wasn't USB/IP but wrong versions of |
Reporting this so we can argue whether it's intended behaviour or not.
I'm taking my first steps with ESP32-C3 and I2C. Here's a log:
Here, I'm starting to loop each max. slice (that fits into the I2C FIFO) of a larger (32k) slice. I am somewhat surprised to receive a timeout, since the I2C is created with:
There is the
new_with_timeout
variant that I'll be soon trying out. Here comes my first question:::new
mean that there are no timeouts? I would expect either that, or a "default" timeout, but the documentation is really scarce oni2c
.Question #2
What is the unit of
timeout
parameter here: https://github.com/esp-rs/esp-hal/blob/main/esp-hal/src/i2c.rs#L380I'm kind of fine looking at these things within the
esp-hal
repo (have it checked out, locally), but this is going elsewhere, without a hint of information what theu32
is. Likely, it'll be milliseconds? But what if I want to not have timeouts? Can I use0
?Question #3
I noticed, going through the code that internal SDA & SCL pull-ups are enabled for the bus. I have external ones - how should I not have them within the chip?
The documentation states:
I hope it's that way. Only, I don't know where to look for how easy it would be. Let's fix this!
Edit:
When coming to the
TimeOut
, the bus has already taken care of 30..40 1-byte reads and writes. It is the cumulative size of transferred data that seems to trigger the timeout. If I vary the size of the written chunks (tried 254, 100 and 50), I get more chunks through, but roughly the same overall data (400..500 bytes).This is weird. I would expect a timeout to apply separately for each I2C transaction.
Same behaviour with both 100kHz and 400kHz bus speeds.
Versions:
esp-hal
0.19.0 with features"defmt", "esp32c3", "embedded-hal"
The text was updated successfully, but these errors were encountered: