OTA hangs when using I2C
Posted: Tue May 25, 2021 2:19 pm
I am not altogether new to C++ or the ESP32, but I am running up against a problem too big for me. When trying to perform an OTA (AsyncElegantOTA if it matters), my code is also using I2C, which causes the ESP32 to throw a lot of errors like:
On some OSes like Windows 10, this will ultimately cause a watchdog reset. On Linux it does perform the OTA most of the time. Since I am using FreeRTOS, I used this code, but it doesn't change a thing:
So I tried:
Which works, but it seems horribly hacky. I am looking for a more elegant way to detect an OTA update being done, so that I can shut down the I2C task. Or what are my other options? As far as I can tell, the OTA uses the I2C bus. There's a bit of reports of the OTA hanging problem across the Interweb, I suspect they might be related.
Code: Select all
[E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbe454
[I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb844c
[I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=0
[I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1
[I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3
[I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=5
[I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffde80c bits=112
[I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffde840
[I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffd0120
[I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=1
[I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=0
[I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=-1
[I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=0
[I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000
[I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled
[I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled
[I][esp32-hal-i2c.c:1138] i2cProcQueue(): Bus busy, reinit
Code: Select all
if( xSemaphoreTake( i2cMutex, 1000 ) == pdTRUE ) {
// do I2C here
xSemaphoreGive( i2cMutex );
}
Code: Select all
if( xSemaphoreTake( i2cMutex, 1000 ) == pdTRUE ) {
wheelAngleTmp = ads.readADC_Differential_0_1();
if( Wire.lastError() != 0 ){
vTaskDelete( NULL );
}
xSemaphoreGive( i2cMutex );
}