I have 5 tasks accessing the multiple devices under the same i2c bus, to avoid conflict i have added semaphore on them, but i am still getting these errors (originating from different tasks):
Code: Select all
ERROR 1: assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle())
ERROR 2: assert failed: vTaskPriorityDisinheritAfterTimeout (pxTCB->uxMutexesHeld)
Mutex creation:
Code: Select all
//Defined in a common header file
SemaphoreHandle_t xI2CSemaphore; // Shared I2C Resource Mutex
//Running on the "setup()"
void setup_mutex() {
if (xI2CSemaphore == NULL) {
xI2CSemaphore = xSemaphoreCreateMutex();
if ((xI2CSemaphore) != NULL) xSemaphoreGive((xI2CSemaphore));
}
Code: Select all
#include "the_file_which_has_the_semaphore.h";
extern SemaphoreHandle_t xI2CSemaphore;
TaskHandle_t Handle_taskTMP102;
void task_temperature(void* pvParameters)
{
ESP_LOGI("", "started");
for (;;)
{
if (xSemaphoreTake(xI2CSemaphore, (TickType_t)DEFAULT_SEMAPHORE_TIMEOUT) == pdTRUE)
{
xLog.temperature = get_temperature(); //This is the function accessing i2c
if (xSemaphoreGive(xI2CSemaphore) != pdTRUE)
{
ESP_LOGE("", "FAILED TO RETURN xI2CSemaphore");
}
vTaskDelay(TMP102_UPDATE_CICLE_MS / portTICK_PERIOD_MS);
}
}
}
Code: Select all
[ 24][I][xlog.h:94] serial_setup(): [xLOG] xLog library version 1.0.0, compiled in Mar 2 2023 12:53:16
[ 36][I][nvs.h:47] setup_nvs(): [] BOOT COUNTER IS 1
[ 40][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 43][W][Wire.cpp:301] begin(): Bus already started in Master Mode.
[ 105][I][sdcard.h:211] setup_sd(): [] SD Card initialized
[ 106][W][Wire.cpp:301] begin(): Bus already started in Master Mode.
[ 111][I][rtc.h:54] task_sync_rtc_to_gps(): [] started
[ 111][I][rtc.h:149] task_rtc(): [] started
[ 411][W][Wire.cpp:301] begin(): Bus already started in Master Mode.
[ 412][I][tmp102.h:94] task_temperature(): [] started
[ 412][I][gps.h:85] task_update_gps(): [] started
[ 426][I][accelerometer.h:79] read_calibrated_offset(): [] read offsets = x 0, y 0, z 0
assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle())
Backtrace: 0x40083c85:0x3ffd5620 0x40093ed9:0x3ffd5640 0x400997e9:0x3ffd5660 0x4009498e:0x3ffd5790 0x400d6d4f:0x3ffd57d0 0x400d6fd9:0x3ffd57f0 0x400d61c9:0x3ffd5810 0x400d6271:0x3ffd5830
#0 0x40083c85:0x3ffd5620 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
#1 0x40093ed9:0x3ffd5640 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
#2 0x400997e9:0x3ffd5660 in __assert_func at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/assert.c:85
#3 0x4009498e:0x3ffd5790 in xQueueGenericSend at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/freertos/queue.c:821 (discriminator 2)
#5 0x400d6fd9:0x3ffd57f0 in TwoWire::endTransmission() at C:/Users/italo/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src/Wire.cpp:642
#6 0x400d61c9:0x3ffd5810 in get_temperature() at src/xlog/MODULES/tmp102.h:46
#7 0x400d6271:0x3ffd5830 in task_temperature(void*) at src/xlog/MODULES/tmp102.h:99
ELF file SHA256: 7bdc8e34d23a705c
>> NOTE: THE ESP32 IS STUCK HERE, it does not reboot or do anything until the reset is pressed
1 - i have tried DEFAULT_SEMAPHORE_TIMEOUT as 0, 10, 1000 with the same results
2 - i have tried disabling some tasks, which does help reducing the errors.
Does anyone have any idea on what could be happening?