Ensure supervisor_tick is run on the same core as CP

This commit is contained in:
Scott Shawcroft 2022-01-19 11:36:15 -08:00
parent 53b6c4b5f0
commit 78942112c7
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
2 changed files with 16 additions and 1 deletions

View File

@ -94,6 +94,7 @@ INC += \
-isystem esp-idf/components/esp_event/include \ -isystem esp-idf/components/esp_event/include \
-isystem esp-idf/components/esp_hw_support/include \ -isystem esp-idf/components/esp_hw_support/include \
-isystem esp-idf/components/esp_hw_support/include/soc \ -isystem esp-idf/components/esp_hw_support/include/soc \
-isystem esp-idf/components/esp_ipc/include \
-isystem esp-idf/components/esp_netif/include \ -isystem esp-idf/components/esp_netif/include \
-isystem esp-idf/components/esp_pm/include \ -isystem esp-idf/components/esp_pm/include \
-isystem esp-idf/components/esp_ringbuf/include \ -isystem esp-idf/components/esp_ringbuf/include \

View File

@ -77,6 +77,8 @@
#include "esp_debug_helpers.h" #include "esp_debug_helpers.h"
#include "esp_ipc.h"
#ifdef CONFIG_SPIRAM #ifdef CONFIG_SPIRAM
#include "esp32/spiram.h" #include "esp32/spiram.h"
#endif #endif
@ -103,7 +105,7 @@ TaskHandle_t circuitpython_task = NULL;
extern void esp_restart(void) NORETURN; extern void esp_restart(void) NORETURN;
STATIC void tick_timer_cb(void *arg) { STATIC void tick_on_cp_core(void *arg) {
supervisor_tick(); supervisor_tick();
// CircuitPython's VM is run in a separate FreeRTOS task from timer callbacks. So, we have to // CircuitPython's VM is run in a separate FreeRTOS task from timer callbacks. So, we have to
@ -111,6 +113,18 @@ STATIC void tick_timer_cb(void *arg) {
xTaskNotifyGive(circuitpython_task); xTaskNotifyGive(circuitpython_task);
} }
// This function may happen on the PRO core when CP is on the APP core. So, make
// sure we run on the CP core.
STATIC void tick_timer_cb(void *arg) {
#if defined(CONFIG_FREERTOS_UNICORE) && CONFIG_FREERTOS_UNICORE
tick_on_cp_core(arg);
#else
// This only blocks until the start of the function. That's ok since the PRO
// core shouldn't care what we do.
esp_ipc_call(CONFIG_ESP_MAIN_TASK_AFFINITY, tick_on_cp_core, NULL);
#endif
}
void sleep_timer_cb(void *arg); void sleep_timer_cb(void *arg);
safe_mode_t port_init(void) { safe_mode_t port_init(void) {