I am attempting to run the A2DP_source example code. It did not get this error a couple days ago, after I updated the github repository is seems to no longer get past line 118 in a2dp_source/main/main.c
I don't know this codebase well enough, but logically I would expect esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) would be the same as ESP_OK
// It helps if you attach a picture of your setup/wiring here.
No wires. This is all bluetooth
// If your code is longer than 30 lines, GIST is preferred.
I (52) boot: compile time 02:54:42
I (53) boot: Enabling RNG early entropy source...
I (68) boot: SPI Speed : 80MHz
I (80) boot: SPI Mode : DIO
I (93) boot: SPI Flash Size : 4MB
I (105) boot: Partition Table:
I (116) boot: ## Label Usage Type ST Offset Length
I (139) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (162) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (185) boot: 2 factory factory app 00 00 00010000 00100000
I (209) boot: End of partition table
I (222) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2cdc4 (183748) map
I (579) esp_image: segment 1: paddr=0x0003cdec vaddr=0x3ffbdb60 size=0x03018 ( 12312) load
I (606) esp_image: segment 2: paddr=0x0003fe0c vaddr=0x3ffc0b78 size=0x00000 ( 0) load
I (608) esp_image: segment 3: paddr=0x0003fe14 vaddr=0x40080000 size=0x001fc ( 508) load
0x40080000: _WindowOverflow4 at /Users/stevenelson/esp/esp-idf/components/freertos/xtensa_vectors.S:1685
I (629) esp_image: segment 4: paddr=0x00040018 vaddr=0x400d0018 size=0x9dff8 (647160) map
0x400d0018: _flash_cache_start at ??:?
I (1813) esp_image: segment 5: paddr=0x000de018 vaddr=0x400801fc size=0x00204 ( 516) load
0x400801fc: _Level3Vector at ??:?
I (1816) esp_image: segment 6: paddr=0x000de224 vaddr=0x40080400 size=0x11bbc ( 72636) load
I (1994) esp_image: segment 7: paddr=0x000efde8 vaddr=0x400c0000 size=0x00000 ( 0) load
I (1995) esp_image: segment 8: paddr=0x000efdf0 vaddr=0x50000000 size=0x00000 ( 0) load
I (2080) boot: Loaded app from partition at offset 0x10000
I (2081) boot: Disabling RNG early entropy source...
I (2084) cpu_start: Pro cpu up.
I (2093) cpu_start: Starting app cpu, entry point is 0x4008103c
0x4008103c: call_start_cpu1 at /Users/stevenelson/esp/esp-idf/components/esp32/cpu_start.c:228
I (1) cpu_start: App cpu up.
I (2126) heap_init: Initializing. RAM available for dynamic allocation:
I (2147) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (2166) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (2185) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (2204) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
I (2223) heap_init: At 3FFD0630 len 0000F9D0 (62 KiB): DRAM
I (2242) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (2262) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (2282) heap_init: At 40091FBC len 0000E044 (56 KiB): IRAM
I (2302) cpu_start: Pro cpu start user code
I (94) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (135) BTDM_INIT: BT controller compile version [e5b3752]
I (135) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
E (135) BT_AV: app_main enable controller failed
I outputted these values that are getting hung on line 118 of a2dp_source/main/main.c:
E (145) BT_AV: esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)== 258
E (145) BT_AV: ESP_OK== 0
This seems like there is just a setting somewhere to enable "classic bt" but I can't find it.
make menuconfig
I've gone through menuconfig a few times. It seems correct to me. here are my BT settings in my config, does anything look wrong?
#
#
CONFIG_BT_ENABLED=y
#
#
CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=
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=1
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=1
CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE_0=y
CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE_1=
CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0
CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y
CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4=
Here are a few more BT specific settings:
CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=
CONFIG_BLE_SCAN_DUPLICATE=y
CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR=y
CONFIG_SCAN_DUPLICATE_BY_ADV_DATA=
CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR=
CONFIG_SCAN_DUPLICATE_TYPE=0
CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200
CONFIG_BLE_MESH_SCAN_DUPLICATE_EN=
CONFIG_BLUEDROID_ENABLED=y
CONFIG_BLUEDROID_PINNED_TO_CORE_0=y
CONFIG_BLUEDROID_PINNED_TO_CORE_1=
CONFIG_BLUEDROID_PINNED_TO_CORE=0
CONFIG_BTC_TASK_STACK_SIZE=3072
CONFIG_BLUEDROID_MEM_DEBUG=
CONFIG_CLASSIC_BT_ENABLED=y
CONFIG_A2DP_ENABLE=y
CONFIG_A2DP_SINK_TASK_STACK_SIZE=2048
CONFIG_A2DP_SOURCE_TASK_STACK_SIZE=2048
CONFIG_BT_SPP_ENABLED=
CONFIG_HFP_ENABLE=y
CONFIG_HFP_CLIENT_ENABLE=y
CONFIG_HFP_AUDIO_DATA_PATH_PCM=y
CONFIG_HFP_AUDIO_DATA_PATH_HCI=
CONFIG_GATTS_ENABLE=y
CONFIG_GATTC_ENABLE=y
CONFIG_GATTC_CACHE_NVS_FLASH=
CONFIG_BLE_SMP_ENABLE=y
CONFIG_BT_STACK_NO_LOG=
Solved it. You have to choose BR/EDR ONLY in the menuconfig. I figured dual mode should work, but apparently not.
CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CONTROLLER_MODE_BTDM=
If this is the correct functionality, I'd like to request the wording is changed to something else. The way it looks in the config made me think dual mode would work. Also, it doesn't mentioned "classic mode" in the menuconfig.
@zenmanenergy From your sdkconfig, it looks like it is the older sdkconfig and recently the main.c in a2dp_source is updated. Can you just delete sdkconfig and sdkconfig.old and compile and flash again. That should work.
I'll give that a try now. Maybe I messed something up, but I thought I just copy/pasted the example code from the latest github pull.
No. You didn't mess up anything. With a recent modification, controller is enabled with classic BT option as it is classic BT app. And hence the controller mode in sdkconfig.defaults is also updated to CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY.
The problem here is, you would have compiled the application before the change and hence old sdkconfig would be already present and the same was being used. :-)
I just looked closer at the example code and now I see the sdkconfig.defaults contains: CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y
I bet I changed that when I edited the settings for the serial port. I just started from scratch, only changing the serial port in the config and now it compiles.
So "dual mode" doesn't include classic BT? Is that correct?
I just looked closer at the example code and now I see the sdkconfig.defaults contains: CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y
I bet I changed that when I edited the settings for the serial port. I just started from scratch, only changing the serial port in the config and now it compiles.
Ohh ok. Because the sdkconfig.defaults change is since ee787085f937a582c3b70692f0d19b58cdb2de7d.
Yes. It should work as is (without changing any bluetooth specific options)
So "dual mode" doesn't include classic BT? Is that correct?
It does include BT as well as BLE.
Please close the issue if it is working fine
The problem here was: a2dp_source/main/main.c had a recent change: enable controller with mode CONFIG_BTDM_CONTROLLER_MODE_BTDM changed to mode CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY
Although, in the sdkconfig that was being used to compile the application, the controller mode was CONFIG_BTDM_CONTROLLER_MODE_BTDM. Hence the API esp_bt_controller_enable() detected mode mismatch and hence it returned an error (ESP_ERR_INVALID_ARG = 0x102 = 258)
With the correction/updation of the sdkconfig file, it didn't see any issues
Ok, I'll close this issue.
But, just for a record, this causes the error:
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=
CONFIG_BTDM_CONTROLLER_MODE_BTDM=y
This does not cause the error:
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CONTROLLER_MODE_BTDM=
So what should I do in case I want to use BT Classic in Dual Mode? Or is it just the issue with the name of the configuration?
Also wondering the same thing @OmkarPrabhu08 - I now have a2dp working properly but have lost access to BLE services. Were you able to get dual mode working?
@drewandre as i think you are working on ADF, please go to bluetooth_service.h, change at line number 446, change to esp_bt_controller_enable(ESP_BT_MODE_BTDM)
I had this problem today and thanks to @zenmanenergy comment I could make it work, thanks
Most helpful comment
So what should I do in case I want to use BT Classic in Dual Mode? Or is it just the issue with the name of the configuration?