Open combalafra01 opened 7 months ago
I expect to receive ESP_ERR_TIMEOUT after xfer_timeout_ms instead of having the watchdog triggered after CONFIG_ESP_TASK_WDT_TIMEOUT_S seconds. Of course xfer_timeout_ms < CONFIG_ESP_TASK_WDT_TIMEOUT_S in my case CONFIG_ESP_TASK_WDT_TIMEOUT_S = 10 seconds while xfer_timeout_ms = 1000 milliseconds
Try it on latest master. I provided a fix there. Backport to 5.2 is on the way. @combalafra01
thank you I cannot test with master, please tell me when 5.2 is available
OK, then, try it on latest branch release/v5.2? I think some fix already there.. @combalafra01
last merge on i2c_master.c on 5.2 was the one of March 21st (Add parameter to config I2C scl await time) So I guess I will have to wait
@mythbuster5
At least it's fixed in v5.2.1-528-g70fc0e3037
reinstall idf with branch release/v5.2 helps
I am about to migrate to 5.2.2 do you know if the fix is included in this version ?
it does not fail anymore but I have other issues, I will open a new ticket for that
@mythbuster5 the fact that the master was rebooting is fixed now but there is still an issue: if the slave was off when the master was transmitting, it is ok now, we receive an error but when the slave is back we still have the same error when the master tries to transmit. The master do not see that the slave is back, I don't know why for the moment. If we reboot the master and configure it again it works. One solution would be to probe the slave before transmitting something but in term of performance it adds some load. With the legacy driver that was OK, the master transmit was a success when the slave was back after being down. This is a very common use case.
following new tests it appears that it works if the master is started while the sale is down but not if the master while the slave is up.
use case OK:
use case KO:
Probing is not a solution because if slave gets down after the probing but before the transmission, the master fails and cannot recover
see #13962 I think you have to release the semaphone in the while loop of s_i2c_send_commands when the xSemaphoreTake fails because it is in a while loop. So the semaphore can be taken OK on first loop, never released for whatever reason (slave not available in our case) fails on second loop because not released, returns and in this case never released.
adding xSemaphoreGive seems to solve the problem.
if (xSemaphoreTake(i2c_master->cmd_semphr, ticks_to_wait) != pdTRUE) {
// Software timeout, clear the command link and finish this transaction.
i2c_master->cmd_idx = 0;
i2c_master->trans_idx = 0;
atomic_store(&i2c_master->status, I2C_STATUS_TIMEOUT);
xSemaphoreGive(i2c_master->cmd_semphr);
return;
}
Answers checklist.
IDF version.
5.2.1
Espressif SoC revision.
ESP32-S3
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-S3-DevKitC-1
Power Supply used.
USB
What is the expected behavior?
receive ESP_ERR_TIMEOUT error code after xfer_timeout_ms milliseconds if no slave is available
What is the actual behavior?
the watchdog triggers after CONFIG_ESP_TASK_WDT_TIMEOUT_S seconds
Steps to reproduce.
create master I2C with a first ESP32 create slave I2C with a second ESP32 connect them switch on master ESP32 but not slave ESP32 when master ESP32 call i2c_master_transmit with xfer_timeout_ms = 1000ms, the watchdog is triggered after CONFIG_ESP_TASK_WDT_TIMEOUT_S seconds while we expect to receive ESP_ERR_TIMEOUT the behaviour is the same when calling i2c_master_probe. The legacy i2c driver was working correctly, this is a problem on the new i2c driver currently if we have an issue with a slave i2c (component KO, wiring issue, ...) , the master is completely blocked by this behaviour
Debug Logs.
More Information.
legacy i2c driver i2c_master_cmd_begin was working properly, sending back ESP_ERR_TIMEOUT when there was an i2c issue like this one.