espressif / esp-at

AT application for ESP32/ESP32-C2/ESP32-C3/ESP32-C6/ESP8266
Apache License 2.0
890 stars 802 forks source link

BLE server. Connection fail #879

Open tomasMjp opened 6 days ago

tomasMjp commented 6 days ago

Answers checklist

AT+GMR

AT version:3.3.0.0(3b13d04 - ESP32C3 - May 8 2024 08:21:54) SDK version:v5.0.6-dirty compile time(be332568):May 8 2024 08:51:33 Bin version:v3.3.0.0(MINI-1)

ESP-AT Firmware Source

Download from release firmware: https://dl.espressif.com/esp-at/firmwares/esp32c3/ESP32-C3-MINI-1-AT-V3.3.0.0.zip

Hardware Information

ESP32-C3 chip and customized module

Power Supply used

External 3.3V

What is the expected behavior?

Connection should be succesful

What is the actual behavior?

Sometimes after a hardware reset using CHIP_EN pin I can't connect to the ESP32-C3 BLE network. Here I have some videos showing the issue. During this "bug" state the BLE network is detectable but I can't connect, sometimes I can connect but after a few seconds the connection is lost as you can see in the videos. To get out of this state I have to apply another CHIP_EN reset pulse and everything works fine again, I can send and receive data without problems.

https://github.com/user-attachments/assets/947875a9-a2a1-4326-b9d1-e8aefc03c34a

https://github.com/user-attachments/assets/292e8618-c523-4ee9-a5fa-e9e29393e9e8

Probability of recurrence

This is very hard to reproduce, 97% of the times after a CHIP_EN reset I can configure the ESP32-C3 BLE server and connect to it succesfully, but 3% of the times this issue happens.

AT+SYSRAM?

The response to this command has some variability:

Steps to reproduce

  1. Configure BLE server
  2. Start advertising
  3. Connect a client to the server (I'm using an Android 12 phone and the nRF Connect app)
  4. Perform a 50ms reset pulse on CHIP_EN pin

Repeat steps 1 to 4 until step 3 fails.

AT command port output

CHIP_EN goes high
*ESP32-C3 boot logs*
ESP32-C3: ready

MCU: AT+RST
ESP32-C3: AT+RST
ESP32-C3: OK

*ESP32-C3 boot logs*
ESP32-C3: ready

MCU: AT+UART_CUR=115200,8,1,0,3
ESP32-C3: AT+UART_CUR=115200,8,1,0,3
ESP32-C3: OK

MCU: ATE0
ESP32-C3: ATE0
ESP32-C3: OK

MCU: AT+CWMODE?
ESP32-C3: +CWMODE:1
ESP32-C3: OK

MCU: AT+BLEINIT=2
ESP32-C3: OK

MCU: AT+RFPOWER=78,10,10,10
ESP32-C3: OK

MCU: AT+BLENAME="xxxxxx"
ESP32-C3: OK

MCU: AT+BLEGATTSSRVCRE
ESP32-C3: OK

MCU: AT+BLEGATTSSRVSTART
ESP32-C3: OK

MCU: AT+BLEADVPARAM=50,50,0,0,7,0,,
ESP32-C3: OK

MCU: AT+BLEADVDATA="02010617094e657572616c20445350204e616e6f20436f72746578030302a0"
ESP32-C3: OK

MCU: AT+BLESCANRSPDATA="14ffe50201010001eeeeeeee000000000000000000"
ESP32-C3: OK

MCU: AT+BLEADVSTART
ESP32-C3: OK

AT log port output

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x403806a8
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x16a8
load:0x403cc710,len:0x93c
load:0x403ce710,len:0x2eb8
entry 0x403cc710
\x1B[0;32mI (35) boot: ESP-IDF v5.0.6-dirty 2nd stage bootloader\x1B[0m
\x1B[0;32mI (35) boot: compile time 08:51:32\x1B[0m
\x1B[0;32mI (35) boot: chip revision: v0.4\x1B[0m
\x1B[0;32mI (38) boot.esp32c3: SPI Speed      : 40MHz\x1B[0m
\x1B[0;32mI (42) boot.esp32c3: SPI Mode       : DIO\x1B[0m
\x1B[0;32mI (47) boot.esp32c3: SPI Flash Size : 4MB\x1B[0m
\x1B[0;32mI (52) boot: Enabling RNG early entropy source...\x1B[0m
\x1B[0;32mI (57) boot: Partition Table:\x1B[0m
\x1B[0;32mI (61) boot: ## Label            Usage          Type ST Offset   Length\x1B[0m
\x1B[0;32mI (68) boot:  0 otadata          OTA data         01 00 0000d000 00002000\x1B[0m
\x1B[0;32mI (75) boot:  1 phy_init         RF data          01 01 0000f000 00001000\x1B[0m
\x1B[0;32mI (83) boot:  2 nvs              WiFi data        01 02 00010000 0000e000\x1B[0m
\x1B[0;32mI (90) boot:  3 at_customize     unknown          40 00 0001e000 00042000\x1B[0m
\x1B[0;32mI (98) boot:  4 ota_0            OTA app          00 10 00060000 001d0000\x1B[0m
\x1B[0;32mI (105) boot:  5 ota_1            OTA app          00 11 00230000 001d0000\x1B[0m
\x1B[0;32mI (113) boot: End of partition table\x1B[0m
\x1B[0;32mI (117) esp_image: segment 0: paddr=00060020 vaddr=3c160020 size=31a40h (203328) map\x1B[0m
\x1B[0;32mI (168) esp_image: segment 1: paddr=00091a68 vaddr=3fc96200 size=0396ch ( 14700) load\x1B[0m
\x1B[0;32mI (172) esp_image: segment 2: paddr=000953dc vaddr=40380000 size=0ac3ch ( 44092) load\x1B[0m
\x1B[0;32mI (185) esp_image: segment 3: paddr=000a0020 vaddr=42000020 size=15e318h (1434392) map\x1B[0m
\x1B[0;32mI (485) esp_image: segment 4: paddr=001fe340 vaddr=4038ac3c size=0b458h ( 46168) load\x1B[0m
\x1B[0;32mI (497) esp_image: segment 5: paddr=002097a0 vaddr=50000000 size=00018h (    24) load\x1B[0m
\x1B[0;32mI (504) boot: Loaded app from partition at offset 0x60000\x1B[0m
\x1B[0;32mI (504) boot: Disabling RNG early entropy source...\x1B[0m
external 32k oscillator already started.
at param mode: 1

AT cmd port:uart1 tx:7 rx:6 cts:5 rts:4 baudrate:115200
module_name: MINI-1
max tx power=78, ret=0
v3.3.0.0

This is printed after the AT+BLEGATTSSRVCRE command:

attribute[1] len[26]  0,16,0x2800,0x01,2,2,A002
ble attribute[2] 16
ble attribute[3] 2800
ble attribute[4] 01
ble attribute[5] 2
ble attribute[6] 2
ble attribute[7] A002
attribute[2] len[24]  1,16,0x2803,0x01,1,1,02
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 02
attribute[3] len[24]  2,16,0xC300,0x01,1,1,30
ble attribute[2] 16
ble attribute[3] C300
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[4] len[24]  3,16,0x2901,0x11,1,1,30
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 11
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[5] len[24]  4,16,0x2803,0x01,1,1,02
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 02
attribute[6] len[26]  5,16,0xC301,0x01,512,512,
ble attribute[2] 16
ble attribute[3] C301
ble attribute[4] 01
ble attribute[5] 512
ble attribute[6] 512
attribute[7] len[26]  6,16,0x2901,0x11,512,512,
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 11
ble attribute[5] 512
ble attribute[6] 512
attribute[8] len[24]  7,16,0x2803,0x01,1,1,08
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 08
attribute[9] len[24]  8,16,0xC302,0x10,1,1,30
ble attribute[2] 16
ble attribute[3] C302
ble attribute[4] 10
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[10] len[24]  9,16,0x2901,0x01,1,1,01
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 01
attribute[11] len[25]  10,16,0x2803,0x01,1,1,04
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 04
attribute[12] len[25]  11,16,0xC303,0x10,1,1,30
ble attribute[2] 16
ble attribute[3] C303
ble attribute[4] 10
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[13] len[25]  12,16,0x2901,0x10,1,1,30
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 10
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[14] len[25]  13,16,0x2803,0x01,1,1,08
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 08
attribute[15] len[27]  14,16,0xC304,0x10,512,512,
ble attribute[2] 16
ble attribute[3] C304
ble attribute[4] 10
ble attribute[5] 512
ble attribute[6] 512
attribute[16] len[25]  15,16,0x2803,0x01,1,1,10
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 10
attribute[17] len[25]  16,16,0xC305,0x01,1,1,00
ble attribute[2] 16
ble attribute[3] C305
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 00
attribute[18] len[27]  17,16,0x2902,0x11,2,2,0000
ble attribute[2] 16
ble attribute[3] 2902
ble attribute[4] 11
ble attribute[5] 2
ble attribute[6] 2
ble attribute[7] 0000
attribute[19] len[25]  18,16,0x2803,0x01,1,1,20
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 20
attribute[20] len[25]  19,16,0xC306,0x01,1,1,00
ble attribute[2] 16
ble attribute[3] C306
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 00
attribute[21] len[27]  20,16,0x2902,0x11,2,2,0000
ble attribute[2] 16
ble attribute[3] 2902
ble attribute[4] 11
ble attribute[5] 2
ble attribute[6] 2
ble attribute[7] 0000
attribute[22] len[25]  21,16,0x2803,0x01,1,1,02
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 02
attribute[23] len[25]  22,16,0xC307,0x01,1,1,30
ble attribute[2] 16
ble attribute[3] C307
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[24] len[27]  23,16,0x2901,0x11,256,1,30
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 11
ble attribute[5] 256
ble attribute[6] 1
ble attribute[7] 30
attribute[25] len[27]  24,16,0x2800,0x01,2,2,A003
ble attribute[2] 16
ble attribute[3] 2800
ble attribute[4] 01
ble attribute[5] 2
ble attribute[6] 2
ble attribute[7] A003
attribute[2] len[25]  25,16,0x2803,0x01,1,1,02
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 02
attribute[3] len[25]  26,16,0xC400,0x01,1,1,30
ble attribute[2] 16
ble attribute[3] C400
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[4] len[25]  27,16,0x2901,0x11,1,1,30
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 11
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[5] len[25]  28,16,0x2803,0x01,1,1,02
ble attribute[2] 16
ble attribute[3] 2803
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 02
attribute[6] len[25]  29,16,0xC401,0x01,1,1,30
ble attribute[2] 16
ble attribute[3] C401
ble attribute[4] 01
ble attribute[5] 1
ble attribute[6] 1
ble attribute[7] 30
attribute[7] len[27]  30,16,0x2901,0x11,256,1,30
ble attribute[2] 16
ble attribute[3] 2901
ble attribute[4] 11
ble attribute[5] 256
ble attribute[6] 1
ble attribute[7] 30

More Information.

I've noticed a difference on the ESP32-C3 boot logs when the issue occurs and when not.

I don't have a 32k crystal connected, the XTAL_32K_P and XTAL_32K_N pins are unconnected in my PCB. image

Is this issue related?

Luxin812 commented 4 days ago

Hi, could you download the latest firmware from the AT master branch for testing to see if you can reproduce this issue? Thanks.