ESP_LOG giving a panic error

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

ESP_LOG giving a panic error

Postby oliverbru » Thu Sep 26, 2019 8:59 am

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

ESP_Dazz
Posts: 142
Joined: Fri Jun 02, 2017 6:50 am

Re: ESP_LOG giving a panic error

Postby ESP_Dazz » Thu Sep 26, 2019 9:09 am

Code: Select all

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

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

Re: ESP_LOG giving a panic error

Postby oliverbru » Thu Sep 26, 2019 9:19 am

It is working.
Thanks a lot :-)

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

Re: ESP_LOG giving a panic error

Postby oliverbru » Thu Sep 26, 2019 9:28 am

It works.
Thanks[

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

Re: ESP_LOG giving a panic error

Postby oliverbru » Thu Sep 26, 2019 2:18 pm

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

User avatar
gunar.kroeger
Posts: 89
Joined: Fri Jul 27, 2018 6:48 pm

Re: ESP_LOG giving a panic error

Postby gunar.kroeger » Thu Sep 26, 2019 7:05 pm

you can't call logging library from inside an interrupt. For debugging, try to toggle a LED or another gpio.
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

KanyeKanye
Posts: 50
Joined: Mon Dec 05, 2016 12:34 am

Re: ESP_LOG giving a panic error

Postby KanyeKanye » Thu Sep 26, 2019 9:20 pm

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");

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

Re: ESP_LOG giving a panic error

Postby oliverbru » Fri Sep 27, 2019 8:53 am

To all,

Thanks a lot for your comments and help.

Olivier

Who is online

Users browsing this forum: MSN [Bot] and 21 guests