logo elektroda
logo elektroda
X
logo elektroda

ESP32-C3 WiFi Disconnects and Reboots During BT Stack Testing – Debug Log Analysis

DeDaMrAz 150 4
ADVERTISEMENT
  • #1 21846290
    DeDaMrAz
    Level 21  
    Info:MAIN:Rebooting...
    Info:I (36704) wifi:flush txq
    I (36704) wifi:stop sw txq
    I (36714) wifi:lmac stop hw txq
    MAIN:Main_OnWiFiStatusChange - WIFI_STA_DISCONNECTED - 2
    Info:MAIN:WiFi Disconnected
    ESP-ROM:esp32c3-api1-20210207
    Build:Feb  7 2021
    rst:0xc (RTC_SW_CPU_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
    Saved PC:0x403874d6
    SPIWP:0xee
    mode:DIO, clock div:1
    load:0x3fcd5820,len:0x15c4
    load:0x403cbf10,len:0xc84
    load:0x403ce710,len:0x2fd0
    entry 0x403cbf1a
    I (15) boot: ESP-IDF v5.5.2 2nd stage bootloader
    I (15) boot: compile time Feb 23 2026 02:46:51
    I (16) boot: chip revision: v0.4
    I (16) boot: efuse block revision: v1.3
    I (19) boot.esp32c3: SPI Speed      : 80MHz
    I (23) boot.esp32c3: SPI Mode       : DIO
    I (27) boot.esp32c3: SPI Flash Size : 4MB
    I (30) boot: Enabling RNG early entropy source...
    I (35) boot: Partition Table:
    I (38) boot: ## Label            Usage          Type ST Offset   Length
    I (44) boot:  0 otadata          OTA data         01 00 00009000 00002000
    I (50) boot:  1 nvs              WiFi data        01 02 0000b000 00005000
    I (57) boot:  2 app0             OTA app          00 10 00010000 000f0000
    I (63) boot:  3 app1             OTA app          00 11 00100000 000f0000
    I (70) boot:  4 lfs              Unknown data     01 82 001f0000 00010000
    I (76) boot: End of partition table
    I (80) esp_image: segment 0: paddr=00100020 vaddr=3c0a0020 size=24a54h (150100) map
    I (111) esp_image: segment 1: paddr=00124a7c vaddr=3fc94a00 size=03570h ( 13680) load
    I (114) esp_image: segment 2: paddr=00127ff4 vaddr=40380000 size=08024h ( 32804) load
    I (121) esp_image: segment 3: paddr=00130020 vaddr=42000020 size=961f4h (614900) map
    I (220) esp_image: segment 4: paddr=001c621c vaddr=40388024 size=0c89ch ( 51356) load
    I (230) esp_image: segment 5: paddr=001d2ac0 vaddr=50000000 size=00034h (    52) load
    I (237) boot: Loaded app from partition at offset 0x100000
    I (237) boot: Disabling RNG early entropy source...
    I (248) cpu_start: Unicore app
    I (256) cpu_start: GPIO 20 and 21 are used as console UART I/O pins
    I (256) cpu_start: Pro cpu start user code
    I (256) cpu_start: cpu freq: 160000000 Hz
    I (258) app_init: Application information:
    I (262) app_init: Project name:     OpenBeken
    I (266) app_init: App version:      dev_20260223_025831
    I (271) app_init: Compile time:     Feb 23 2026 02:58:50
    I (276) app_init: ELF file SHA256:  2fa82e7b6...
    I (281) app_init: ESP-IDF:          v5.5.2
    I (284) efuse_init: Min chip rev:     v0.3
    I (288) efuse_init: Max chip rev:     v1.99 
    I (292) efuse_init: Chip rev:         v0.4
    I (296) heap_init: Initializing. RAM available for dynamic allocation:
    I (302) heap_init: At 3FCA1530 len 0001EAD0 (122 KiB): RAM
    I (307) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
    I (314) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
    I (320) heap_init: At 50000034 len 00001FB4 (7 KiB): RTCRAM
    I (325) spi_flash: detected chip: generic
    I (329) spi_flash: flash io: dio
    I (332) sleep_gpio: Configure to isolate all GPIO pins in sleep state
    I (338) sleep_gpio: Enable automatic switching of GPIO sleep configuration
    I (356) pm: Frequency switching config: CPU_MAX: 160, APB_MAX: 80, APB_MIN: 40, Light sleep: DISABLED
    I (356) main_task: Started on CPU0
    I (356) main_task: Calling app_main()
    I (356) temperature_sensor: Range [-10°C ~ 80°C], error < 1°C
    BT proxy: ESP-IDF phase1 stub active
    Entering initLog()...
    Commands registered!
    initLog() done!


    Super early tests but I want to test if this is feasible at all an implement it as a BT proxy that can be enabled with a flag for testing proposes. If all the test pass I'll look into adding it to other platforms but since ESP gave me most problems before I am starting with the "biggest" fish first 😁 will update this once some progress is made, stay tuned.

    Added after 2 [hours] 31 [minutes]:

    Browser screenshot showing JSON data with Bluetooth scan results

    Some progress but with a lot of struggle... not sure it is worth it but I'll explore more....

    Added after 33 [minutes]:

    Screenshot of OpenESP32C3_test status page with system info and buttons: Config, Restart, Launch Web Application, About

    Added after 3 [minutes]:

    ESPHome screenshot showing the OpenBeken device page with device info and empty panels.

    Info:MAIN:Time 65, idle 209/s, free 82912, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 66, idle 216/s, free 83040, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 67, idle 216/s, free 82224, MQTT 0(4), bWifi 1, secondsWithNoPing 1, socks 0/0 
    Info:NTP:Seconds since Jan 1 1900 = 3980817267
    Info:NTP:Unix time  : 1771828467 - local Time 2026-02-23 06:34:27
    Info:MAIN:Time 68, idle 218/s, free 82868, MQTT 0(4), bWifi 1, secondsWithNoPing 2, socks 0/0 
    Info:MAIN:Time 69, idle 211/s, free 82868, MQTT 0(4), bWifi 1, secondsWithNoPing 3, socks 0/0 
    Info:DRV:BTProxy: Received API Msg 5 (Len: 0)
    Info:DRV:BTProxy: Handshake -> DisconnectRequest
    Info:DRV:BTProxy: Client disconnected or error
    Info:DRV:BTProxy: Client connected (sock 57)
    Info:DRV:BTProxy: Received API Msg 1 (Len: 29)
    Info:DRV:BTProxy: Handshake -> HelloRequest
    Info:DRV:BTProxy: Received API Msg 3 (Len: 0)
    Info:DRV:BTProxy: Handshake -> ConnectRequest
    Info:DRV:BTProxy: Received API Msg 9 (Len: 0)
    Info:DRV:BTProxy: Handshake -> DeviceInfoRequest
    Info:DRV:BTProxy: Received API Msg 11 (Len: 0)
    Info:DRV:BTProxy: Handshake -> ListEntitiesRequest (Sending Done)
    Info:DRV:BTProxy: Received API Msg 20 (Len: 0)
    Info:DRV:BTProxy: Received API Msg 34 (Len: 0)
    Info:DRV:BTProxy: Received API Msg 38 (Len: 0)
    Info:MAIN:Time 70, idle 231/s, free 83036, MQTT 0(4), bWifi 1, secondsWithNoPing 4, socks 0/0 
    Info:MAIN:Time 71, idle 200/s, free 83036, MQTT 0(4), bWifi 1, secondsWithNoPing 5, socks 0/0 
    Info:MAIN:Time 72, idle 209/s, free 83036, MQTT 0(4), bWifi 1, secondsWithNoPing 6, socks 0/0 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 73, idle 212/s, free 83036, MQTT 0(5), bWifi 1, secondsWithNoPing 7, socks 0/0 
    Info:MAIN:Time 74, idle 219/s, free 82864, MQTT 0(5), bWifi 1, secondsWithNoPing 8, socks 0/0 
    Info:MAIN:Time 75, idle 217/s, free 70720, MQTT 0(5), bWifi 1, secondsWithNoPing 9, socks 0/0


    Weird mashup....

    Added after 1 [hours]:


    Bluetooth network graph: OpenBeken BT Proxy linked to Home Assistant and node “BT Proxy 1”

    Proof of concept is working...


    Since I've been digging through Bluetooth entire night and made this proof of concept work I came to the conclusion that it is a lot of work for somewhat little benefit. Every platform has it's own BT API so no one BTProxy driver is strictly plausible and binaries required are often large so that will most likely exclude 2Mb platforms (not tested - just a guess).

    Overall - not impossible but problematic and cost to benefit ratio is significant so I am going to stop this experiment here unless there is a viable usage case and a need for such a driver. The current device will remain as a test in my setup just to collect data and observe overall stability and behavior.

    Added after 21 [minutes]:

    If anybody is interested in playing around and experimenting more I am attaching latest build I made for ESP32-C3 module
  • ADVERTISEMENT
  • #2 21846584
    insmod
    Level 30  
    This is much more complex than what i've thought of doing.
    But this is better.
    Are you using NimBLE or bluedroid?
  • ADVERTISEMENT
  • #3 21846587
    DeDaMrAz
    Level 21  
    bluedroid as ESPHome was the base and easiest to implement.

    my initial idea was to "restore" BT proxy option to the zigbee gateway with RTL8720D but I started by what I had on the table atm - EPS32-C3.... most issues stem from the different IDF versions and support for BT 4.2 vs BT5 and BLE.... on top of that I had a bug in the docker local build tool so I spent a good amount of time figuring that out - turns out it was my error all along in parsing the partitions.csv.... not proud of that.

    As soon as I find my 8720 dev board I'll try to port it to RTL.
  • ADVERTISEMENT
  • #4 21846591
    insmod
    Level 30  
    Can you push it into some branch on github?
ADVERTISEMENT