Description
When users include both BLE and WiFi in their applications, we get a crash at startup. There is an issue in the BLE repository which details this in full and can be found here:
Digging into this, we find that the final assertion is caused at components/esp32/cpu_start.c
in this code section:
portBASE_TYPE res = xTaskCreatePinnedToCore(&main_task, "main",
ESP_TASK_MAIN_STACK, NULL,
ESP_TASK_MAIN_PRIO, NULL, 0);
assert(res == pdTRUE);
ESP_LOGI(TAG, "Starting scheduler on PRO CPU.");
vTaskStartScheduler();
abort(); /* Only get to here if not enough free heap to start scheduler */
specficially, we fail at the abort()
statement in the last line. When we look at this code, we see that the stack size for main() is based of ESP_TASK_MAIN_STACK
which is a synonym for CONFIG_MAIN_TASK_STACK_SIZE
which is one of our configuration variables. The problem (as I see it) is that the ESP-IDF code is supplied pre-compiled for us and hence we don't have the opportunity to change this setting.
This issue asks for collaboration on finding a solution. It may be as simple as increasing the size of CONFIG_MAIN_TASK_STACK_SIZE
in the build of the ESP-IDF that is distributed with Arduino-ESP32.