Page 1 of 1

ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 8:59 am
by oliverbru

Code: Select all

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "sdkconfig.h"

#define BLINK_GPIO_GREEN 25
#define BUTTON GPIO_NUM_36
#define ESP_INTR_FLAG_DEFAULT 0


void blink_task(void *pvParameter)
{
    while (1)
    {
        ESP_LOGI("test", "Restarting now.");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}

static void IRAM_ATTR gpio_isr_handler()
{
    gpio_set_level(BLINK_GPIO_GREEN, 1);
}

void app_main()
{
    gpio_pad_select_gpio(BLINK_GPIO_GREEN);
    gpio_set_direction(BLINK_GPIO_GREEN, GPIO_MODE_OUTPUT);
    
    gpio_config_t btn_config;
    btn_config.intr_type = GPIO_INTR_HIGH_LEVEL;
    btn_config.mode = GPIO_MODE_INPUT;               //Set as Input
    btn_config.pin_bit_mask = (1ULL << GPIO_NUM_36); //Bitmask
    btn_config.pull_up_en = GPIO_PULLUP_DISABLE;     //Disable pullup
    btn_config.pull_down_en = GPIO_PULLDOWN_DISABLE; //Disable pulldown
    gpio_config(&btn_config);

    //install gpio isr service
    gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);

    //hook isr handler for specific gpio pin
    gpio_isr_handler_add(BUTTON, gpio_isr_handler, NULL);

    xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
    
This code works fine if I do not use this line in my blind_task function

Code: Select all

ESP_LOGI("test", "Restarting now.");
But if I use it, I have a panic error.

I do not understand.

Thanks I am using ESP-IDF 3.3 on with VSCode on windows and a ESP WROOM 32 devkit

Re: ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 9:09 am
by ESP_Dazz

Code: Select all

xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
Try increasing your stack size (e.g. 4096).

Re: ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 9:19 am
by oliverbru
It is working.
Thanks a lot :-)

Re: ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 9:28 am
by oliverbru
It works.
Thanks[

Re: ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 2:18 pm
by oliverbru

Code: Select all

static void IRAM_ATTR gpio_isr_handler()
{
    ESP_LOGI("test", "PRESSED !");
}
It gives the same panic error :-(

PS : I am newbie.

Thanks

Re: ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 7:05 pm
by gunar.kroeger
you can't call logging library from inside an interrupt. For debugging, try to toggle a LED or another gpio.

Re: ESP_LOG giving a panic error

Posted: Thu Sep 26, 2019 9:20 pm
by KanyeKanye
Pins GPI36, GPI39, GPI34, GPI35 have no internal pull resistors (and if even they would, you disabled them).
When floating, lots of interrupts is triggered what cause karnel panic.

For logging use:

Code: Select all

ets_printf("ISR");

Re: ESP_LOG giving a panic error

Posted: Fri Sep 27, 2019 8:53 am
by oliverbru
To all,

Thanks a lot for your comments and help.

Olivier