From 311b8519af75be9fe4215b5ee8f77e91d089d5df Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 19 Aug 2020 10:46:09 +1000 Subject: [PATCH] esp32: Pin MicroPython and NimBLE tasks to core 0. MicroPython and NimBLE must be on the same core, for synchronisation of the BLE ringbuf and the MicroPython scheduler. However, in the current IDF versions (3.3 and 4.0) there are issues (see e.g. #5489) with running NimBLE on core 1. This change - pinning both tasks to core 0 - makes it possible to reliably run the BLE multitests on esp32 boards. --- ports/esp32/boards/sdkconfig.ble | 9 ++++++--- ports/esp32/mphalport.h | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ports/esp32/boards/sdkconfig.ble b/ports/esp32/boards/sdkconfig.ble index cdbb621a63..f714ce4629 100644 --- a/ports/esp32/boards/sdkconfig.ble +++ b/ports/esp32/boards/sdkconfig.ble @@ -9,9 +9,12 @@ CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4 # Pin to the same core as MP. -CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=n -CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y -CONFIG_BT_NIMBLE_PINNED_TO_CORE=1 +# Until we move to IDF 4.2+, we need NimBLE on core 0, and for synchronisation +# with the ringbuffer and scheduler MP needs to be on the same core. +# See https://github.com/micropython/micropython/issues/5489 +CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y +CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=n +CONFIG_BT_NIMBLE_PINNED_TO_CORE=0 # v3.3-only (renamed in 4.0) CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y diff --git a/ports/esp32/mphalport.h b/ports/esp32/mphalport.h index 1f78d820a3..60cc308d68 100644 --- a/ports/esp32/mphalport.h +++ b/ports/esp32/mphalport.h @@ -35,8 +35,11 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" -// The core that the MicroPython task(s) are pinned to -#define MP_TASK_COREID (1) +// The core that the MicroPython task(s) are pinned to. +// Until we move to IDF 4.2+, we need NimBLE on core 0, and for synchronisation +// with the ringbuffer and scheduler MP needs to be on the same core. +// See https://github.com/micropython/micropython/issues/5489 +#define MP_TASK_COREID (0) extern TaskHandle_t mp_main_task_handle;