bt classic discoveries (starting / stopping) causes unexpected reset

andurbal
Posts: 3
Joined: Thu Mar 25, 2021 9:18 pm

bt classic discoveries (starting / stopping) causes unexpected reset

Postby andurbal » 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??

  1.  
  2. `#include <stdint.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #include <stdio.h>
  6. #include "nvs.h"
  7. #include "nvs_flash.h"
  8. #include "freertos/FreeRTOS.h"
  9. #include "freertos/task.h"
  10. #include "esp_system.h"
  11. #include "sdkconfig.h"
  12. #include "esp_log.h"
  13. #include "esp_bt.h"
  14. #include "esp_bt_main.h"
  15. #include "esp_gap_bt_api.h"
  16. #include "esp_spp_api.h"
  17. #include "esp32/rom/rtc.h"
  18.  
  19. const char *TAG_MAIN = "MINIMAL_CODE_TEST_RESET.CPP";
  20. uint32_t InqCycles = 0;
  21.  
  22. // Relaunch a INQUIRY in BT CLASSIC each , for example 3 seconds
  23. void vTaskControlBluetooth(void* pvParameters)
  24. {
  25. #define INQUIRY_SECONDS_ON 1
  26. #define INQUIRY_SECONDS_OFF 2
  27. static int8_t InquirySlot = 0;
  28. esp_err_t res;
  29.  
  30. for (;;) {
  31.  
  32.     // Start a CLASSIC DISCOVERY
  33.     if (InquirySlot==0){
  34.         res =  esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 3, 0);
  35.         if (res!=ESP_OK) ESP_LOGI(TAG_MAIN,"BT Launch Result %d, code %s", res, esp_err_to_name(res));
  36.     }
  37.     // Cancel a Classic DISCOVERY
  38.     if (InquirySlot==INQUIRY_SECONDS_ON){
  39.         res =  esp_bt_gap_cancel_discovery();
  40.         if (res!=ESP_OK) ESP_LOGI(TAG_MAIN,"BT Stop Result %d, code %s", res, esp_err_to_name(res));
  41.     }
  42.     // Move Time SLOT
  43.     if (++InquirySlot>=(INQUIRY_SECONDS_ON+INQUIRY_SECONDS_OFF)){
  44.         InquirySlot=0;
  45.         InqCycles++;
  46.     }
  47.            
  48.     // Suspend 1sec
  49.     vTaskDelay(pdMS_TO_TICKS(1000));
  50. }
  51. vTaskDelete(NULL);
  52. }
  53.  
  54. // Periodic Report Last Reset Cause
  55. void vTaskReportOnTerminal(void* pvParameters)
  56. {
  57. for (;;)
  58. {
  59. 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);
  60. vTaskDelay(pdMS_TO_TICKS(60*1000));
  61. }
  62. vTaskDelete(NULL);
  63. }
  64.  
  65. void NVS_InitNVS()
  66. {
  67. esp_err_t ret = nvs_flash_init();
  68. if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
  69. ESP_LOGI(TAG_MAIN, "NO FREE en NVS FLASH INIT %d", ret);
  70. ESP_ERROR_CHECK(nvs_flash_erase());
  71. ret = nvs_flash_init();
  72. }
  73. ESP_LOGI(TAG_MAIN, "NVS FLASH INIT result %d", ret);
  74. }
  75.  
  76. extern "C" void app_main(void) {
  77.  
  78. BaseType_t xReturned;
  79.  
  80. esp_log_level_set(TAG_MAIN, ESP_LOG_INFO);          // Set LOG LEVEL
  81. NVS_InitNVS();                                      // Init NVS
  82.  
  83.  
  84. // Init Btooth
  85. esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
  86. ESP_ERROR_CHECK(esp_bt_controller_init(&cfg));
  87. ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BTDM));
  88. ESP_ERROR_CHECK(esp_bluedroid_init());
  89. ESP_ERROR_CHECK(esp_bluedroid_enable());
  90. //ESP_ERROR_CHECK(esp_spp_init(ESP_SPP_MODE_CB));       // esto no influye
  91.  
  92. // Launch periodic Logs on Monitor
  93. xReturned = xTaskCreate(vTaskReportOnTerminal,"TASKREPORT",3*1024,NULL,tskIDLE_PRIORITY,NULL);
  94. configASSERT((xReturned == pdPASS));
  95.  
  96. // Launch Task to Restart BT CLASSIC each XX Seconds
  97. xReturned = xTaskCreate(vTaskControlBluetooth,"TASKLAUNCHBT",3*1024,NULL,tskIDLE_PRIORITY,NULL);
  98. configASSERT((xReturned == pdPASS));
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------------------
  102. //----------------------------------------------------------------------------------------------------
  103. //----------------------------------------------------------------------------------------------------
  104. //----------------------------------------------------------------------------------------------------
  105. //----------------------------------------------------------------------------------------------------
  106. // START STOP INQUIRY + SPP NO STARTED ----- CRASH
  107. //----------------------------------------------------------------------------------------------------
  108. //----------------------------------------------------------------------------------------------------
  109. //----------------------------------------------------------------------------------------------------
  110. //----------------------------------------------------------------------------------------------------
  111. //----------------------------------------------------------------------------------------------------
  112. // ASSERT_ERR(0), in lm_task.c at line 3997
  113. // Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
  114.  
  115. // Core 0 register dump:
  116. // PC : 0x40082f08 PS : 0x00060d34 A0 : 0x8005351c A1 : 0x3ffd0500
  117. // A2 : 0x00000001 A3 : 0x00000000 A4 : 0x60008048 A5 : 0x3ffbdc0c
  118. // A6 : 0x3ffbdc0c A7 : 0x00000001 A8 : 0x80082f08 A9 : 0x3ffd04e0
  119. // A10 : 0x00000029 A11 : 0x00000029 A12 : 0x00000010 A13 : 0xffffffff
  120. // A14 : 0x00000000 A15 : 0xfffffffb SAR : 0x00000004 EXCCAUSE: 0x00000005
  121. // EXCVADDR: 0x00000000 LBEG : 0x40082eb0 LEND : 0x40082eb7 LCOUNT : 0x00000000
  122.  
  123. // Backtrace:
  124. // 0x40082f05:0x3ffd0500
  125. // 0x40053519:0x3ffd0520
  126. // 0x40083e92:0x3ffd0540
  127. // 0x40019d11:0x3ffd0570
  128. // 0x40055b4d:0x3ffd0590
  129. // 0x40127f4f:0x3ffd05b0
  130. // 0x40128541:0x3ffd05d0
  131. // 0x4008ddb5:0x3ffd0600
  132. //
  133. // 0x40082f05: r_assert_err at ??:?
  134. // 0x40053519: ?? ??:0
  135. // 0x4008ddb5: vPortTaskWrapper at C:/Users/anurb/esp/esp-idf/components/freertos/xtensa/port.c:143
  136. // 0x40019d11: ?? ??:0
  137. // 0x40055b4d: ?? ??:0
  138. // 0x40127f4f: r_rw_schedule at ??:?
  139. // 0x40128541: btdm_controller_task at ??:?
  140. // 0x4008ddb5: vPortTaskWrapper at C:/Users/anurb/esp/esp-idf/components/freertos/xtensa/port.c:143
  141. //
  142. // Core 1 register dump:
  143. // PC : 0x4015df9a PS : 0x00060034 A0 : 0x800d42ad A1 : 0x3ffbc460
  144. // A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x80000001
  145. // A6 : 0x00000003 A7 : 0x00060023 A8 : 0x800d41fe A9 : 0x3ffbc430
  146. // A10 : 0x00000000 A11 : 0x00060a23 A12 : 0x00060a20 A13 : 0x00060a23
  147. // A14 : 0x00000001 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000005
  148. // EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
  149.  
  150. // Backtrace:0x4015df97:0x3ffbc460 0x400d42aa:0x3ffbc480 0x4008e745:0x3ffbc4a0 0x4008ddb5:0x3ffbc4c0
  151.  
  152. // ELF file SHA256: 54387e1c21c6e4cd
  153. `

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 207 guests