Recently I found that the program paniced when printf() was called within a critical section and the last case happened when trying to call gpio_config() which yet has printf inside.
Briefly, the code called is:
Code: Select all
portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&mutex);
gpio_config_t GPIO_Struct;
...
err=gpio_config(&GPIO_Struct);
...
portEXIT_CRITICAL(&mutex);
Code: Select all
0x40088091: invoke_abort at C:/esp-idf/components/esp32/panic.c:157
0x40088421: abort at C:/esp-idf/components/esp32/panic.c:174
0x40083646: lock_acquire_generic at C:/esp-idf/components/newlib/locks.c:143
0x40083769: _lock_acquire_recursive at C:/esp-idf/components/newlib/locks.c:171
0x40172186: _vfprintf_r at /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vfprintf.c:853 (discriminator 2)
0x401751b5: vprintf at /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vprintf.c:34
0x400933a1: esp_log_write at C:/esp-idf/components/log/log.c:190
0x400eaf45: gpio_config at C:/esp-idf/components/driver/gpio.c:364 (discriminator 9)
I am wandering whether it is incorrect to call any function internally invoking printf() within critical section or it is just a coincidence and the problem is caused by other thing?