Enabling BTDM in ESPADF example - crashes on init

vimalzxc
Posts: 1
Joined: Fri Dec 15, 2023 5:10 pm

Enabling BTDM in ESPADF example - crashes on init

Postby vimalzxc » Fri Dec 15, 2023 5:36 pm

I am trying to run the pipeline_a2dp_source_stream_example on as ESP32_LyraTv4.3 board
The example works fine, able to connect it to a BT classic speaker and play an mp3 file from an sd card
My application requires BLE to coexist with the BT classic a2dp source. So, I enabled BTDM - here is a snippet of the relevant sdkconfig. I moved BT to core 1 as ADF task runs on core 0.

Code: Select all

CONFIG_BT_ENABLED=y
CONFIG_BT_BLUEDROID_PINNED_TO_CORE_1=y
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BTDM_CTRL_MODE_BTDM=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BTDM_CTRL_PINNED_TO_CORE_1=y
# ADF Features
CONFIG_ESP_DISPATCHER_DELEGATE_TASK_CORE=0
Initialization code afer esp adf initializations

Code: Select all

audio_pipeline_handle_t pipeline;
audio_element_handle_t fatfs_stream_reader, bt_stream_writer, mp3_decoder, encoder, ble_stream;
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
    // NVS partition was truncated and needs to be erased
    // Retry nvs_flash_init
    ESP_ERROR_CHECK(nvs_flash_erase());
    err = nvs_flash_init();
}

ESP_LOGI(TAG, "[ 1 ] Mount sdcard");
// Initialize peripherals management
esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG();
esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg);
// Initialize SD Card peripheral
audio_board_sdcard_init(set, SD_MODE_1_LINE);
 ESP_LOGI(TAG, "[ 2 ] Start codec chip");
audio_board_handle_t board_handle = audio_board_init();
audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_DECODE, AUDIO_HAL_CTRL_START);
ESP_LOGI(TAG, "[3.0] Create audio pipeline for playback");
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline = audio_pipeline_init(&pipeline_cfg);
mem_assert(pipeline);
ESP_LOGI(TAG, "[3.1] Create fatfs stream to read data from sdcard");
fatfs_stream_cfg_t fatfs_cfg = FATFS_STREAM_CFG_DEFAULT();
fatfs_cfg.type = AUDIO_STREAM_READER;
 fatfs_stream_reader = fatfs_stream_init(&fatfs_cfg);
ESP_LOGI(TAG, "[3.2] Create mp3 decoder to decode mp3 file");
mp3_decoder_cfg_t mp3_cfg = DEFAULT_MP3_DECODER_CONFIG();
mp3_decoder = mp3_decoder_init(&mp3_cfg);
ESP_LOGI(TAG, "[3.4] Create Bluetooth stream");
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
esp_bt_pin_code_t pin_code = {'1', '2', '3', '4'};
ESP_ERROR_CHECK(esp_bt_controller_init(&bt_cfg));
/*** Modified HERE ****/
ESP_ERROR_CHECK(esp_bt_controller_enable(ESP_BT_MODE_BTDM));	// fails here
ESP_ERROR_CHECK(esp_bluedroid_init());
ESP_ERROR_CHECK(esp_bluedroid_enable());

Crash Log

Code: Select all

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core  1 register dump:
PC      : 0x40119698  PS      : 0x00060530  A0      : 0x80104052  A1      : 0x3ffd7f60  
0x40119698: aes_cipher_msg_auth_code at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/smp/smp_cmac.c:287
A2      : 0x3ffd8000  A3      : 0x3f80a2e4  A4      : 0x0000002e  A5      : 0x00000000  
A6      : 0x3ffc3afc  A7      : 0x00000000  A8      : 0x00000002  A9      : 0x00000001  
A10     : 0x00000001  A11     : 0x00001400  A12     : 0x00000000  A13     : 0x3ffb6608  
A14     : 0x00001400  A15     : 0x00000000  SAR     : 0x00000001  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000024  LBEG    : 0x40093da6  LEND    : 0x40093db1  LCOUNT  : 0x00000000  
0x40093da6: memset at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memset.S:150
0x40093db1: memset at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memset.S:160
Backtrace: 0x40119695:0x3ffd7f60 0x4010404f:0x3ffd7ff0 0x400fda79:0x3ffd8040 0x400fe0c4:0x3ffd8060 0x400ff806:0x3ffd80a0 0x40101349:0x3ffd8120 0x400fc800:0x3ffd8170 0x400fcb37:0x3ffd8190 0x4011ff8f:0x3ffd81b0
0x40119695: aes_cipher_msg_auth_code at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/smp/smp_cmac.c:282
0x4010404f: gatts_calculate_datebase_hash at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/gatt/gatt_sr_hash.c:191
0x400fda79: gatt_update_for_database_change at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/gatt/gatt_api.c:129
0x400fe0c4: GATTS_StartService at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/gatt/gatt_api.c:530
0x400ff806: gatt_profile_db_init at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/gatt/gatt_attr.c:488 (discriminator 3)
0x40101349: gatt_init at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/gatt/gatt_main.c:148
0x400fc800: btu_init_core at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/btu/btu_init.c:102
0x400fcb37: btu_task_start_up at /home/xxx/esp/esp-idf/components/bt/host/bluedroid/stack/btu/btu_task.c:270
0x4011ff8f: osi_thread_run at /home/xxx/esp/esp-idf/components/bt/common/osi/thread.c:165

Who is online

Users browsing this forum: No registered users and 27 guests