Andrey
Andrey

Reputation: 6377

esp-idf assert failed: spinlock_acquire

My code is as follows:

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

#define GPIO_MPU_INTERRUPT GPIO_NUM_4
#define ESP_INTR_FLAG_DEFAULT 0

void app_main(void)
{
    gpio_config_t io_conf = {};
    io_conf.intr_type = GPIO_INTR_POSEDGE;
    io_conf.pin_bit_mask = 1ULL<<GPIO_MPU_INTERRUPT;
    io_conf.mode = GPIO_MODE_INPUT;
    io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
    gpio_config(&io_conf);
    gpio_set_intr_type(GPIO_MPU_INTERRUPT, GPIO_INTR_ANYEDGE);
    gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
}

If I compile with optimization - it works fine. But when compiling without optimization - I am getting an error:

IDF/components/freertos/queue.c:821 (xQueueGenericSend)- assert failed!

assert failed: spinlock_acquire spinlock.h:122 (result == core_id || result == SPINLOCK_FREE)

...

0x4008b58f: spinlock_acquire at C:/Espressif/frameworks/esp-idf-v4.4.1/components/esp_hw_support/include/soc/spinlock.h:122
 (inlined by) xPortEnterCriticalTimeout at C:/Espressif/frameworks/esp-idf-v4.4.1/components/freertos/port/xtensa/port.c:288

0x400882a4: vPortEnterCritical at C:/Espressif/frameworks/esp-idf-v4.4.1/components/freertos/port/xtensa/include/freertos/portmacro.h:578
 (inlined by) xQueueGenericSend at C:/Espressif/frameworks/esp-idf-v4.4.1/components/freertos/queue.c:840

Upvotes: 0

Views: 5887

Answers (1)

Andrey
Andrey

Reputation: 6377

Looks like it is a memory issue. I've changed IPC task stack size from 1024 to 1536 and it is working now

Upvotes: 1

Related Questions