Skip to content

BLE_INIT: controller init failed error with ESP-IDF and Arduino component #432

Closed

Description

@moritz89

I am running into this crash as soon as I call NimBLEDevice::init("");

It is based on a clean project with Bluetooth and Bluetooth host NimBLE enabled.

Added the compile definition to the main CMakeLists.txt file:

# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
idf_build_set_property(MINIMAL_BUILD ON)
project(NimBLE_GATT_Server)
add_compile_definitions(ARDUINO_ARCH_ESP32=1)

The main.cpp file is:

#include <Arduino.h>
#include <NimBLEDevice.h>

void setup() {
  delay(2000);
  Serial.begin(115200);
  while (!Serial) {
    ;  // wait for serial port to connect
  }
  Serial.println("INIT");
  NimBLEDevice::init("");
}

void loop() {
  Serial.println("loop");
  delay(1000);
}

It does not crash if the setup() and loop() are not called but if "Autostart Arduino setup and loop on boot" is enabled it does.

Activity

  1. moritz89 commented on Jul 30, 2026

    @moritz89
    Author

    One workaround I've found is adding this include at the start of the main.cpp

    #include <esp32-hal-alloc-ble-mem.h>
    
  2. h2zero commented on Jul 31, 2026

    @h2zero
    Owner

    @moritz89 could you provide more information as to your environment setup? This header is already included through:

    # include "esp32-hal-bt.h"

  3. moritz89 commented on Jul 31, 2026

    @moritz89
    Author

    nimble-test.zip

    Here is a minimal example of the crash. Using VS Code and ESP-IDF. Hope it compiles and flashes on your side. Used an ESP32 WROOM dev kit

  4. h2zero commented on Aug 1, 2026

    @h2zero
    Owner

    Thanks, I needed to update the idf version I was using to repro but I have resolved both of your issues in #434

  5. moritz89 commented on Aug 3, 2026

    @moritz89
    Author

    Thanks for the quick turnaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions