8000 Merge branch 'main' into cp_webserver · kevincon/circuitpython@3be3e89 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3be3e89

Browse files
authored
Merge branch 'main' into cp_webserver
2 parents 08c93ad + c3a149c commit 3be3e89

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@
145145
url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git
146146
[submodule "ports/espressif/esp-idf"]
147147
path = ports/espressif/esp-idf
148-
url = https://github.com/espressif/esp-idf.git
149-
branch = release/v4.4
148+
url = https://github.com/adafruit/esp-idf.git
149+
branch = circuitpython8
150150
[submodule "ports/espressif/certificates/nina-fw"]
151151
path = ports/espressif/certificates/nina-fw
152152
url = https://github.com/adafruit/nina-fw.git

ports/espressif/common-hal/microcontroller/__init__.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ volatile uint32_t nesting_count = 0;
6565
static portMUX_TYPE cp_mutex = portMUX_INITIALIZER_UNLOCKED;
6666

6767
void common_hal_mcu_disable_interrupts(void) {
68+
assert(xPortGetCoreID() == CONFIG_ESP_MAIN_TASK_AFFINITY);
6869
if (nesting_count == 0) {
6970
portENTER_CRITICAL(&cp_mutex);
7071
}
7172
nesting_count++;
7273
}
7374

7475
void common_hal_mcu_enable_interrupts(void) {
75-
if (nesting_count == 0) {
76-
// Maybe log here because it's very bad.
77-
}
76+
assert(xPortGetCoreID() == CONFIG_ESP_MAIN_TASK_AFFINITY);
77+
assert(nesting_count > 0);
7878
nesting_count--;
7979
if (nesting_count > 0) {
8080
return;

ports/espressif/common-hal/wifi/__init__.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,25 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
4242

4343
#include "components/log/include/esp_log.h"
4444

45+
#include "supervisor/port.h"
4546
#include "supervisor/workflow.h"
4647

48+
#include "esp_ipc.h"
49+
4750
static const char *TAG = "CP wifi";
4851

52+
STATIC void schedule_background_on_cp_core(void *arg) {
53+
supervisor_workflow_request_background();
54+
55+
// CircuitPython's VM is run in a separate FreeRTOS task from wifi callbacks. So, we have to
56+
// notify the main task every time in case it's waiting for us.
57+
port_wake_main_task();
58+
}
59+
4960
static void event_handler(void *arg, esp_event_base_t event_base,
5061
int32_t event_id, void *event_data) {
62+
// This runs on the PRO CORE! It cannot share CP interrupt enable/disable
63+
// directly.
5164
wifi_radio_obj_t *radio = arg;
5265
if (event_base == WIFI_EVENT) {
5366
switch (event_id) {
@@ -108,7 +121,14 @@ static void event_handler(void *arg, esp_event_base_t event_base,
108121
radio->retries_left = radio->starting_retries;
109122
xEventGroupSetBits(radio->event_group_handle, WIFI_CONNECTED_BIT);
110123
}
111-
supervisor_workflow_request_background();
124+
// Use IPC to ensure we run schedule background on the same core as CircuitPython.
125+
#if defined(CONFIG_FREERTOS_UNICORE) && CONFIG_FREERTOS_UNICORE
126+
schedule_background_on_cp_core(NULL);
127+
#else
128+
// This only blocks until the start of the function. That's ok since the PRO
129+
// core shouldn't care what we do.
130+
esp_ipc_call(CONFIG_ESP_MAIN_TASK_AFFINITY, schedule_background_on_cp_core, NULL);
131+
#endif
112132
}
113133

114134
static bool wifi_inited;

ports/espressif/esp-idf

Submodule esp-idf updated 411 files

0 commit comments

Comments
 (0)
0