https://toitlang.org/ logo
"device not configured", perhaps related to I2C
# help
a
Hi hi, We are seeing some log lines similar to this on occasion
Copy code
[lb-device] ERROR: Error reading from device: ESP_ERR_INVALID_STATE, got 0 bytes, sleeping for 75ms before retrying

E (306797) i2c.master: I2C transaction unexpected nack detected

E (306797) i2c.master: s_i2c_synchronous_transaction(876): I2C transaction failed

E (306797) i2c.master: i2c_master_transmit_receive(1101): I2C transaction failed

Error: device not configured
The first I2c lines we kind of expect and can recover from (or used to be able to) however this
Error: device not configured
is not something we have seen before and are trying to track down. Any ideas where it might be coming from?
f
I'm guessing this is with the latest SDK release?
a
Yes
f
Was there any other error before the first line?
a
there are a few more lines relating to i2c, the same sort of lines, and after it occours a few times, it does the device not configured line
Copy code
E (306597) i2c.master: I2C transaction unexpected nack detected

E (306597) i2c.master: s_i2c_synchronous_transaction(876): I2C transaction failed

E (306597) i2c.master: i2c_master_transmit_receive(1101): I2C transaction failed

[lb-device] ERROR: Error reading from device: ESP_ERR_INVALID_STATE, got 0 bytes, sleeping for 75ms before retrying

E (306697) i2c.master: I2C transaction unexpected nack detected

E (306697) i2c.master: s_i2c_synchronous_transaction(876): I2C transaction failed

E (306697) i2c.master: i2c_master_transmit_receive(1101): I2C transaction failed

[lb-device] ERROR: Error reading from device: ESP_ERR_INVALID_STATE, got 0 bytes, sleeping for 75ms before retrying

E (306797) i2c.master: I2C transaction unexpected nack detected

E (306797) i2c.master: s_i2c_synchronous_transaction(876): I2C transaction failed

E (306797) i2c.master: i2c_master_transmit_receive(1101): I2C transaction failed

Error: device not configured
f
I think the grouping should be:
Copy code
E (306597) i2c.master: I2C transaction unexpected nack detected

E (306597) i2c.master: s_i2c_synchronous_transaction(876): I2C transaction failed

E (306597) i2c.master: i2c_master_transmit_receive(1101): I2C transaction failed

[lb-device] ERROR: Error reading from device: ESP_ERR_INVALID_STATE, got 0 bytes, sleeping for 75ms before retrying
All of these errors are from the ESP-IDF.
a
yes, full list of the lines printed above, and the grouping looks like that
Is
Error: device not configured
potentially then also from the IDF? I had a hunt around at the toit level and couldnt find much
f
I would have said the last one is from your code.
Instead of catching it, and retrying, it gets caught by a higher level
catch
that prints the error.?
a
hmmm, potentially though I see nowhere in our code that would allow output of such a log line
f
neither the esp-idf nor Toit have the text "device not configured" in their sources.
a
and our does doesnt ahve the word "configured" in it, or anything that would output
Error: <foo>
😄
f
could of course be concatenated or something, but the ESP-IDF usually uses a logger (with the
E (...)
), and Toit typically just throws.
We can try to upgrade to the newest ESP-IDF and hope that they fixed something.
I can see, for example, that there was this commit recently: https://github.com/espressif/esp-idf/commit/459b75f81a121dc83beb103a10aee8216c657fce
a
oh interesting
f
That one is, however, too recent for a stable release. So if we think it could help we would need to cherry pick it for testing.
a
which IDF is in the latestr toit?
f
We are now using 5.3.1.
a
looks what what version he was using before
Copy code
Version:         v1.50.2
SDK version:     v2.0.0-alpha.178
f
We used the 5.3.1 esp-idf in the previous Tout release too.
But we were still using the old driver APIs.
Espressif rewrote most of their drivers and deprecated the old ones.
So it's likely a change in how the espressif drivers handle the I2C bus.
5.3.1 is from September 2024
a
very fun that the issue https://github.com/espressif/esp-idf/pull/15638 explicitly flasg up the c6 (which is what we are using)
f
I looked through the commits but didn't find anything particularly interesting.
I would take an ESP32 (not C6) and see if you have the same issues with the peripheral there.
I assume this is very early when talking to the i2c device?
a
it looks like lots of comms has already happened flawlessly, before this
nack
related issue this
nack
related issue always seemed to recover well before, and comms would recover. However now we see this additional log line appearing at the end We will do some more debugging today though and see what we can figure out
f
Ok. If there are comms before, then things are harder to test. Otherwise I would have suggested trying to reproduce it with a pure esp-idf (no Toit). Basically adapt an i2c example to see if it reproduces without any Toit.