Page 1 of 1

"PRO CPU has been reset by WDT" when using ESP32 bluetooth stack

Posted: Mon Apr 29, 2024 4:29 am
by u_ding
ESP-IDF5.1 version, when modifying the avdt layer message and sending it out, triggers "PRO CPU has been reset by WDT" and reset.

Example used: a2dp_source
Modified code, esp-idf/components/bt/host/bluedroid/stack/avdt/avdt_ad.c
  1. UINT8 avdt_ad_write_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, BT_HDR *p_buf)
  2. {
  3. UINT8 tcid;
  4.  
  5. /* get tcid from type, scb */
  6. tcid = avdt_ad_type_to_tcid(type, p_scb);
  7.  
  8. srand(time(NULL));
  9. // p_buf[0].event = (uint16_t)rand();
  10.  
  11. // if(type == AVDT_CHAN_MEDIA){
  12. p_buf->event = (uint16_t)rand();
  13. p_buf->len = (uint16_t)rand();
  14. p_buf->offset = (uint16_t)rand();
  15. p_buf->layer_specific = (uint16_t)rand();
  16. for(int i = 0; i < p_buf->len; ++i) p_buf->data[i] = (uint16_t)rand();
  17. // }
  18.  
  19. // static int dk_cnt = 0;
  20. // if(++dk_cnt % 1000 == 0){
  21. // dk_cnt = 0, printf("\n\n avdt_ad_write_req \n");
  22. // printf("%" PRIu16 " ", p_buf->event);
  23. // printf("%" PRIu16 " ", p_buf->len);
  24. // printf("%" PRIu16 " ", p_buf->offset);
  25. // printf("%" PRIu16 " \n", p_buf->layer_specific);
  26. // for(int i = 0; i < p_buf->len; ++i) printf("%" PRIu16 " ", p_buf->data[i]);
  27. // printf("\n\n");
  28. // }
  29.  
  30. return L2CA_DataWrite(avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid, p_buf);
  31. }

change the target of esp-idf/examples/bluetooth/bluedroid/classic_bt/a2dp_source to "HUAWEI FreeBuds 4i"
  1. /* device name */ #define TARGET_DEVICE_NAME    "HUAWEI FreeBuds 4i"
  1. TTTT  HUAWEI FreeBuds 4i
  2. I (9877) BT_AV: Found a target device, address b8:8e:82:9a:be:50, name HUAWEI FreeBuds 4i
  3. I (9887) BT_AV: Cancel device discovery ...
  4. I (9897) BT_AV: Device discovery stopped.
  5. I (9897) BT_AV: a2dp connecting to peer: HUAWEI FreeBuds 4i
  6. W (9907) BT_APPL: reset flags
  7. I (9917) BT_AV: bt_app_av_sm_hdlr state: 4, event: 0x0
  8. W (10367) BT_HCI: hcif conn complete: hdl 0x80, st 0x0
  9. I (10367) BT_AV: event: 16
  10. ets Jul 29 2019 12:21:46
  11.  
  12. rst:0x7 (TG0WDT_SYS_RESET),boot:0x1e (SPI_FAST_FLASH_BOOT)
  13. configsip: 0, SPIWP:0xee
  14. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  15. mode:DIO, clock div:2
  16. load:0x3fff0030,len:7132
  17. ho 0 tail 12 room 4
  18. load:0x40078000,len:15624
  19. ho 0 tail 12 room 4
  20. load:0x40080400,len:4
  21. 0x40080400: _init at ??:?
  22.  
  23. load:0x40080404,len:3876
  24. entry 0x4008064c
  25. I (65) boot: ESP-IDF v5.1.3-416-gd23b7a0361-dirty 2nd stage bootloader
  26. I (65) boot: compile time Apr 23 2024 07:46:47
  27. I (68) boot: Multicore bootloader
  28. I (72) boot: chip revision: v3.1
  29. I (76) boot.esp32: SPI Speed      : 40MHz
  30. I (81) boot.esp32: SPI Mode       : DIO
  31. I (85) boot.esp32: SPI Flash Size : 2MB
  32. W (90) boot.esp32: PRO CPU has been reset by WDT.
  33. W (95) boot.esp32: WDT reset info: PRO CPU PC=0x4000c056
  34. 0x4000c056: xthal_get_ccount in ROM
  35.  
  36. W (101) boot.esp32: WDT reset info: APP CPU PC=0x400d3952
  37. 0x400d3952: panic_handler at /root/esp/esp-idf/components/esp_system/port/panic_handler.c:138 (discriminator 1)
  38.  
  39. I (107) boot: Enabling RNG early entropy source...
  40. I (113) boot: Partition Table:
  41. I (116) boot: ## Label            Usage          Type ST Offset   Length
  42. I (124) boot:  0 nvs              WiFi data        01 02 00009000 00006000
  43. I (131) boot:  1 phy_init         RF data          01 01 0000f000 00001000
  44. I (139) boot:  2 factory          factory app      00 00 00010000 00100000
  45. I (146) boot: End of partition table
  46. I (151) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=2b044h (176196) map
  47. I (223) esp_image: segment 1: paddr=0003b06c vaddr=3ffbdb60 size=04988h ( 18824) load
  48. I (230) esp_image: segment 2: paddr=0003f9fc vaddr=40080000 size=0061ch (  1564) load
  49. I (231) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=a26fch (665340) map
  50. I (477) esp_image: segment 4: paddr=000e2724 vaddr=4008061c size=15814h ( 88084) load
  51. I (525) boot: Loaded app from partition at offset 0x10000
  52. I (525) boot: Disabling RNG early entropy source...
  53. I (537) cpu_start: Multicore app
  54. I (537) cpu_start: Pro cpu up.
  55. I (537) cpu_start: Starting app cpu, entry point is 0x400813f4
  56. 0x400813f4: call_start_cpu1 at /root/esp/esp-idf/components/esp_system/port/cpu_start.c:159
  57.  
  58. I (0) cpu_start: App cpu up.
  59. I (557) cpu_start: Pro cpu start user code
  60. I (557) cpu_start: cpu freq: 160000000 Hz
  61. I (558) cpu_start: Application information:
  62. I (562) cpu_start: Project name:     a2dp_source
  63. I (567) cpu_start: App version:      1
  64. I (572) cpu_start: Compile time:     Apr 23 2024 07:46:52
  65. I (578) cpu_start: ELF file SHA256:  c8def851c5f44aa9...
  66. I (584) cpu_start: ESP-IDF:          v5.1.3-416-gd23b7a0361-dirty
  67. I (591) cpu_start: Min chip rev:     v0.0
  68. I (595) cpu_start: Max chip rev:     v3.99
  69. I (600) cpu_start: Chip rev:         v3.1
  70. I (605) heap_init: Initializing. RAM available for dynamic allocation:
  71. I (612) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
  72. I (618) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
  73. I (624) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
  74. I (631) heap_init: At 3FFCC6D8 len 00013928 (78 KiB): DRAM
  75. I (637) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
  76. I (643) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
  77. I (649) heap_init: At 40095E30 len 0000A1D0 (40 KiB): IRAM
  78. I (657) spi_flash: detected chip: generic
  79. I (660) spi_flash: flash io: dio
  80. W (664) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
  81. I (678) coexist: coex firmware version: d96c1e51f
  82. I (683) app_start: Starting scheduler on CPU0
  83. I (688) app_start: Starting scheduler on CPU1
  84. I (688) main_task: Started on CPU0
  85. I (698) main_task: Calling app_main()
  86. I (718) BTDM_INIT: BT controller compile version [1175e0a]
  87. I (718) BTDM_INIT: Bluetooth MAC: 48:e7:29:a3:b3:ae
  88. I (718) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06

Re: "PRO CPU has been reset by WDT" when using ESP32 bluetooth stack

Posted: Mon Apr 29, 2024 8:59 am
by MicroController

Code: Select all

W (101) boot.esp32: WDT reset info: APP CPU PC=0x400d3952
0x400d3952: panic_handler at /root/esp/esp-idf/components/esp_system/port/panic_handler.c:138 (discriminator 1)
Apparently, there's an exception ("panic") happening which causes the reset. I'm wondering why you don't get a backtrace printed when that happens.

Re: "PRO CPU has been reset by WDT" when using ESP32 bluetooth stack

Posted: Mon Apr 29, 2024 9:03 am
by u_ding
MicroController wrote:
Mon Apr 29, 2024 8:59 am

Code: Select all

W (101) boot.esp32: WDT reset info: APP CPU PC=0x400d3952
0x400d3952: panic_handler at /root/esp/esp-idf/components/esp_system/port/panic_handler.c:138 (discriminator 1)
Apparently, there's an exception ("panic") happening which causes the reset. I'm wondering why you don't get a backtrace printed when that happens.
I also want to know.