Merge pull request #5888 from tannewt/esp_tick_core

Ensure supervisor_tick is run on the same core as CP
This commit is contained in:
Dan Halbert 2022-01-19 19:26:50 -05:00 committed by GitHub
commit 8bae6af12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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_hw_support/include \
-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_pm/include \
-isystem esp-idf/components/esp_ringbuf/include \

View File

@ -77,6 +77,8 @@
#include "esp_debug_helpers.h"
#include "esp_ipc.h"
#ifdef CONFIG_SPIRAM
#include "esp32/spiram.h"
#endif
@ -103,7 +105,7 @@ TaskHandle_t circuitpython_task = NULL;
extern void esp_restart(void) NORETURN;
STATIC void tick_timer_cb(void *arg) {
STATIC void tick_on_cp_core(void *arg) {
supervisor_tick();
// 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);
}
// 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);
safe_mode_t port_init(void) {