Arduino-esp32: Initialize BT controller failed with 0x103 ESP_ERR_INVALID_STATE error

Created on 30 Dec 2018  路  5Comments  路  Source: espressif/arduino-esp32

Hardware:

Board: OLIMEX ESP32-GATEWAY
Core Installation/update date: 2018.12.30
IDE name: Sloeber IDE, esp32-arduino master (commit ids: 6dd8be3, 6f6ee98)
Flash Frequency: ?40Mhz?
PSRAM enabled: ?no?
Upload Speed: 115200
Computer OS: Windows 10

Description:

I am trying to implement the ESP-IDF A2DP Source example with the ESP32-arduino library but Igot 0x103 ESP_ERR_INVALID_STATE error.

Sketch:

void setup()
{
  Serial.begin(115200); //start serial for debug
  Serial.println(__func__);
  Serial.println(_firmware_version); //print the firmware version to debug interface
  Serial.println("-------------");
  Serial.println("API Started!");
  Serial.println("-------------");
// Add your initialization code here
  esp_err_t ret = nvs_flash_init();
  if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
      ESP_ERROR_CHECK(nvs_flash_erase());
      ret = nvs_flash_init();
  }

 esp_bt_controller_mem_release(ESP_BT_MODE_BLE);

  esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();

  ret = esp_bt_controller_init(&bt_cfg);
  if (ret != ESP_OK)  //this comes true with ret = 0x103
  {
      Serial.print("In function: ");
      Serial.println(__func__);
      Serial.println("initialize controller failed");
      Serial.println(ret);
      return;
  }

.
.
.
}

What can be the problem?

All 5 comments

Please search through old issues before posting. You cannot release BT memory unless you compile arduino as an ESP-IDF component

Also Arduino already does most of the things that you are calling up there. NVS init and BT release... read this code: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-misc.c#L193-L212

Also Arduino has it's own API to do esp_bt_controller_init! Do not use IDF one

Thank you very much for the guidance. Now everything works like a charm!

great! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamwilt picture adamwilt  路  63Comments

tablatronix picture tablatronix  路  72Comments

gaurav0190 picture gaurav0190  路  55Comments

PhilColbert picture PhilColbert  路  125Comments

dsyleixa picture dsyleixa  路  65Comments