espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.69k stars 7.29k forks source link

ESP32S3 BLE Extended Advertising Does Not Work (IDFGH-12943) #13887

Closed letusgitcommit closed 5 months ago

letusgitcommit commented 5 months ago

Answers checklist.

General issue report

Setup

Windows 11 Powershell 7.4.2 esp-idfv5.2.1 (fresh install retrieved via git as detailed on the release page) esp32s3 devkit c1 Python 3.11.3 Ran export.ps1 to populate appropriate environment

Process

  1. cd into the examples folder into the nimble bleprph folder.
  2. Run idf.py set-target esp32s3
  3. Run menuconfig and enable ble 5 feature extended advertising and go to example configuration and enable extended advertising.
  4. idf.py build flash monitor.
  5. Search for BLE devices.
  6. Cannot find the device advertising.

Log Output

Executing action: monitor
Serial port COM8
Connecting....
Detecting chip type... ESP32-S3
Running idf_monitor in directory ~\esp\esp-idf-v5.2.1\examples\bluetooth\nimble\bleprph
Executing "~\.espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe ~\esp\esp-idf-v5.2.1\tools/idf_monitor.py -p COM8 -b 115200 --toolchain-prefix xtensa-esp32s3-elf- --target esp32s3 --revision 0 ~\esp\esp-idf-v5.2.1\examples\bluetooth\nimble\bleprph\build\bleprph.elf --force-color -m '~\.espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe' '~\esp\esp-idf-v5.2.1\tools\idf.py'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM8 instead...
--- esp-idf-monitor 1.4.0 on \\.\COM8 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clockESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3810,len:0x178c
load:0x403c9700,len:0x4
load:0x403c9704,len:0xcbc
load:0x403cc700,len:0x2da0
entry 0x403c9914
I (27) boot: ESP-IDF v5.2.1 2nd stage bootloader
I (27) boot: compile time May 31 2024 14:15:57
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label            Usage          Type ST Offset   Length
I (64) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c060020 size=1d0b8h (118968) map
I (121) esp_image: segment 1: paddr=0002d0e0 vaddr=3fc98600 size=02f38h ( 12088) load
I (123) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=5bbe8h (375784) map
I (194) esp_image: segment 3: paddr=0008bc10 vaddr=3fc9b538 size=011d0h (  4560) load
I (195) esp_image: segment 4: paddr=0008cde8 vaddr=40374000 size=14540h ( 83264) load
I (226) boot: Loaded app from partition at offset 0x10000
I (226) boot: Disabling RNG early entropy source...
I (238) cpu_start: Multicore app
I (247) cpu_start: Pro cpu start user code
I (247) cpu_start: cpu freq: 160000000 Hz
I (247) cpu_start: Application information:
I (250) cpu_start: Project name:     bleprph
I (255) cpu_start: App version:      v5.2.1
I (260) cpu_start: Compile time:     May 31 2024 14:15:20
I (266) cpu_start: ELF file SHA256:  0f59344cd...
I (272) cpu_start: ESP-IDF:          v5.2.1
I (276) cpu_start: Min chip rev:     v0.0
I (281) cpu_start: Max chip rev:     v0.99
I (286) cpu_start: Chip rev:         v0.2
I (291) heap_init: Initializing. RAM available for dynamic allocation:
I (298) heap_init: At 3FC9EE68 len 0004A8A8 (298 KiB): RAM
I (304) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (310) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (316) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (323) spi_flash: detected chip: gd
I (327) spi_flash: flash io: dio
W (331) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (344) sleep: Configure to isolate all GPIO pins in sleep state
I (351) sleep: Enable automatic switching of GPIO sleep configuration
I (358) coexist: coex firmware version: 77cd7f8
I (363) coexist: coexist rom version e7ae62f
I (368) main_task: Started on CPU0
I (378) main_task: Calling app_main()
I (388) BLE_INIT: BT controller compile version [30b57c4]
I (388) BLE_INIT: Bluetooth MAC: 48:27:e2:f0:22:ba
I (398) phy_init: phy_version 640,cd64a1a,Jan 24 2024,17:28:12
I (438) NimBLE_BLE_PRPH: BLE Host Task Started
I (448) NimBLE: Device Address:
I (448) NimBLE: 48:27:e2:f0:22:ba
I (448) NimBLE:

I (448) NimBLE: GAP procedure initiated: extended advertise; instance=0

I (448) uart: queue free spaces: 8
I (458) main_task: Returned from app_main()

Relevant sdkconfig options

#
# Example Configuration
#
# CONFIG_BLE_SM_IO_CAP_DISP_ONLY is not set
# CONFIG_BLE_SM_IO_CAP_DISP_YES_NO is not set
# CONFIG_BLE_SM_IO_CAP_KEYBOARD_ONLY is not set
CONFIG_BLE_SM_IO_CAP_NO_IO=y
# CONFIG_BLE_SM_IO_CAP_KEYBOARD_DISP is not set
CONFIG_EXAMPLE_IO_TYPE=3
# CONFIG_EXAMPLE_BONDING is not set
# CONFIG_EXAMPLE_MITM is not set
# CONFIG_EXAMPLE_USE_SC is not set
CONFIG_EXAMPLE_EXTENDED_ADV=y
# CONFIG_EXAMPLE_RANDOM_ADDR is not set
# CONFIG_EXAMPLE_ENCRYPTION is not set
# CONFIG_EXAMPLE_RESOLVE_PEER_ADDR is not set
# end of Example Configuration

#
# Bluetooth
#
CONFIG_BT_ENABLED=y
# CONFIG_BT_BLUEDROID_ENABLED is not set
CONFIG_BT_NIMBLE_ENABLED=y
# CONFIG_BT_CONTROLLER_ONLY is not set
CONFIG_BT_CONTROLLER_ENABLED=y
# CONFIG_BT_CONTROLLER_DISABLED is not set

#
# NimBLE Options
#
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y
# CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set
# CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set
# CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set
# CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set
CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y
# CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set
CONFIG_BT_NIMBLE_LOG_LEVEL=1
CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3
CONFIG_BT_NIMBLE_MAX_BONDS=3
CONFIG_BT_NIMBLE_MAX_CCCDS=8
CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0
CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y
# CONFIG_BT_NIMBLE_PINNED_TO_CORE_1 is not set
CONFIG_BT_NIMBLE_PINNED_TO_CORE=0
CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=4096
CONFIG_BT_NIMBLE_ROLE_CENTRAL=y
CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y
CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y
CONFIG_BT_NIMBLE_ROLE_OBSERVER=y
# CONFIG_BT_NIMBLE_NVS_PERSIST is not set
CONFIG_BT_NIMBLE_SECURITY_ENABLE=y
CONFIG_BT_NIMBLE_SM_LEGACY=y
CONFIG_BT_NIMBLE_SM_SC=y
# CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS is not set
CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION=y
CONFIG_BT_NIMBLE_SM_SC_LVL=0
# CONFIG_BT_NIMBLE_DEBUG is not set
# CONFIG_BT_NIMBLE_DYNAMIC_SERVICE is not set
CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="nimble"
CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31
CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=256
CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0

#
# Memory Settings
#
CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT=12
CONFIG_BT_NIMBLE_MSYS_1_BLOCK_SIZE=256
CONFIG_BT_NIMBLE_MSYS_2_BLOCK_COUNT=24
CONFIG_BT_NIMBLE_MSYS_2_BLOCK_SIZE=320
CONFIG_BT_NIMBLE_TRANSPORT_ACL_FROM_LL_COUNT=24
CONFIG_BT_NIMBLE_TRANSPORT_ACL_SIZE=255
CONFIG_BT_NIMBLE_TRANSPORT_EVT_SIZE=70
CONFIG_BT_NIMBLE_TRANSPORT_EVT_COUNT=30
CONFIG_BT_NIMBLE_TRANSPORT_EVT_DISCARD_COUNT=8
# end of Memory Settings

CONFIG_BT_NIMBLE_GATT_MAX_PROCS=4
# CONFIG_BT_NIMBLE_HS_FLOW_CTRL is not set
CONFIG_BT_NIMBLE_RPA_TIMEOUT=900
# CONFIG_BT_NIMBLE_MESH is not set
CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=y
CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS=2000
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=y
CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT=3
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=y
CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY=y
CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY=y
CONFIG_BT_NIMBLE_EXT_ADV=y
CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=1
CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE=1650
CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV=y
CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER=y
CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS=0
# CONFIG_BT_NIMBLE_GATT_CACHING is not set
CONFIG_BT_NIMBLE_WHITELIST_SIZE=12
# CONFIG_BT_NIMBLE_TEST_THROUGHPUT_TEST is not set
# CONFIG_BT_NIMBLE_BLUFI_ENABLE is not set
CONFIG_BT_NIMBLE_USE_ESP_TIMER=y
CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE=y
# CONFIG_BT_NIMBLE_BLE_GATT_BLOB_TRANSFER is not set

#
# GAP Service
#

#
# GAP Appearance write permissions
#
# CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE is not set
# end of GAP Appearance write permissions

CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM=0
CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM_ENC=0
CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM_ATHN=0
CONFIG_BT_NIMBLE_SVC_GAP_APPEAR_WRITE_PERM_ATHR=0
CONFIG_BT_NIMBLE_SVC_GAP_CAR_CHAR_NOT_SUPP=y
# CONFIG_BT_NIMBLE_SVC_GAP_CAR_NOT_SUPP is not set
# CONFIG_BT_NIMBLE_SVC_GAP_CAR_SUPP is not set
CONFIG_BT_NIMBLE_SVC_GAP_CENT_ADDR_RESOLUTION=-1

#
# GAP device name write permissions
#
# CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE is not set
# end of GAP device name write permissions

CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM=0
CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM_ENC=0
CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM_AUTHEN=0
CONFIG_BT_NIMBLE_SVC_GAP_NAME_WRITE_PERM_AUTHOR=0
CONFIG_BT_NIMBLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL=0
CONFIG_BT_NIMBLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL=0
CONFIG_BT_NIMBLE_SVC_GAP_PPCP_SLAVE_LATENCY=0
CONFIG_BT_NIMBLE_SVC_GAP_PPCP_SUPERVISION_TMO=0
# end of GAP Service

#
# BLE Services
#
# CONFIG_BT_NIMBLE_HID_SERVICE is not set
# end of BLE Services

# CONFIG_BT_NIMBLE_VS_SUPPORT is not set
# CONFIG_BT_NIMBLE_HIGH_DUTY_ADV_ITVL is not set
# CONFIG_BT_NIMBLE_HOST_QUEUE_CONG_CHECK is not set

#
# Host-controller Transport
#
CONFIG_UART_PARITY_NONE=y
# CONFIG_UART_PARITY_ODD is not set
# CONFIG_UART_PARITY_EVEN is not set
CONFIG_BT_NIMBLE_TRANSPORT_UART_PARITY_NONE=1
CONFIG_BT_NIMBLE_TRANSPORT_UART_PARITY_ODD=0
CONFIG_BT_NIMBLE_TRANSPORT_UART_PARITY_EVEN=0
CONFIG_UART_HW_FLOWCTRL_DISABLE=y
# CONFIG_UART_HW_FLOWCTRL_CTS_RTS is not set
CONFIG_BT_NIMBLE_HCI_UART_FLOW_CTRL=0
CONFIG_BT_NIMBLE_HCI_UART_RTS_PIN=19
CONFIG_BT_NIMBLE_HCI_UART_CTS_PIN=23
# end of Host-controller Transport
# end of NimBLE Options

#
# Controller Options
#
CONFIG_BT_CTRL_MODE_EFF=1
CONFIG_BT_CTRL_BLE_MAX_ACT=6
CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=6
CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0
CONFIG_BT_CTRL_PINNED_TO_CORE_0=y
# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set
CONFIG_BT_CTRL_PINNED_TO_CORE=0
CONFIG_BT_CTRL_HCI_MODE_VHCI=y
# CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set
CONFIG_BT_CTRL_HCI_TL=1
CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30
CONFIG_BT_BLE_CCA_MODE_NONE=y
# CONFIG_BT_BLE_CCA_MODE_HW is not set
# CONFIG_BT_BLE_CCA_MODE_SW is not set
CONFIG_BT_BLE_CCA_MODE=0
CONFIG_BT_CTRL_HW_CCA_VAL=20
CONFIG_BT_CTRL_HW_CCA_EFF=0
CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y
# CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set
# CONFIG_BT_CTRL_CE_LENGTH_TYPE_SD is not set
CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF=0
CONFIG_BT_CTRL_TX_ANTENNA_INDEX_0=y
# CONFIG_BT_CTRL_TX_ANTENNA_INDEX_1 is not set
CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF=0
CONFIG_BT_CTRL_RX_ANTENNA_INDEX_0=y
# CONFIG_BT_CTRL_RX_ANTENNA_INDEX_1 is not set
CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF=0
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N24 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N21 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N18 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N15 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N12 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N9 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N6 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N3 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N0 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P3 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P6 is not set
CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P9=y
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P12 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P15 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P18 is not set
# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P21 is not set
CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=11
CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y
CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100
CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20
CONFIG_BT_CTRL_BLE_SCAN_DUPL=y
CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE=y
# CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA is not set
# CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE is not set
CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0
CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100
CONFIG_BT_CTRL_DUPL_SCAN_CACHE_REFRESH_PERIOD=0
# CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN is not set
# CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set
CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y
CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0

#
# MODEM SLEEP Options
#
# CONFIG_BT_CTRL_MODEM_SLEEP is not set
# end of MODEM SLEEP Options

CONFIG_BT_CTRL_SLEEP_MODE_EFF=0
CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0
CONFIG_BT_CTRL_HCI_TL_EFF=1
# CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set
# CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX is not set
# CONFIG_BT_BLE_ADV_DATA_LENGTH_ZERO_AUX is not set
# end of Controller Options
# end of Bluetooth

What am I doing wrong here?

rahult-github commented 5 months ago

Hi @letusgitcommit ,

I (448) NimBLE: Device Address: I (448) NimBLE: 48:27:e2:f0:22:ba I (448) NimBLE: I (448) NimBLE: GAP procedure initiated: extended advertise; instance=0 I (448) uart: queue free spaces: 8 I (458) main_task: Returned from app_main()

Logs indicate that extended advertising has been started.

  1. What is the remote device (then central device) being used ?
  2. Does the remote device find other devices which are doing extended advertising ?
  3. Can you try changing remote to say blecent example of s3 and check if it works or not.
letusgitcommit commented 5 months ago

Turns out this was a me issue. Thanks for the response @rahult-github!

I was using the bleak client Python package for Windows 11, but I must be using it wrong (or it doesn't support extended advertising).

Steps to fix:

  1. Build, flash, and monitor the bleprph example with appropriate menuconfig settings (extended advertising, etc.) on esp32s3 device 1.
  2. Build, flash, and monitor the blecent example with appropriate menuconfig settings (extended advertising, etc.) on esp32s3 device 2.

Monitor both esp32s3 devices from the terminal will indicate that they are exchanging information (even if you don't happen to see the exact info).

Thanks again.

rahult-github commented 5 months ago

Hi @letusgitcommit ,

Ok . Thanks for confirming.

(even if you don't happen to see the exact info).

Default log level is at INFO, which prints the operation information only. If more detailed information is needed ( like what was the exact data content that was trasmitted / received ), you can enable the Debug logging mode and check .