Panic from BT stack (Bluedroid)

Moondrop
Posts: 5
Joined: Tue Aug 31, 2021 6:27 pm

Panic from BT stack (Bluedroid)

Postby Moondrop » Sun Oct 16, 2022 8:06 pm

Hi All.
I am encountering a weird behaviour envolving the BT stack. I have application which uses external ADC (SPI + additional control pins), the ADC is being read (in a separate RTOS task) in chunks and passed to the main task which writes the chunks to sdcard (SPI-SDCARD). The application works well when no BT involved, I see the data read from ADC, written to sdcard and no failures happen.
In my application there are 2 ways to start the data measurements:

1) Automatically after waking-up from deepsleep (wakeup trigger is a sensor), always same number of measurements taken
2) Manually via user menu through BT-Serial (Serial Port Profile), In that case bluedroid classic BT + SPP is working, asking the user how many measurements he wants from ADC, the user then sends a number, and the ADC is being read and saved to file.

When I use case (2) I always get a panic for BT stack (in case (1) it never happens). Even if I ask much less measurements then in case (1). I do see that some of the data is being read from ADC and written to file, but after sometime the failure always comes and device restarts.

* The SPP works well, I do see the number that the user is sending from the client terminal, and this number is correctly passed to ADC measuring function. The measuring then starts and after a short time the panic happens

Here is the panic message:
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40105922 PS : 0x00060030 A0 : 0x800e2fb4 A1 : 0x3ffdd210
0x40105922: list_foreach at /home/ben/esp/esp-idf/components/bt/common/osi/list.c:250
A2 : 0xcececece A3 : 0x400e2ec4 A4 : 0x3ffdd230 A5 : 0x3ffdadc0
0x400e2ec4: btm_get_acl_db at /home/ben/esp/esp-idf/components/bt/host/bluedroid/stack/btm/btm_acl.c:97
A6 : 0x00000003 A7 : 0x00060023 A8 : 0x00060023 A9 : 0x3ffdae90
A10 : 0x007befa8 A11 : 0x003fffff A12 : 0x00060020 A13 : 0x00000001
A14 : 0x007bf2f8 A15 : 0x003fffff SAR : 0x00000013 EXCCAUSE: 0x0000001c
EXCVADDR: 0xcececece LBEG : 0x40092664 LEND : 0x40092680 LCOUNT : 0xffffffff
0x40092664: memcpy at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:175
0x40092680: memcpy at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memcpy.S:197

Backtrace: 0x4010591f:0x3ffdd210 0x400e2fb1:0x3ffdd230 0x400ebd50:0x3ffdd270 0x400f03e4:0x3ffdd2a0 0x400f0e47:0x3ffdd2f0 0x40105cab:0x3ffdd310

0x4010591f: list_foreach at /home/ben/esp/esp-idf/components/bt/common/osi/list.c:248 (discriminator 1)
0x400e2fb1: btm_handle_to_acl at /home/ben/esp/esp-idf/components/bt/host/bluedroid/stack/btm/btm_acl.c:169
0x400ebd50: btm_pm_proc_mode_change at /home/ben/esp/esp-idf/components/bt/host/bluedroid/stack/btm/btm_pm.c:766
0x400f03e4: btu_hcif_mode_change_evt at /home/ben/esp/esp-idf/components/bt/host/bluedroid/stack/btu/btu_hcif.c:1580
(inlined by) btu_hcif_process_event at /home/ben/esp/esp-idf/components/bt/host/bluedroid/stack/btu/btu_hcif.c:262
0x400f0e47: btu_hci_msg_process at /home/ben/esp/esp-idf/components/bt/host/bluedroid/stack/btu/btu_task.c:159
0x40105cab: osi_thread_run at /home/ben/esp/esp-idf/components/bt/common/osi/thread.c:165

Here is my related configuration:
CONFIG_BT_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=y
# CONFIG_BT_NIMBLE_ENABLED is not set
# CONFIG_BT_CONTROLLER_ONLY is not set
CONFIG_BT_BTC_TASK_STACK_SIZE=3572
CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0=y
# CONFIG_BT_BLUEDROID_PINNED_TO_CORE_1 is not set
CONFIG_BT_BLUEDROID_PINNED_TO_CORE=0
CONFIG_BT_BTU_TASK_STACK_SIZE=5512
# CONFIG_BT_BLUEDROID_MEM_DEBUG is not set
CONFIG_BT_CLASSIC_ENABLED=y
# CONFIG_BT_A2DP_ENABLE is not set
CONFIG_BT_SPP_ENABLED=y
# CONFIG_BT_HFP_ENABLE is not set
# CONFIG_BT_HID_ENABLED is not set
# CONFIG_BT_SSP_ENABLED is not set
CONFIG_BT_BLE_ENABLED=y
# CONFIG_BT_GATTS_ENABLE is not set
CONFIG_BT_GATTC_ENABLE=y
# CONFIG_BT_GATTC_CACHE_NVS_FLASH is not set
CONFIG_BT_GATTC_CONNECT_RETRY_COUNT=3
# CONFIG_BT_BLE_SMP_ENABLE is not set
# CONFIG_BT_STACK_NO_LOG is not set
CONFIG_BT_ACL_CONNECTIONS=4
# CONFIG_BT_MULTI_CONNECTION_ENBALE is not set
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=y
# CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY is not set
# CONFIG_BT_BLE_HOST_QUEUE_CONG_CHECK is not set
CONFIG_BT_SMP_ENABLE=y
# CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN is not set
CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30
CONFIG_BT_MAX_DEVICE_NAME_LEN=32
# CONFIG_BT_BLE_RPA_SUPPORTED is not set
CONFIG_CLASSIC_BT_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0=y
# CONFIG_BT_BLUEDROID_PINNED_TO_CORE_1 is not set
CONFIG_BT_BLUEDROID_PINNED_TO_CORE=0
# CONFIG_BT_BLUEDROID_MEM_DEBUG is not set
CONFIG_BLUEDROID_ENABLED=y
CONFIG_BLUEDROID_PINNED_TO_CORE_0=y
# CONFIG_BLUEDROID_PINNED_TO_CORE_1 is not set
CONFIG_BLUEDROID_PINNED_TO_CORE=0
# CONFIG_BLUEDROID_MEM_DEBUG is not set

# CONFIG_BTDM_CTRL_MODE_BLE_ONLY is not set
# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set
CONFIG_BTDM_CTRL_MODE_BTDM=y
CONFIG_BTDM_CTRL_BLE_MAX_CONN=3
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN=2
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=0
# CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI is not set
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM=y
CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=1
CONFIG_BTDM_CTRL_PCM_ROLE_EDGE_CONFIG=y
CONFIG_BTDM_CTRL_PCM_ROLE_MASTER=y
# CONFIG_BTDM_CTRL_PCM_ROLE_SLAVE is not set
CONFIG_BTDM_CTRL_PCM_POLAR_FALLING_EDGE=y
# CONFIG_BTDM_CTRL_PCM_POLAR_RISING_EDGE is not set
CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0
CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0
# CONFIG_BTDM_CTRL_AUTO_LATENCY is not set
CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT=y
CONFIG_BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF=y
CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3
CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=2
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0
CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y
# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set
CONFIG_BTDM_CTRL_PINNED_TO_CORE=0
CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y
# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set
CONFIG_BTDM_CTRL_MODEM_SLEEP=y
CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG=y
# CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED is not set
CONFIG_BTDM_CTRL_LPCLK_SEL_MAIN_XTAL=y
CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y
CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1
CONFIG_BTDM_BLE_SCAN_DUPL=y
# CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE is not set
# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set
CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE=y
CONFIG_BTDM_SCAN_DUPL_TYPE=2
CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=100
CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN=y
CONFIG_BTDM_MESH_DUPL_SCAN_CACHE_SIZE=100
CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y
CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y
CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100
CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20
CONFIG_BTDM_RESERVE_DRAM=0xdb5c
CONFIG_BTDM_CTRL_HLI=y
# CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY is not set
# CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY is not set
CONFIG_BTDM_CONTROLLER_MODE_BTDM=y
CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN=3
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN=2
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN=0
CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=3
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=2
CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0
CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0
CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y
# CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 is not set
CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=y
CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: Panic from BT stack (Bluedroid)

Postby ESP_Sprite » Mon Oct 17, 2022 12:15 am

Code: Select all

EXCVADDR: 0xcececece 
Looks like a memory corruption error; that unfortunately is all I can deduce from that dump.

Who is online

Users browsing this forum: snutw_ and 70 guests