Crash with BT and WIFI

bcolbert
Posts: 9
Joined: Mon Jul 05, 2021 7:32 pm

Crash with BT and WIFI

Postby bcolbert » Mon Jul 05, 2021 7:43 pm

Hello,

I have a very small sketch that just enables bluetooth and WiFi. If I include either esp_bluedroid_init or WiFi.mode in the sketch the program crashes. It never reaches the loop() call, as a matter of fact, even with a Serial.print at the beginning of the setup, I never see it the setup print() output. The following repeats on the console:

rst:0x3 (SW_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:1044
load:0x40078000,len:10044
load:0x40080400,len:5900
entry 0x400806ac
ets Jun 8 2016 00:22:57

The code is as follows:

[Codebox]#include "Arduino.h"
#include "esp_bt.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include "esp_gap_bt_api.h"
#include "esp_a2dp_api.h"
#include "esp_avrc_api.h"
#include<WebServer.h>
#include<WiFi.h>

void setup() {
Serial.begin(115200);
Serial.print("Setup!");

//Arduino bluetooth initialization
btStart();

// bluedroid allows for bluetooth classic
esp_bluedroid_init();
esp_bluedroid_enable();

//set up device name
esp_bt_dev_set_device_name("Duh");

// replace ssid and password with your details
const char* ssid = "SomeNetwork";
const char* password = "APassword";
WiFi.mode(WIFI_STA);
while(WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, password);
delay(1000);
Serial.print(".");
}
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}

void loop() {
Serial.println("looop");

delay(5000);
}[/Codebox]

Device: DOIT ESP32 DEVKIT V1 (and Adafruit Huzzah)
Arduino version: 1.8.15
ESP32 SDK version: v3.3.1-61-g367c3c09c

martinius96
Posts: 34
Joined: Thu Dec 13, 2018 1:39 am

Re: Crash with BT and WIFI

Postby martinius96 » Tue Jul 06, 2021 5:19 pm

In my opinion, you CAN'T use Bluetooth and WiFi in same time, because both technologies share same antenna.
You need to switch between Bluetooth and WiFi when you want to use one of them.
There is other thread related to that with more than 7 pages: viewtopic.php?t=6707

bcolbert
Posts: 9
Joined: Mon Jul 05, 2021 7:32 pm

Re: Crash with BT and WIFI

Postby bcolbert » Tue Jul 06, 2021 5:35 pm

I figured out what the problem was. The flash allocation wasn't correct (big enough?). Either way, I was able to fix by modifying the listing for my board in the boards.txt file by adding:

esp32doit-devkit-v1.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
esp32doit-devkit-v1.menu.PartitionScheme.huge_app.build.partitions=huge_app
esp32doit-devkit-v1.menu.PartitionScheme.huge_app.upload.maximum_size=3145728

Who is online

Users browsing this forum: No registered users and 68 guests