taks / esp32-nimble

A wrapper for the ESP32 NimBLE Bluetooth stack.
Apache License 2.0
106 stars 32 forks source link

ESP32-C3 crashes when 2nd device connects in `ble_server` example #63

Closed ChocolateLoverRaj closed 8 months ago

ChocolateLoverRaj commented 8 months ago

Steps to reproduce:

Error:

thread '<unnamed>' panicked at examples/ble_server.rs:20:42:
called `Result::unwrap()` on an `Err` value: Operation failed due to resource exhaustion.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

abort() was called at PC 0x4202b1f1 on core 0

Full log (the first part was not included because I reached the terminal max history):

I (43) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (43) boot: compile time Jun  7 2023 07:59:10
I (44) boot: chip revision: v0.4
I (48) boot.esp32c3: SPI Speed      : 40MHz
I (53) boot.esp32c3: SPI Mode       : DIO
I (57) boot.esp32c3: SPI Flash Size : 4MB
I (62) boot: Enabling RNG early entropy source...
I (68) boot: Partition Table:
I (71) boot: ## Label            Usage          Type ST Offset   Length
I (78) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (86) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (93) boot:  2 factory          factory app      00 00 00010000 003f0000
I (101) boot: End of partition table
I (105) esp_image: segment 0: paddr=00010020 vaddr=3c090020 size=2f650h (194128) map
I (156) esp_image: segment 1: paddr=0003f678 vaddr=3fc91200 size=009a0h (  2464) load
I (157) esp_image: segment 2: paddr=00040020 vaddr=42000020 size=8836ch (557932) map
I (284) esp_image: segment 3: paddr=000c8394 vaddr=3fc91ba0 size=01894h (  6292) load
I (286) esp_image: segment 4: paddr=000c9c30 vaddr=40380000 size=11198h ( 70040) load
I (312) boot: Loaded app from partition at offset 0x10000
I (312) boot: Disabling RNG early entropy source...
I (324) cpu_start: Unicore app
I (324) cpu_start: Pro cpu up.
I (333) cpu_start: Pro cpu start user code
I (333) cpu_start: cpu freq: 160000000 Hz
I (333) cpu_start: Application information:
I (336) cpu_start: Project name:     libespidf
I (341) cpu_start: App version:      v0.4.0-25-g75bb3e8-dirty
I (348) cpu_start: Compile time:     Jan  3 2024 13:10:34
I (354) cpu_start: ELF file SHA256:  0000000000000000...
I (360) cpu_start: ESP-IDF:          v5.1.1
I (364) cpu_start: Min chip rev:     v0.3
I (369) cpu_start: Max chip rev:     v0.99 
I (374) cpu_start: Chip rev:         v0.4
I (379) heap_init: Initializing. RAM available for dynamic allocation:
I (386) heap_init: At 3FC95ED0 len 00046840 (282 KiB): DRAM
I (392) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (399) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (406) spi_flash: detected chip: generic
I (410) spi_flash: flash io: dio
W (414) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
W (424) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`
I (433) sleep: Configure to isolate all GPIO pins in sleep state
I (440) sleep: Enable automatic switching of GPIO sleep configuration
I (447) coexist: coex firmware version: 80b0d89
I (452) coexist: coexist rom version 9387209
I (458) app_start: Starting scheduler on CPU0
I (462) main_task: Started on CPU0
I (462) main_task: Calling app_main()
I (472) BLE_INIT: BT controller compile version [963cad4]
I (472) phy_init: phy_version 970,1856f88,May 10 2023,17:44:12
I (522) BLE_INIT: Bluetooth MAC: ec:da:3b:35:6e:1a

I (522) esp32_nimble::ble_device: BLE Host Task Started
I (522) NimBLE: GAP procedure initiated: stop advertising.

I (522) esp32_nimble::ble_device: Device Address: EC:DA:3B:35:6E:1A
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid fafafafa-fafa-fafa-fafa-fafafafafafa
         handle 10
     end_handle 17
characteristic
           uuid d4e0e0d0-1a2b-11e9-ab14-d663bd873d93
     def_handle 11
     val_handle 12
   min_key_size 0
          flags [READ]
characteristic
           uuid a3c87500-8ed3-4bdf-8a39-a01bebede295
     def_handle 13
     val_handle 14
   min_key_size 0
          flags [READ|NOTIFY]
ccc descriptor
           uuid 0x2902
         handle 15
   min_key_size 0
          flags [READ|WRITE]
characteristic
           uuid 3c9a3f00-8ed3-4bdf-8a39-a01bebede295
     def_handle 16
     val_handle 17
   min_key_size 0
          flags [READ|WRITE]
I (652) NimBLE: GAP procedure initiated: advertise; 
I (652) NimBLE: disc_mode=2
I (652) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (662) NimBLE: 

I (1252) ble_server: Client connected
I (1252) NimBLE: GAP procedure initiated: 
I (1252) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (1262) NimBLE: 

I (1272) ble_server: Multi-connect support: start advertising
I (1272) NimBLE: GAP procedure initiated: advertise; 
I (1282) NimBLE: disc_mode=2
I (1282) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (1292) NimBLE: 

I (2472) ble_server: Client disconnected (205)
I (3392) ble_server: Client connected
I (3392) NimBLE: GAP procedure initiated: 
I (3392) NimBLE: connection parameter update; conn_handle=2 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (3402) NimBLE: 

I (3402) ble_server: Multi-connect support: start advertising
I (3412) NimBLE: GAP procedure initiated: advertise; 
I (3412) NimBLE: disc_mode=2
I (3422) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (3432) NimBLE: 

I (4632) ble_server: Client disconnected (205)
I (4742) ble_server: Client connected
I (4742) NimBLE: GAP procedure initiated: 
I (4742) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (4752) NimBLE: 

I (4752) ble_server: Multi-connect support: start advertising
I (4762) NimBLE: GAP procedure initiated: advertise; 
I (4762) NimBLE: disc_mode=2
I (4772) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (4782) NimBLE: 

I (5322) ble_server: Client connected
I (5322) NimBLE: GAP procedure initiated: 
I (5322) NimBLE: connection parameter update; conn_handle=2 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (5332) NimBLE: 

I (5332) ble_server: Multi-connect support: start advertising
I (5342) NimBLE: GAP procedure initiated: advertise; 
I (5342) NimBLE: disc_mode=2
I (5352) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (5362) NimBLE: 

I (5952) ble_server: Client disconnected (205)
I (6282) ble_server: Client connected
I (6282) NimBLE: GAP procedure initiated: 
I (6282) NimBLE: connection parameter update; conn_handle=3 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (6292) NimBLE: 

I (6292) ble_server: Multi-connect support: start advertising
I (6302) NimBLE: GAP procedure initiated: advertise; 
I (6302) NimBLE: disc_mode=2
I (6312) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (6322) NimBLE: 

I (7512) ble_server: Client disconnected (205)
I (7622) ble_server: Client connected
I (7632) NimBLE: GAP procedure initiated: 
I (7632) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (7642) NimBLE: 

I (7642) ble_server: Multi-connect support: start advertising
I (7652) NimBLE: GAP procedure initiated: advertise; 
I (7652) NimBLE: disc_mode=2
I (7662) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (7672) NimBLE: 

I (8832) ble_server: Client disconnected (205)
I (9502) ble_server: Client connected
I (9502) NimBLE: GAP procedure initiated: 
I (9502) NimBLE: connection parameter update; conn_handle=3 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (9512) NimBLE: 

I (9512) ble_server: Multi-connect support: start advertising
I (9522) NimBLE: GAP procedure initiated: advertise; 
I (9532) NimBLE: disc_mode=2
I (9532) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (9542) NimBLE: 

I (9882) ble_server: Client connected
I (9882) NimBLE: GAP procedure initiated: 
I (9882) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (9892) NimBLE: 

I (9892) ble_server: Multi-connect support: start advertising
thread '<unnamed>' panicked at examples/ble_server.rs:20:42:
called `Result::unwrap()` on an `Err` value: Operation failed due to resource exhaustion.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

abort() was called at PC 0x4202b1f1 on core 0
0x4202b1f1 - panic_abort::__rust_start_panic::abort
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort/src/lib.rs:43
Core  0 register dump:
MEPC    : 0x40381666  RA      : 0x4038a49c  SP      : 0x3fca9010  GP      : 0x3fc91a00  
0x40381666 - panic_abort
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/esp_system/panic.c:452
0x4038a49c - __ubsan_include
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/esp_system/ubsan.c:313
0x3fca9010 - vflash_mem
    at ??:??
0x3fc91a00 - coex_schm_ble_mesh_standby_bt_default_wifi_connecting
    at ??:??
TP      : 0x3fc7a6b8  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
0x3fc7a6b8 - esp_system_init_fn_init_components0
    at ??:??
0x37363534 - ??
    at ??:??
0x7271706f - s_rtc_timer_retain_mem
    at ??:??
0x33323130 - ??
    at ??:??
S0/FP   : 0x3fca904c  S1      : 0x3fca9030  A0      : 0x3fca904c  A1      : 0x3fca902e  
0x3fca904c - vflash_mem
    at ??:??
0x3fca9030 - vflash_mem
    at ??:??
0x3fca904c - vflash_mem
    at ??:??
0x3fca902e - vflash_mem
    at ??:??
A2      : 0x00000000  A3      : 0x3fca9079  A4      : 0x3fc94656  A5      : 0x3fc9465e  
0x00000000 - ??
    at ??:??
0x3fca9079 - vflash_mem
    at ??:??
0x3fc94656 - s_temperature_sensor_power_cnt
    at ??:??
0x3fc9465e - s_phy_digital_regs_mem
    at ??:??
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x3c09417c  S3      : 0x3fca9140  
0x7a797877 - s_rtc_timer_retain_mem
    at ??:??
0x76757473 - s_rtc_timer_retain_mem
    at ??:??
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x3fca9140 - vflash_mem
    at ??:??
S4      : 0x00000001  S5      : 0x00000000  S6      : 0x00000001  S7      : 0x00000000  
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
0x6e6d6c6b - s_rtc_timer_retain_mem
    at ??:??
0x6a696867 - s_rtc_timer_retain_mem
    at ??:??
0x66656463 - s_rtc_timer_retain_mem
    at ??:??
0x62613938 - s_rtc_timer_retain_mem
    at ??:??
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
0x00001801 - ??
    at ??:??
0x40380001 - _vector_table
    at ??:??
0x00000007 - ??
    at ??:??
0x00000000 - ??
    at ??:??
MHARTID : 0x00000000  
0x00000000 - ??
    at ??:??

Stack memory:
3fca9010: 0x00000004 0x00000000 0x3fca902c 0x4038fa20 0x00000000 0x00000000 0x3fca9e0c 0x40380030
0x00000004 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca902c - vflash_mem
    at ??:??
0x4038fa20 - __assert_func
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/newlib/assert.c:34
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca9e0c - vflash_mem
    at ??:??
0x40380030 - _vector_table
    at ??:??
3fca9030: 0x32303234 0x31663162 0x3fca9e00 0x3fc92948 0x3fca9030 0x3fc92964 0x3fca902c 0x726f6261
0x32303234 - ??
    at ??:??
0x31663162 - ??
    at ??:??
0x3fca9e00 - vflash_mem
    at ??:??
0x3fc92948 - __func__.0
    at ??:??
0x3fca9030 - vflash_mem
    at ??:??
0x3fc92964 - __func__.0
    at ??:??
0x3fca902c - vflash_mem
    at ??:??
0x726f6261 - s_rtc_timer_retain_mem
    at ??:??
3fca9050: 0x20292874 0x20736177 0x6c6c6163 0x61206465 0x43502074 0x34783020 0x62323032 0x20316631
0x20292874 - ??
    at ??:??
0x20736177 - ??
    at ??:??
0x6c6c6163 - s_rtc_timer_retain_mem
    at ??:??
0x61206465 - s_rtc_timer_retain_mem
    at ??:??
0x43502074 - intr_handler_set
    at ??:??
0x34783020 - ??
    at ??:??
0x62323032 - s_rtc_timer_retain_mem
    at ??:??
0x20316631 - ??
    at ??:??
3fca9070: 0x63206e6f 0x2065726f 0x00000030 0x40380000 0x3fca9df0 0x00000000 0x3fc9347c 0x4202b1f4
0x63206e6f - s_rtc_timer_retain_mem
    at ??:??
0x2065726f - ??
    at ??:??
0x00000030 - ??
    at ??:??
0x40380000 - _vector_table
    at ??:??
0x3fca9df0 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc9347c - _ZN3std9panicking4HOOK17h6e4fedcdb04c639dE
    at ??:??
0x4202b1f4 - panic_abort::__rust_start_panic::abort
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/panic_abort/src/lib.rs:43
3fca9090: 0x3c09417c 0x00000000 0x00000000 0x42011aba 0x3fca9ecc 0x000000ac 0x00000000 0x42011668
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x42011aba - std::sys::unix::thread_local_key::get
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/sys/unix/thread_local_key.rs:22
0x3fca9ecc - vflash_mem
    at ??:??
0x000000ac - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x42011668 - std::sys::common::thread_local::os_local::Key<T>::get
    at ??:??
3fca90b0: 0x3c09417c 0x00000000 0x3fc9347c 0x42025bd4 0x3c09417c 0x00000000 0x3fc9347c 0x42024e3c
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc9347c - _ZN3std9panicking4HOOK17h6e4fedcdb04c639dE
    at ??:??
0x42025bd4 - std::thread::local::LocalKey<T>::try_with
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/thread/local.rs:269
0x3c09417c - anon.9c971a9f34cefc91940349831abdaa93.65.llvm.1902461694989214552
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc9347c - _ZN3std9panicking4HOOK17h6e4fedcdb04c639dE
    at ??:??
0x42024e3c - std::panicking::rust_panic_with_hook
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/panicking.rs:753
3fca90d0: 0x00000000 0x00000000 0x3fca8360 0x4038aaea 0x3fca9144 0x3c09b2c0 0x3fca91b8 0x3c09027c
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038aaea - xQueueGenericSend
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:908
0x3fca9144 - vflash_mem
    at ??:??
0x3c09b2c0 - anon.a0b825c23b6c5bceab56088a2140e816.75.llvm.4102161038622529759
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
3fca90f0: 0x00000001 0x00000000 0x3fca8360 0x4038b208 0x00000000 0x00000000 0x00000000 0x3fc94a88
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038b208 - xQueueTakeMutexRecursive
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:788
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc94a88 - ble_gap_slave
    at ??:??
3fca9110: 0x00000000 0x3fca93bc 0x3fca8360 0x4038ac9c 0x00000000 0x00000000 0x00000000 0x3fca92bc
0x00000000 - ??
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038ac9c - xQueueGiveMutexRecursive
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:737
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca92bc - vflash_mem
    at ??:??
3fca9130: 0x3c09027c 0x3fca9188 0x3fca91b8 0x42007ab8 0x3fca91b8 0x3fca9ecc 0x000000ac 0x00000059
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3fca9188 - vflash_mem
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x42007ab8 - std::panicking::begin_panic_handler::{{closure}}
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x3fca9ecc - vflash_mem
    at ??:??
0x000000ac - ??
    at ??:??
0x00000059 - ??
    at ??:??
3fca9150: 0x3c09027c 0x3fca91b8 0x3fca9188 0x4200791a 0x3fca91b8 0x3fca9188 0x3c09027c 0x15000016
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3fca91b8 - vflash_mem
    at ??:??
0x3fca9188 - vflash_mem
    at ??:??
0x4200791a - std::sys_common::backtrace::__rust_end_short_backtrace
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:173
0x3fca91b8 - vflash_mem
    at ??:??
0x3fca9188 - vflash_mem
    at ??:??
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x15000016 - ??
    at ??:??
3fca9170: 0x3fc9138c 0x3fc91354 0x00000001 0x4203aa1c 0x00000013 0x00000000 0x3c0a5684 0x3c0a5728
0x3fc9138c - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x3fc91354 - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x00000001 - ??
    at ??:??
0x4203aa1c - core::panicking::panic_fmt
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/panicking.rs:72
0x00000013 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3c0a5684 - anon.eafa7363aa718ec270aba380d2bec196.62.llvm.3332932360389494246
    at ??:??
0x3c0a5728 - anon.eafa7363aa718ec270aba380d2bec196.89.llvm.3332932360389494246
    at ??:??
3fca9190: 0x3fca91b8 0x3c09027c 0x3fc90001 0x42004390 0x00000000 0x00000000 0x3c0901b1 0x0000002b
0x3fca91b8 - vflash_mem
    at ??:??
0x3c09027c - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3fc90001 - esp_system_init_fn_init_components0
    at ??:??
0x42004390 - esp32_nimble::server::ble_advertising::BLEAdvertising::start_with_duration
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3c0901b1 - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x0000002b - ??
    at ??:??
3fca91b0: 0x3fca91ec 0x3c0901dc 0x3c0a58dc 0x00000002 0x3fca91d0 0x00000002 0x00000000 0x00000000
0x3fca91ec - vflash_mem
    at ??:??
0x3c0901dc - anon.ce3590d354e7fbd03284a7c578f01efc.3.llvm.17525416276404507567
    at ??:??
0x3c0a58dc - anon.eafa7363aa718ec270aba380d2bec196.89.llvm.3332932360389494246
    at ??:??
0x00000002 - ??
    at ??:??
0x3fca91d0 - vflash_mem
    at ??:??
0x00000002 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca91d0: 0x3fca91a8 0x42038364 0x3fca91b0 0x4203835c 0x3fc9138c 0x3fc91354 0x00000001 0x00000006
0x3fca91a8 - vflash_mem
    at ??:??
0x42038364 - <&T as core::fmt::Display>::fmt
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:2288
0x3fca91b0 - vflash_mem
    at ??:??
0x4203835c - <&T as core::fmt::Debug>::fmt
    at /var/home/rajas/.rustup/toolchains/esp/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:2288
0x3fc9138c - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x3fc91354 - _ZN12esp32_nimble10ble_device10BLE_SERVER17h83a3f9c90a55bdeeE
    at ??:??
0x00000001 - ??
    at ??:??
0x00000006 - ??
    at ??:??
3fca91f0: 0x3fca96a0 0x00000000 0x3fca8360 0x4038a558 0x00000000 0x00000000 0x3fca8360 0x4038aaea
0x3fca96a0 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038a558 - prvCopyDataToQueue
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:2415
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca8360 - vflash_mem
    at ??:??
0x4038aaea - xQueueGenericSend
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/freertos/FreeRTOS-Kernel/queue.c:908
3fca9210: 0x00000001 0xfff00000 0x00000000 0x356e1a00 0x00ecda3b 0xc58895ae 0x1a004851 0xda3b356e
0x00000001 - ??
    at ??:??
0xfff00000 - s_rtc_timer_retain_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x356e1a00 - ??
    at ??:??
0x00ecda3b - ??
    at ??:??
0xc58895ae - s_rtc_timer_retain_mem
    at ??:??
0x1a004851 - ??
    at ??:??
0xda3b356e - s_rtc_timer_retain_mem
    at ??:??
3fca9230: 0x95ae00ec 0x4851c588 0x00300001 0x003c0000 0x3fca0101 0x3fca93bc 0x00000000 0x00000000
0x95ae00ec - s_rtc_timer_retain_mem
    at ??:??
0x4851c588 - intr_handler_set
    at ??:??
0x00300001 - ??
    at ??:??
0x003c0000 - ??
    at ??:??
0x3fca0101 - vflash_mem
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca9250: 0x356e1a00 0x00ecda3b 0xc58895ae 0x1a004851 0xda3b356e 0x95ae00ec 0x4851c588 0x00300001
0x356e1a00 - ??
    at ??:??
0x00ecda3b - ??
    at ??:??
0xc58895ae - s_rtc_timer_retain_mem
    at ??:??
0x1a004851 - ??
    at ??:??
0xda3b356e - s_rtc_timer_retain_mem
    at ??:??
0x95ae00ec - s_rtc_timer_retain_mem
    at ??:??
0x4851c588 - intr_handler_set
    at ??:??
0x00300001 - ??
    at ??:??
3fca9270: 0x003c0000 0x3fca0101 0x3fc913a8 0x00000000 0x00000001 0x3fca9310 0x3fc958c0 0x4205147c
0x003c0000 - ??
    at ??:??
0x3fca0101 - vflash_mem
    at ??:??
0x3fc913a8 - _ZN12esp32_nimble10ble_device15BLE_ADVERTISING17h728d982ebf14b211E.llvm.9177407296607108776
    at ??:??
0x00000000 - ??
    at ??:??
0x00000001 - ??
    at ??:??
0x3fca9310 - vflash_mem
    at ??:??
0x3fc958c0 - ble_hs_conn_elem_mem
    at ??:??
0x4205147c - ble_gap_rd_rem_sup_feat_tx
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_gap.c:1975
3fca9290: 0x420544b0 0x48400000 0x3fca9338 0x3fca9329 0x00000000 0x00000000 0x00000000 0x00000000
0x420544b0 - ble_gatts_chr_def_access
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_gatts.c:243
0x48400000 - intr_handler_set
    at ??:??
0x3fca9338 - vflash_mem
    at ??:??
0x3fca9329 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca92b0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000001 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca92d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca92f0: 0x3fca6420 0x00000000 0x00000000 0x3fc945ec 0x3fc945e8 0x3fc945fc 0x3fca5862 0x4204d9fc
0x3fca6420 - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fc945ec - g_eventq_dflt
    at ??:??
0x3fc945e8 - ble_hs_ev_stop
    at ??:??
0x3fc945fc - npl_funcs
    at ??:??
0x3fca5862 - vflash_mem
    at ??:??
0x4204d9fc - ble_hs_hci_evt_le_enh_conn_complete
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:469
3fca9310: 0x00010000 0x95ae0001 0x4851c588 0x00000030 0x0001003c 0x00000000 0x00000000 0x00000000
0x00010000 - ??
    at ??:??
0x95ae0001 - s_rtc_timer_retain_mem
    at ??:??
0x4851c588 - intr_handler_set
    at ??:??
0x00000030 - ??
    at ??:??
0x0001003c - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca9330: 0x3fc945fc 0x3fca5860 0x3fca5860 0x4204db16 0x3fc945e8 0x3fc945fc 0x3fc94870 0x40382d00
0x3fc945fc - npl_funcs
    at ??:??
0x3fca5860 - vflash_mem
    at ??:??
0x3fca5860 - vflash_mem
    at ??:??
0x4204db16 - ble_hs_hci_evt_process
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/nimble/host/src/ble_hs_hci_evt.c:1023
0x3fc945e8 - ble_hs_ev_stop
    at ??:??
0x3fc945fc - npl_funcs
    at ??:??
0x3fc94870 - ble_hs_hci_os_event_buf
    at ??:??
0x40382d00 - nimble_port_run
    at /var/home/rajas/Documents/esp32-nimble/.embuild/espressif/esp-idf/v5.1.1/components/bt/host/nimble/nimble/porting/nimble/src/nimble_port.c:256
3fca9350: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x42005c3e
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x42005c3e - esp32_nimble::ble_device::BLEDevice::blecent_host_task
    at /var/home/rajas/Documents/esp32-nimble/src/ble_device.rs:300
3fca9370: 0x3c0929bc 0x00000001 0x3c09288c 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x3c0929bc - str.1.llvm.12882497722226090508
    at ??:??
0x00000001 - ??
    at ??:??
0x3c09288c - str.1.llvm.12882497722226090508
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
3fca9390: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
3fca93b0: 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x3fca8e50 0x3fc95ee4 0x3fc9381c 0x3fc9381c 0x3fca93bc
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0xa5a5a5a5 - s_rtc_timer_retain_mem
    at ??:??
0x00000154 - ??
    at ??:??
0x3fca8e50 - vflash_mem
    at ??:??
0x3fc95ee4 - vflash_mem
    at ??:??
0x3fc9381c - pxReadyTasksLists
    at ??:??
0x3fc9381c - pxReadyTasksLists
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
3fca93d0: 0x3fc93814 0x00000004 0x3fca80c8 0x3fca80c8 0x3fca93bc 0x00000000 0x00000015 0x3fca83b8
0x3fc93814 - pxReadyTasksLists
    at ??:??
0x00000004 - ??
    at ??:??
0x3fca80c8 - vflash_mem
    at ??:??
0x3fca80c8 - vflash_mem
    at ??:??
0x3fca93bc - vflash_mem
    at ??:??
0x00000000 - ??
    at ??:??
0x00000015 - ??
    at ??:??
0x3fca83b8 - vflash_mem
    at ??:??
3fca93f0: 0x626d696e 0x685f656c 0x0074736f 0x00c968d0 0x00000000 0x3fca93b0 0x00000015 0x00000000
0x626d696e - s_rtc_timer_retain_mem
    at ??:??
0x685f656c - s_rtc_timer_retain_mem
    at ??:??
0x0074736f - ??
    at ??:??
0x00c968d0 - ??
    at ??:??
0x00000000 - ??
    at ??:??
0x3fca93b0 - vflash_mem
    at ??:??
0x00000015 - ??
    at ??:??
0x00000000 - ??
    at ??:??

ELF file SHA256: 0000000000000000

Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x40048b82
0x40048b82 - vflash_mem
    at ??:??
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x171c
0x3fcd5820 - vflash_mem
    at ??:??
load:0x403cc710,len:0x968
0x403cc710 - spi_flash_chip_winbond_page_program
    at ??:??
load:0x403ce710,len:0x2f68
0x403ce710 - spi_flash_chip_winbond_page_program
    at ??:??
SHA-256 comparison failed:
Calculated: 1d06b938c0222bf626e0bdf46178b1b37ab24d03f0360fc8fcf7153c2571deaf
Expected: 68d7bdf643ba446b8ed7ae8423241d442fd052b2bc77091100ba06fd65dcf8d5
Attempting to boot anyway...
entry 0x403cc710
0x403cc710 - spi_flash_chip_winbond_page_program
    at ??:??
I (42) boot: ESP-IDF v5.1-beta1-378-gea5e0ff298-dirt 2nd stage bootloader
I (42) boot: compile time Jun  7 2023 07:59:10
I (43) boot: chip revision: v0.4
I (47) boot.esp32c3: SPI Speed      : 40MHz
I (52) boot.esp32c3: SPI Mode       : DIO
I (57) boot.esp32c3: SPI Flash Size : 4MB
I (62) boot: Enabling RNG early entropy source...
I (67) boot: Partition Table:
I (71) boot: ## Label            Usage          Type ST Offset   Length
I (78) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (85) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (93) boot:  2 factory          factory app      00 00 00010000 003f0000
I (100) boot: End of partition table
I (105) esp_image: segment 0: paddr=00010020 vaddr=3c090020 size=2f650h (194128) map
I (156) esp_image: segment 1: paddr=0003f678 vaddr=3fc91200 size=009a0h (  2464) load
I (157) esp_image: segment 2: paddr=00040020 vaddr=42000020 size=8836ch (557932) map
I (283) esp_image: segment 3: paddr=000c8394 vaddr=3fc91ba0 size=01894h (  6292) load
I (285) esp_image: segment 4: paddr=000c9c30 vaddr=40380000 size=11198h ( 70040) load
I (312) boot: Loaded app from partition at offset 0x10000
I (312) boot: Disabling RNG early entropy source...
I (323) cpu_start: Unicore app
I (323) cpu_start: Pro cpu up.
I (332) cpu_start: Pro cpu start user code
I (332) cpu_start: cpu freq: 160000000 Hz
I (333) cpu_start: Application information:
I (335) cpu_start: Project name:     libespidf
I (341) cpu_start: App version:      v0.4.0-25-g75bb3e8-dirty
I (347) cpu_start: Compile time:     Jan  3 2024 13:10:34
I (353) cpu_start: ELF file SHA256:  0000000000000000...
I (359) cpu_start: ESP-IDF:          v5.1.1
I (364) cpu_start: Min chip rev:     v0.3
I (369) cpu_start: Max chip rev:     v0.99 
I (373) cpu_start: Chip rev:         v0.4
I (378) heap_init: Initializing. RAM available for dynamic allocation:
I (386) heap_init: At 3FC95ED0 len 00046840 (282 KiB): DRAM
I (392) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (398) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (406) spi_flash: detected chip: generic
I (409) spi_flash: flash io: dio
W (414) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
W (424) timer_group: legacy driver is deprecated, please migrate to `driver/gptimer.h`
I (433) sleep: Configure to isolate all GPIO pins in sleep state
I (439) sleep: Enable automatic switching of GPIO sleep configuration
I (447) coexist: coex firmware version: 80b0d89
I (452) coexist: coexist rom version 9387209
I (457) app_start: Starting scheduler on CPU0
I (462) main_task: Started on CPU0
I (462) main_task: Calling app_main()
I (472) BLE_INIT: BT controller compile version [963cad4]
I (472) phy_init: phy_version 970,1856f88,May 10 2023,17:44:12
I (522) BLE_INIT: Bluetooth MAC: ec:da:3b:35:6e:1a

I (522) esp32_nimble::ble_device: BLE Host Task Started
I (532) NimBLE: GAP procedure initiated: stop advertising.

I (532) esp32_nimble::ble_device: Device Address: EC:DA:3B:35:6E:1A
primary service
           uuid 0x1800
         handle 1
     end_handle 5
characteristic
           uuid 0x2a00
     def_handle 2
     val_handle 3
   min_key_size 0
          flags [READ]
characteristic
           uuid 0x2a01
     def_handle 4
     val_handle 5
   min_key_size 0
          flags [READ]
primary service
           uuid 0x1801
         handle 6
     end_handle 9
characteristic
           uuid 0x2a05
     def_handle 7
     val_handle 8
   min_key_size 0
          flags [INDICATE]
ccc descriptor
           uuid 0x2902
         handle 9
   min_key_size 0
          flags [READ|WRITE]
primary service
           uuid fafafafa-fafa-fafa-fafa-fafafafafafa
         handle 10
     end_handle 17
characteristic
           uuid d4e0e0d0-1a2b-11e9-ab14-d663bd873d93
     def_handle 11
     val_handle 12
   min_key_size 0
          flags [READ]
characteristic
           uuid a3c87500-8ed3-4bdf-8a39-a01bebede295
     def_handle 13
     val_handle 14
   min_key_size 0
          flags [READ|NOTIFY]
ccc descriptor
           uuid 0x2902
         handle 15
   min_key_size 0
          flags [READ|WRITE]
characteristic
           uuid 3c9a3f00-8ed3-4bdf-8a39-a01bebede295
     def_handle 16
     val_handle 17
   min_key_size 0
          flags [READ|WRITE]
I (652) NimBLE: GAP procedure initiated: advertise; 
I (652) NimBLE: disc_mode=2
I (662) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (672) NimBLE: 

I (732) ble_server: Client connected
I (732) NimBLE: GAP procedure initiated: 
I (732) NimBLE: connection parameter update; conn_handle=1 itvl_min=24 itvl_max=48 latency=0 supervision_timeout=60 min_ce_len=0 max_ce_len=0
I (742) NimBLE: 

I (752) ble_server: Multi-connect support: start advertising
I (762) NimBLE: GAP procedure initiated: advertise; 
I (762) NimBLE: disc_mode=2
I (762) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (772) NimBLE: 
oleander commented 8 months ago

Operation failed due to resource exhaustion.

You likely need to increase maximum number of concurrent connections. The connection count before the crash is 3, try increasing it to 9 using "menuconfig" or by updating the sdkconfig directly.

Also try increasing the stack size to 7000.

ChocolateLoverRaj commented 8 months ago

@oleander thanks for the tip.

I found this option, and I changed the sdkconfig.defaults file and added this:

CONFIG_BT_CONTROLLER_ENABLED=y
CONFIG_BTDM_CTRL_BLE_MAX_CONN=9
CONFIG_BT_NIMBLE_MAX_CONNECTIONS=9

and now I'm able to connect 4 devices (I didn't test with more than that) without the microcontroller crashing. Should I make a PR adding these options?