guild icon
Toit
#"device not configured", perhaps related to I2C
Thread channel in help
addshore
addshore 05/12/2025 11:25 AM
Hi hi,

We are seeing some log lines similar to this on occasion
[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?
floitsch
floitsch 05/12/2025 11:34 AM
I'm guessing this is with the latest SDK release?
addshore
addshore 05/12/2025 11:34 AM
Yes
floitsch
floitsch 05/12/2025 11:34 AM
Was there any other error before the first line?
addshore
addshore 05/12/2025 11:35 AM
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
addshore
addshore 05/12/2025 11:35 AM
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
floitsch
floitsch 05/12/2025 11:36 AM
I think the grouping should be:
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
floitsch
floitsch 05/12/2025 11:36 AM
All of these errors are from the ESP-IDF.
addshore
addshore 05/12/2025 11:36 AM
yes, full list of the lines printed above, and the grouping looks like that
addshore
addshore 05/12/2025 11:37 AM
Is Error: device not configured potentially then also from the IDF?
I had a hunt around at the toit level and couldnt find much
floitsch
floitsch 05/12/2025 11:37 AM
I would have said the last one is from your code.
floitsch
floitsch 05/12/2025 11:37 AM
Instead of catching it, and retrying, it gets caught by a higher level catch that prints the error.?
floitsch
floitsch 05/12/2025 11:38 AM
addshore
addshore 05/12/2025 11:39 AM
hmmm, potentially though I see nowhere in our code that would allow output of such a log line
floitsch
floitsch 05/12/2025 11:40 AM
neither the esp-idf nor Toit have the text "device not configured" in their sources.
addshore
addshore 05/12/2025 11:41 AM
and our does doesnt ahve the word "configured" in it, or anything that would output Error: <foo> :๐Ÿ˜„:(edited)
floitsch
floitsch 05/12/2025 11:41 AM
could of course be concatenated or something, but the ESP-IDF usually uses a logger (with the E (...)), and Toit typically just throws.
๐Ÿ‘1
floitsch
floitsch 05/12/2025 11:42 AM
We can try to upgrade to the newest ESP-IDF and hope that they fixed something.
addshore
addshore 05/12/2025 11:42 AM
oh interesting
floitsch
floitsch 05/12/2025 11:42 AM
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.
addshore
addshore 05/12/2025 11:43 AM
which IDF is in the latestr toit?
floitsch
floitsch 05/12/2025 11:43 AM
We are now using 5.3.1.
floitsch
floitsch 05/12/2025 11:44 AM
Espressif IoT Development Framework. Official development framework for Espressif SoCs. - History for components/driver/i2c/i2c.c - espressif/esp-idf
addshore
addshore 05/12/2025 11:44 AM
looks what what version he was using before
addshore
addshore 05/12/2025 11:44 AM
Version: v1.50.2 SDK version: v2.0.0-alpha.178
floitsch
floitsch 05/12/2025 11:45 AM
We used the 5.3.1 esp-idf in the previous Tout release too.
floitsch
floitsch 05/12/2025 11:45 AM
But we were still using the old driver APIs.
floitsch
floitsch 05/12/2025 11:45 AM
Espressif rewrote most of their drivers and deprecated the old ones.
floitsch
floitsch 05/12/2025 11:45 AM
So it's likely a change in how the espressif drivers handle the I2C bus.
๐Ÿ‘1
floitsch
floitsch 05/12/2025 11:46 AM
5.3.1 is from September 2024
addshore
addshore 05/12/2025 11:47 AM
very fun that the issue https://github.com/espressif/esp-idf/pull/15638 explicitly flasg up the c6 (which is what we are using)
Description
There was a fix to the new i2c driver in #13647 but not the legacy driver. Port the fix to the legacy driver.
Can see the diff here: fdc5fa2
ESPHome i2c scan locks up on C6 and P4, with...
floitsch
floitsch 05/12/2025 11:48 AM
I looked through the commits but didn't find anything particularly interesting.
floitsch
floitsch 05/12/2025 11:49 AM
I would take an ESP32 (not C6) and see if you have the same issues with the peripheral there.
floitsch
floitsch 05/12/2025 11:49 AM
I assume this is very early when talking to the i2c device?
addshore
addshore 05/12/2025 11:51 AM
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
floitsch
floitsch 05/12/2025 11:52 AM
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.
๐Ÿ‘1
37 messages in total