Skip to content

ESP32 halts when repeatedly invoking ble.begin() & ble.end() #1711

Closed
@muojp

Description

@muojp

Hardware:

Board: DOIT-ESP32-DevBoard
Core Installation/update date: 31/jul/2018
IDE name: Arduino IDE 1.8.5
Flash Frequency: 80Mhz
Upload Speed: 115200

Description:

I tested SimpleBLE library and found it freezes ESP32 board if you periodically call begin() and end(). On my board, ESP32 halts or reboots at 33rd time of calling begin().

Here are some detail:

  • delay duration (500ms) on the attached sketch is just an example and set for easier issue-repro. I actually tried 500 - 10000 ms and ESP32 crashed in every case.
  • omitting end() seem solving the problem (no freeze at 100+ times of invocation) but I don't think it's a desired solution.
  • changing or keeping advertised identifier on each begin() doesn't affect the test result.
  • ESP32 sometimes reboots after freezing but sometimes just halts.
  • after digging into the ESP-IDF(ref: https://github.com/espressif/esp-idf/tree/aaf12390e) code, I found it seems BTA_EnableBluetooth (bt/bluedroid/bta/dm/bta_dm_api.c) stuck and somehow fails to return future call. I'm not sure whether it is an issue of ESP-IDF or ESP32-Arduino, but filing this issue because it reproduces on simple ESP32-Arduino code.

Sketch:

#include "SimpleBLE.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

SimpleBLE ble;

void setup() {
    Serial.begin(115200);
    Serial.setDebugOutput(true);
}

void loop() {
  for (int i = 0; i < 64; i++) {
    ble.begin("My BLE node");
    Serial.println(String(i));
    delay(500);
    ble.end();
  }
}

Debug Messages:

ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:952
load:0x40078000,len:6084
load:0x40080000,len:7936
entry 0x40080310
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
abort() was called at PC 0x4008a255 on core 0

Backtrace: 0x40090c38:0x3ffdaaf0 0x40090e3b:0x3ffdab10 0x4008a255:0x3ffdab30 0x4008a280:0x3ffdab50 0x4008a3d1:0x3ffdab80 0x4014de6f:0x3ffdaba0 0x40147771:0x3ffdae60 0x401400c1:0x3ffdaeb0 0x40116b73:0x3ffdaee0 0x40111d3a:0x3ffdaf00 0x4012db6e:0x3ffdaf20 0x4010a8b1:0x3ffdaf40 0x40111b36:0x3ffdaf60 0x400ecfe6:0x3ffdaf80

Rebooting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions