Page 1 of 1

BLE and WIFI can't coexist when ESP32 as BLE master?

Posted: Tue Jan 10, 2017 6:14 am
by xzwang
I update my IDF by git pull on master branch. I find that some APIs has changed in esp_gattc_api.h.
I want to make BLE and WIFI coexistence and swap data, So the example 15 and example 03 are what I really want.

Then I modify the example 15 (gattc_demo), and add WIFI function into this demo.
However, esp32 throw an exception that:
***ERROR*** A stack overflow in task

The BLE or WIFI can work correctly if only one is enabled. But I wonder how to make BLE and WIFI coexistence ? And BLE and WIFI can work coexistence before I to the command: git pull.

Re: BLE and WIFI can't coexist when ESP32 as BLE master?

Posted: Tue Jan 10, 2017 6:43 am
by xzwang
I find that the sdkconfig on master branch disabled [Run FreeRTOS only on first core]. So I enable the [Run FreeRTOS only on first core] in menuconfig, the crash disappeared.

Anyone can explain this result? Thanks!

Re: BLE and WIFI can't coexist when ESP32 as BLE master?

Posted: Wed Jan 11, 2017 1:35 am
by ESP_Sprite
That bit of BLE is still somewhat in development for ESP-IDF 2.0; I think we internally ran into the same issue and we have an engineer debugging it.

Re: BLE and WIFI can't coexist when ESP32 as BLE master?

Posted: Thu Feb 23, 2017 3:47 pm
by madscientist_42
Sounds like a resource contention problem. When you're running dual cores, you can have two active threads of execution- under the "right" conditions, you can have something yank the carpet out from underneath you when running FreeRTOS since there's little in the way of protections against both cores clobbering each other.

Not sure if SMP is a good thing unless you've got good locking in the OS for things. Now, if you pinned threads to a given core, gave the differing dependent threads mailbox slotting for communications...might work out nicely.

Re: BLE and WIFI can't coexist when ESP32 as BLE master?

Posted: Sun Feb 26, 2017 6:38 am
by ESP_Sprite
madscientist_42 wrote:Sounds like a resource contention problem. When you're running dual cores, you can have two active threads of execution- under the "right" conditions, you can have something yank the carpet out from underneath you when running FreeRTOS since there's little in the way of protections against both cores clobbering each other.
FYI: FreeRTOS is pre-emptive multitasking; so while you may see the problem earlier on multicore, it's just as easy to run into the same thing in single-core. Thread a reads a variable, freertos switches to thread b, thread b reads, modifies, writes the variable, freertos switches back to thread a, thread a modifies and writes the variable read earlier, and happily undoes thread b's work on the variable. No two cores needed. Unfortunately (or fortunately, depending on how you look at it), doing concurrency right is about as hard on singlecore as it is on SMP.

Re: BLE and WIFI can't coexist when ESP32 as BLE master?

Posted: Mon Feb 27, 2017 2:44 pm
by madscientist_42
ESP_Sprite wrote:
madscientist_42 wrote:Sounds like a resource contention problem. When you're running dual cores, you can have two active threads of execution- under the "right" conditions, you can have something yank the carpet out from underneath you when running FreeRTOS since there's little in the way of protections against both cores clobbering each other.
FYI: FreeRTOS is pre-emptive multitasking; so while you may see the problem earlier on multicore, it's just as easy to run into the same thing in single-core. Thread a reads a variable, freertos switches to thread b, thread b reads, modifies, writes the variable, freertos switches back to thread a, thread a modifies and writes the variable read earlier, and happily undoes thread b's work on the variable. No two cores needed. Unfortunately (or fortunately, depending on how you look at it), doing concurrency right is about as hard on singlecore as it is on SMP.
Very much so. It's the cause of many "ghost in the machine" conditions in embedded code when you're doing multi-threaded stuff.