UncleRus / esp-idf-lib

Component library for ESP32-xx and ESP8266
https://esp-idf-lib.readthedocs.io/en/latest/
1.39k stars 431 forks source link

Watchdog timer reset after BME280 initialization on ESP32C3 #620

Open camielverdult opened 6 months ago

camielverdult commented 6 months ago

The issue

When using the code from the example, I am getting a watchdog timer reset after the bmp280_init function call:

void app_main(void)
{
    ESP_ERROR_CHECK(i2cdev_init());
    // xTaskCreatePinnedToCore(bmp280_test, "bmp280_test", configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL, PRO_CPU_NUM);

    bmp280_params_t params;
    ESP_LOGI("app_main", "a");
    bmp280_init_default_params(&params);
    ESP_LOGI("app_main", "b");
    bmp280_t dev;
    ESP_LOGI("app_main", "c");
    memset(&dev, 0, sizeof(bmp280_t));
    ESP_LOGI("app_main", "d");

    ESP_ERROR_CHECK(bmp280_init_desc(&dev, BMP280_I2C_ADDRESS_1, I2C_NUM_0, I2C_SDA, I2C_SCL));
    ESP_LOGI("app_main", "e");
    ESP_ERROR_CHECK(bmp280_init(&dev, &params));
    ESP_LOGI("app_main", "f");

    bool bme280p = dev.id == BME280_CHIP_ID;
    // Log chip id
    // ESP_LOGI("BMP280: found %s\n", bme280p ? "BME280" : "BMP280");

    ESP_LOGI("app_main", "g");
    float pressure, temperature, humidity;

    while (1)
    {
        ESP_LOGI("app_main", "looping...");
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        if (bmp280_read_float(&dev, &temperature, &pressure, &humidity) != ESP_OK)
        {
            // Log the error
            ESP_LOGE("BMP280", "Temperature/pressure reading failed");
            continue;
        }

        ESP_LOGI("app_main", "Pressure: %.2f Pa, Temperature: %.2f C", pressure, temperature);
        if (bme280p)
            ESP_LOGI("BMP280", ", Humidity: %.2f\n", humidity);
        else
            ESP_LOGI("BMP280", "\n");
    }
}

I do not know if this issue is related to #609.

Which SDK are you using?

esp-idf

Which version of SDK are you using?

master (Wed Aug 23 19:25:22 2023)

Which build target have you used?

Component causing the issue

bmp280

Anything in the logs that might be useful for us?

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380082
riscv32-esp-elf-addr2line -pfiaC -e /Users/camiel/Documents/GitHub/c3-sensor/build/c3-sensor.elf 0x40380082: [Errno 2] No such file or directory: 'riscv32-esp-elf-addr2line'
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1738
load:0x403cc710,len:0xae8
load:0x403ce710,len:0x2e7c
entry 0x403cc71a
I (24) boot: ESP-IDF v5.2-dev-2383-g82cceabc6e 2nd stage bootloader
I (24) boot: compile time Mar 19 2024 09:50:52
I (25) boot: chip revision: v0.4
I (29) boot.esp32c3: SPI Speed      : 80MHz
I (34) boot.esp32c3: SPI Mode       : DIO
I (38) boot.esp32c3: SPI Flash Size : 2MB
I (43) boot: Enabling RNG early entropy source...
I (49) boot: Partition Table:
I (52) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (67) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (74) boot:  2 factory          factory app      00 00 00010000 00100000
I (82) boot: End of partition table
I (86) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0a568h ( 42344) map
I (101) esp_image: segment 1: paddr=0001a590 vaddr=3fc8c200 size=01158h (  4440) load
I (104) esp_image: segment 2: paddr=0001b6f0 vaddr=40380000 size=04928h ( 18728) load
I (115) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=19620h (103968) map
I (136) esp_image: segment 4: paddr=00039648 vaddr=40384928 size=07750h ( 30544) load
I (146) boot: Loaded app from partition at offset 0x10000
I (147) boot: Disabling RNG early entropy source...
I (158) cpu_start: Unicore app
I (158) cpu_start: Pro cpu up.
I (167) cpu_start: Pro cpu start user code
I (167) cpu_start: cpu freq: 160000000 Hz
I (167) cpu_start: Application information:
I (170) cpu_start: Project name:     c3-sensor
I (175) cpu_start: App version:      88b924b-dirty
I (180) cpu_start: Compile time:     Mar 19 2024 22:31:39
I (186) cpu_start: ELF file SHA256:  d393f7b95...
I (192) cpu_start: ESP-IDF:          v5.2-dev-2383-g82cceabc6e
I (198) cpu_start: Min chip rev:     v0.3
I (203) cpu_start: Max chip rev:     v0.99 
I (208) cpu_start: Chip rev:         v0.4
I (213) heap_init: Initializing. RAM available for dynamic allocation:
I (220) heap_init: At 3FC8E200 len 0004E510 (313 KiB): DRAM
I (226) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (233) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (240) spi_flash: detected chip: generic
I (244) spi_flash: flash io: dio
W (247) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
W (261) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`
I (271) sleep: Configure to isolate all GPIO pins in sleep state
I (278) sleep: Enable automatic switching of GPIO sleep configuration
I (285) app_start: Starting scheduler on CPU0
I (290) main_task: Started on CPU0
I (290) main_task: Calling app_main()
I (290) app_main: 1
I (300) app_main: a
I (300) app_main: b
I (300) app_main: c
I (300) app_main: d
I (310) app_main: e
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380080
riscv32-esp-elf-addr2line -pfiaC -e /Users/camiel/Documents/GitHub/c3-sensor/build/c3-sensor.elf 0x40380080: [Errno 2] No such file or directory: 'riscv32-esp-elf-addr2line'
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1738
load:0x403cc710,len:0xae8
load:0x403ce710,len:0x2e7c
entry 0x403cc71a
I (24) boot: ESP-IDF v5.2-dev-2383-g82cceabc6e 2nd stage bootloader
I (24) boot: compile time Mar 19 2024 09:50:52
I (25) boot: chip revision: v0.4
I (28) boot.esp32c3: SPI Speed      : 80MHz
I (33) boot.esp32c3: SPI Mode       : DIO
I (38) boot.esp32c3: SPI Flash Size : 2MB
W (43) boot.esp32c3: PRO CPU has been reset by WDT.
... omitted duplicate logs ...
I (295) main_task: Calling app_main()
I (295) app_main: 1
I (305) app_main: a
I (305) app_main: b
I (305) app_main: c
I (305) app_main: d
I (315) app_main: e

Additional information or context

This is with the Adafruit BME280 breakout board on a generic ESP32-C3-MINI-1 dev board.

Confirmation

camielverdult commented 6 months ago

The I2C scanner also throws this watchdog timer reset.

I (294) main_task: Calling app_main()
I (294) app_main: 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380082
riscv32-esp-elf-addr2line -pfiaC -e /Users/camiel/Documents/GitHub/c3-sensor/build/c3-sensor.elf 0x40380082: [Errno 2] No such file or directory: 'riscv32-esp-elf-addr2line'
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x1738
load:0x403cc710,len:0xae8
load:0x403ce710,len:0x2e7c
entry 0x403cc71a
I (24) boot: ESP-IDF v5.2-dev-2383-g82cceabc6e 2nd stage bootloader
I (24) boot: compile time Mar 19 2024 09:50:52
I (25) boot: chip revision: v0.4
I (28) boot.esp32c3: SPI Speed      : 80MHz
I (33) boot.esp32c3: SPI Mode       : DIO
I (38) boot.esp32c3: SPI Flash Size : 2MB
W (43) boot.esp32c3: PRO CPU has been reset by WDT.