bt classic discoveries (starting / stopping) causes unexpected reset
Posted: Thu Mar 25, 2021 9:22 pm
Development Kit: m5stack grey and m5stackcore2 used with ESPIDF
Module or chip used: ESP32 chip revision: 3
IDF version: V4.2
Build System: CMake
Compiler version : xtensa-esp32-elf-gcc (crosstool-NG esp-2020r3) 8.4.0
Operating System: WINDOWS
Using an IDE?: YES VISUAL CODE WITH ESPRESSIF EXTENSION
Power Supply: USB
##Problem Description
bluetooth classic discovery. Launching discoveries periodically on BT CLASSIC via esp_bt_gap_start_discovery(..) produces an unexpected RESET.
Our application is starting BT Classic discoveries. For example Start a Discovery of aprox 2 seconds each 3 seconds. All works OK (devices are founded, events are coming etc...), but in a not predictable time, can be 2 hours, can be 7 hours, the ESP32 Resets because of Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
I enclose a code that is crashing, and the crash LOG
Any Ideas???
Has someone encountered something similar??
Module or chip used: ESP32 chip revision: 3
IDF version: V4.2
Build System: CMake
Compiler version : xtensa-esp32-elf-gcc (crosstool-NG esp-2020r3) 8.4.0
Operating System: WINDOWS
Using an IDE?: YES VISUAL CODE WITH ESPRESSIF EXTENSION
Power Supply: USB
##Problem Description
bluetooth classic discovery. Launching discoveries periodically on BT CLASSIC via esp_bt_gap_start_discovery(..) produces an unexpected RESET.
Our application is starting BT Classic discoveries. For example Start a Discovery of aprox 2 seconds each 3 seconds. All works OK (devices are founded, events are coming etc...), but in a not predictable time, can be 2 hours, can be 7 hours, the ESP32 Resets because of Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
I enclose a code that is crashing, and the crash LOG
Any Ideas???
Has someone encountered something similar??
- `#include <stdint.h>
- #include <string.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include "nvs.h"
- #include "nvs_flash.h"
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_system.h"
- #include "sdkconfig.h"
- #include "esp_log.h"
- #include "esp_bt.h"
- #include "esp_bt_main.h"
- #include "esp_gap_bt_api.h"
- #include "esp_spp_api.h"
- #include "esp32/rom/rtc.h"
- const char *TAG_MAIN = "MINIMAL_CODE_TEST_RESET.CPP";
- uint32_t InqCycles = 0;
- // Relaunch a INQUIRY in BT CLASSIC each , for example 3 seconds
- void vTaskControlBluetooth(void* pvParameters)
- {
- #define INQUIRY_SECONDS_ON 1
- #define INQUIRY_SECONDS_OFF 2
- static int8_t InquirySlot = 0;
- esp_err_t res;
- for (;;) {
- // Start a CLASSIC DISCOVERY
- if (InquirySlot==0){
- res = esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 3, 0);
- if (res!=ESP_OK) ESP_LOGI(TAG_MAIN,"BT Launch Result %d, code %s", res, esp_err_to_name(res));
- }
- // Cancel a Classic DISCOVERY
- if (InquirySlot==INQUIRY_SECONDS_ON){
- res = esp_bt_gap_cancel_discovery();
- if (res!=ESP_OK) ESP_LOGI(TAG_MAIN,"BT Stop Result %d, code %s", res, esp_err_to_name(res));
- }
- // Move Time SLOT
- if (++InquirySlot>=(INQUIRY_SECONDS_ON+INQUIRY_SECONDS_OFF)){
- InquirySlot=0;
- InqCycles++;
- }
- // Suspend 1sec
- vTaskDelay(pdMS_TO_TICKS(1000));
- }
- vTaskDelete(NULL);
- }
- // Periodic Report Last Reset Cause
- void vTaskReportOnTerminal(void* pvParameters)
- {
- for (;;)
- {
- printf("LAST RESET CAUSED BY REASON CODE : %d (Core0) %d (Core1), Inq Cycles %d\r\n", rtc_get_reset_reason(0),rtc_get_reset_reason(1), InqCycles);
- vTaskDelay(pdMS_TO_TICKS(60*1000));
- }
- vTaskDelete(NULL);
- }
- void NVS_InitNVS()
- {
- esp_err_t ret = nvs_flash_init();
- if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
- ESP_LOGI(TAG_MAIN, "NO FREE en NVS FLASH INIT %d", ret);
- ESP_ERROR_CHECK(nvs_flash_erase());
- ret = nvs_flash_init();
- }
- ESP_LOGI(TAG_MAIN, "NVS FLASH INIT result %d", ret);
- }
- extern "C" void app_main(void) {
- BaseType_t xReturned;
- esp_log_level_set(TAG_MAIN, ESP_LOG_INFO); // Set LOG LEVEL
- NVS_InitNVS(); // Init NVS
- // Init Btooth
- esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
- ESP_ERROR_CHECK(esp_bt_controller_init(&cfg));
- ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BTDM));
- ESP_ERROR_CHECK(esp_bluedroid_init());
- ESP_ERROR_CHECK(esp_bluedroid_enable());
- //ESP_ERROR_CHECK(esp_spp_init(ESP_SPP_MODE_CB)); // esto no influye
- // Launch periodic Logs on Monitor
- xReturned = xTaskCreate(vTaskReportOnTerminal,"TASKREPORT",3*1024,NULL,tskIDLE_PRIORITY,NULL);
- configASSERT((xReturned == pdPASS));
- // Launch Task to Restart BT CLASSIC each XX Seconds
- xReturned = xTaskCreate(vTaskControlBluetooth,"TASKLAUNCHBT",3*1024,NULL,tskIDLE_PRIORITY,NULL);
- configASSERT((xReturned == pdPASS));
- }
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- // START STOP INQUIRY + SPP NO STARTED ----- CRASH
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------------------
- // ASSERT_ERR(0), in lm_task.c at line 3997
- // Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
- // Core 0 register dump:
- // PC : 0x40082f08 PS : 0x00060d34 A0 : 0x8005351c A1 : 0x3ffd0500
- // A2 : 0x00000001 A3 : 0x00000000 A4 : 0x60008048 A5 : 0x3ffbdc0c
- // A6 : 0x3ffbdc0c A7 : 0x00000001 A8 : 0x80082f08 A9 : 0x3ffd04e0
- // A10 : 0x00000029 A11 : 0x00000029 A12 : 0x00000010 A13 : 0xffffffff
- // A14 : 0x00000000 A15 : 0xfffffffb SAR : 0x00000004 EXCCAUSE: 0x00000005
- // EXCVADDR: 0x00000000 LBEG : 0x40082eb0 LEND : 0x40082eb7 LCOUNT : 0x00000000
- // Backtrace:
- // 0x40082f05:0x3ffd0500
- // 0x40053519:0x3ffd0520
- // 0x40083e92:0x3ffd0540
- // 0x40019d11:0x3ffd0570
- // 0x40055b4d:0x3ffd0590
- // 0x40127f4f:0x3ffd05b0
- // 0x40128541:0x3ffd05d0
- // 0x4008ddb5:0x3ffd0600
- //
- // 0x40082f05: r_assert_err at ??:?
- // 0x40053519: ?? ??:0
- // 0x4008ddb5: vPortTaskWrapper at C:/Users/anurb/esp/esp-idf/components/freertos/xtensa/port.c:143
- // 0x40019d11: ?? ??:0
- // 0x40055b4d: ?? ??:0
- // 0x40127f4f: r_rw_schedule at ??:?
- // 0x40128541: btdm_controller_task at ??:?
- // 0x4008ddb5: vPortTaskWrapper at C:/Users/anurb/esp/esp-idf/components/freertos/xtensa/port.c:143
- //
- // Core 1 register dump:
- // PC : 0x4015df9a PS : 0x00060034 A0 : 0x800d42ad A1 : 0x3ffbc460
- // A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x80000001
- // A6 : 0x00000003 A7 : 0x00060023 A8 : 0x800d41fe A9 : 0x3ffbc430
- // A10 : 0x00000000 A11 : 0x00060a23 A12 : 0x00060a20 A13 : 0x00060a23
- // A14 : 0x00000001 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000005
- // EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
- // Backtrace:0x4015df97:0x3ffbc460 0x400d42aa:0x3ffbc480 0x4008e745:0x3ffbc4a0 0x4008ddb5:0x3ffbc4c0
- // ELF file SHA256: 54387e1c21c6e4cd
- `