ESP_LOGD causing crash

densha
Posts: 5
Joined: Sun Feb 11, 2018 6:54 am

ESP_LOGD causing crash

Postby densha » Mon Feb 26, 2018 10:39 am

Hi Forum

I am new to ESP32 and I have interfaced to my SHT31 sensor. However, when I use ESP_LOGD I am getting a crash and my ESP32 is rebooting. In the attached minimal example when I un-comment ESP_LOGD(tag, "i2c write start"); I get a crash.

Could someone explain what I have done wrong and why this is crashing?

Thanks

Densha

Code: Select all

#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include <esp_log.h>

#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <math.h>
#include <stdbool.h>
#include <esp_err.h>
#include "sdkconfig.h"

static const char tag[] = "sht31";

esp_err_t i2c_send_command () {
    // UNCOMMENT THIS LINE ESP_LOGD(tag, "i2c write start");
    return ESP_OK;
}

void SHT31_task( void * arg)
{
    while(1) {
        esp_err_t ret = i2c_send_command ();
        vTaskDelay(10000 / portTICK_PERIOD_MS);
    }
}

void app_main() {
    ESP_LOGD(tag, "sht31 initialize");
    xTaskCreate(&SHT31_task, "sht31_task", 1024, NULL, 5, NULL);
}

Code: Select all

Crash
0x400df995: esp_vfs_write at /home/densha/esp/esp-idf/components/vfs/./vfs.c:274 (discriminator 4)
0x400d5d35: __sprint_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:437
0x400db4fe: _vfprintf_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vfprintf.c:1782 (discriminator 1)
0x400db641: vprintf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/libc/stdio/vprintf.c:39
0x400823e9: esp_log_write at /home/densha/esp/esp-idf/components/log/./log.c:215
0x400d1c75: i2c_send_command at /home/densha/esp/esp32_sht31/main/./main.c:14
0x400d1c7f: SHT31_task at /home/densha/esp/esp32_sht31/main/./main.c:21 (discriminator 1)

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: ESP_LOGD causing crash

Postby ESP_Angus » Mon Feb 26, 2018 10:44 pm

Hi Densha,

There's a task stack overflow. printf() (used by ESP_LOGx) uses quite a lot of stack space and 1024 bytes is not enough. Try increasing it to 2048 or 4096.


Angus

densha
Posts: 5
Joined: Sun Feb 11, 2018 6:54 am

Re: ESP_LOGD causing crash

Postby densha » Tue Feb 27, 2018 7:04 am

Angus

Perfect - Thanks.

Densha

Who is online

Users browsing this forum: No registered users and 89 guests