I got build error using A2DP-SINK/SOURCE example from ESP-IDF

I have done following below

  1. I have downloaded the latest release ESP-IDF from this link Releases · espressif/esp-idf · GitHub (v4.0.3).
  2. I have created a new PlatformIO project in VSC (framework: “ESP-IDF”, default location).
  3. I copied all files from “main” example(A2DP-Sink or Source) folder to the “src” in VSC folder.
  4. Build the project and got error follow snapshot below

I have tried to download an older version from the ESP-IDF(v3.3.5) and do the same but still got the error also.

How can I solve this?

Additional error snapshot,
2

Why? Per released, and right there in your screenshot, it says PlatformIO uses ESP-IDF of version 4.3.0, your link leads to me 4.0.3. Using that example code might create conflicts because it references things that are not there in the PlatformIO version.

You must copy the sdkconfig.defaults to the project too, delete the old sdkconfig.<board name> file and start the menuconfig. The sdkconfig.defaults activates, when applied, all the needed bluetooth stuff of the example. Otherwise esp_bt.h and friends will for sure not be found.

I don’t understand, the link I gave you that is the ESP-IDF that I want the Bluetooth example code, the version on the PlatformIO 4.3.0, I don’t know where it gets, I only installed the PlatformIO in the extension of VSC.

I follow your instruction but I got error follow snapshot below,

You linked to https://github.com/espressif/esp-idf/releases, showing 4.0.3 at the top. If you got your code form esp-idf/examples/bluetooth/bluedroid/classic_bt/a2dp_sink at v4.3 · espressif/esp-idf · GitHub, all is fine.

Hm that’s not good, it is supposed to regenerate that file there with the defaults… let me take a look.

You are right, regenerating the sdkconfig file doesn’t work like I expected – Regenerate sdkconfig.<board> if missing · Issue #588 · platformio/platform-espressif32 · GitHub is open, because I think it should make sense.

When I first create a blank project, put all the files in it (including the sdkconfig.defaults), but before a sdkconfig file is generated, it works just fine and the settings are applied.

And also compiles fine.

..
RAM:   [=         ]  14.6% (used 47996 bytes from 327680 bytes)
Flash: [=======   ]  69.8% (used 732341 bytes from 1048576 bytes)
Building .pio\build\pico32\firmware.bin
esptool.py v3.1
Merged 1 ELF section
============== [SUCCESS] Took 75.07 seconds ==============

When the project has already been created, one can still go into the menuconfig and apply all settings that would have otherwise been applied by the defaults file, as listed above. Using the “/ = Jump to symbol” command in the menuconfig, one can very easily copy-paste the config macro names (without the CONFIG_) prefix and set them accordingly.

Reference project is at GitHub - maxgerhardt/pio-espidf-a2dpsink: From https://github.com/espressif/esp-idf/tree/v4.3/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main as PIO project.

1 Like

I have downloaded the ESP-IDF v4.3 and start the menuconfig and change the BT_ENABLED(=y)
follow your instruction

For now, it was able to build but I got another errors at the end of the process following message below,

Compiling .pio\build\pico32\bootloader\soc\esp32\touch_sensor_periph.o
Compiling .pio\build\pico32\bootloader\soc\esp32\uart_periph.o
Compiling .pio\build\pico32\bootloader\spi_flash\esp32\spi_flash_rom_patch.o
Archiving .pio\build\pico32\bootloader\esp-idf\micro-ecc\libmicro-ecc.a
Archiving .pio\build\pico32\bootloader\esp-idf\soc\libsoc.a
Archiving .pio\build\pico32\bootloader\esp-idf\spi_flash\libspi_flash.a
Linking .pio\build\pico32\bootloader.elf
Building .pio\build\pico32\bootloader.bin
esptool.py v3.1
Merged 1 ELF section
Linking .pio\build\pico32\firmware.elf
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o:(.literal.bt_av_hdl_a2d_evt+0x44): undefined reference to esp_bt_gap_set_scan_mode' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o:(.literal.bt_av_new_track+0x4): undefined reference to esp_avrc_ct_send_metadata_cmd’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o:(.literal.bt_av_new_track+0x8): undefined reference to esp_avrc_rn_evt_bit_mask_operation' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o:(.literal.bt_av_new_track+0xc): undefined reference to esp_avrc_ct_send_register_notification_cmd’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o:(.literal.volume_set_by_local_host+0x18): undefined reference to esp_avrc_tg_send_rn_rsp' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o:(.literal.bt_av_hdl_avrc_ct_evt+0x1c): undefined reference to esp_avrc_ct_send_get_rn_capabilities_cmd’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o: in function bt_av_hdl_a2d_evt': C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:136: undefined reference to esp_bt_gap_set_scan_mode’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:139: undefined reference to esp_bt_gap_set_scan_mode' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\bt_app_av.o: in function bt_av_new_track’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:184: undefined reference to esp_avrc_ct_send_metadata_cmd' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:189: undefined reference to esp_avrc_rn_evt_bit_mask_operation’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/bt_app_av.c:189: undefined referen
ce to esp_avrc_ct_send_register_notification_cmd' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\bt_app_av.o: in function bt_av_playback_changed’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:209:
undefined reference to esp_avrc_rn_evt_bit_mask_operation' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc uments\PlatformIO\Projects\audio_sink/src/bt_app_av.c:211: undefined referen ce to esp_avrc_ct_send_register_notification_cmd’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32
src\bt_app_av.o: in function bt_av_play_pos_changed': C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:217: undefined reference to esp_avrc_rn_evt_bit_mask_operation’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/bt_app_av.c:219: undefined referen
ce to esp_avrc_ct_send_register_notification_cmd' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\bt_app_av.o: in function volume_set_by_local_host’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:309:
undefined reference to esp_avrc_tg_send_rn_rsp' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\bt_app_av.o: in function bt_av_hdl_avrc_tg_evt’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:355:
undefined reference to esp_avrc_tg_send_rn_rsp' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\bt_app_av.o: in function bt_av_hdl_avrc_ct_evt’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/bt_app_av.c:250:
undefined reference to esp_avrc_ct_send_get_rn_capabilities_cmd' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\main.o:(.literal.bt_av_hdl_stack_evt+0x30): undefined reference to esp_
bt_gap_register_callback’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32
src\main.o:(.literal.bt_av_hdl_stack_evt+0x34): undefined reference to esp_ avrc_ct_init' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\main.o:(.literal.bt_av_hdl_stack_evt+0x38): undefined reference to esp_
avrc_ct_register_callback’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32
src\main.o:(.literal.bt_av_hdl_stack_evt+0x3c): undefined reference to esp_ avrc_tg_init' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\main.o:(.literal.bt_av_hdl_stack_evt+0x40): undefined reference to esp_
avrc_tg_register_callback’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32
src\main.o:(.literal.bt_av_hdl_stack_evt+0x44): undefined reference to esp_ avrc_tg_set_rn_evt_cap' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\main.o:(.literal.bt_av_hdl_stack_evt+0x48): undefined reference to esp_
a2d_register_callback’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32
src\main.o:(.literal.bt_av_hdl_stack_evt+0x4c): undefined reference to esp_ a2d_sink_register_data_callback' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\main.o:(.literal.bt_av_hdl_stack_evt+0x50): undefined reference to esp_
a2d_sink_init’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32
src\main.o:(.literal.app_main+0x34): undefined reference to esp_bt_gap_set_ pin' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\ src\main.o: in function bt_av_hdl_stack_evt’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/main.c:184: unde
fined reference to esp_bt_gap_register_callback' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc uments\PlatformIO\Projects\audio_sink/src/main.c:187: undefined reference to esp_avrc_ct_init’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/main.c:188: undefined reference to
esp_avrc_ct_register_callback' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc uments\PlatformIO\Projects\audio_sink/src/main.c:190: undefined reference to esp_avrc_tg_init’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/main.c:191: undefined reference to
esp_avrc_tg_register_callback' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc uments\PlatformIO\Projects\audio_sink/src/main.c:194: undefined reference to esp_avrc_rn_evt_bit_mask_operation’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/main.c:195: undefined reference to
esp_avrc_tg_set_rn_evt_cap' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc uments\PlatformIO\Projects\audio_sink/src/main.c:198: undefined reference to esp_a2d_register_callback’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/main.c:199: undefined reference to
esp_a2d_sink_register_data_callback' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa -esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc uments\PlatformIO\Projects\audio_sink/src/main.c:200: undefined reference to esp_a2d_sink_init’
c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/…/lib/gcc/xtensa
-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:\Users\Saran\Doc
uments\PlatformIO\Projects\audio_sink/src/main.c:203: undefined reference to
esp_bt_gap_set_scan_mode' c:/users/saran/.platformio/packages/toolchain-xtensa32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\pico32\src\main.o: in function app_main’:
C:\Users\Saran\Documents\PlatformIO\Projects\audio_sink/src/main.c:107: undefined reference to `esp_bt_gap_set_pin’
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\pico32\firmware.elf] Error 1

And what about the other 8 configs mentioned in the sdkconfig.defaults?

1 Like

I change the config to follow the rest of 8 configs, it is work!! Thanks!!!