summaryrefslogtreecommitdiff
path: root/ports/esp32/main.c
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2024-08-06 16:13:33 +1000
committerDamien George <damien@micropython.org>2024-08-14 12:56:46 +1000
commite3955f421d10111271dfb6a2774e742ed01c1d7b (patch)
treeaa04aac6616025285d566cce5244cf250d3c3569 /ports/esp32/main.c
parent86f2c285eb222f30c24df187ac66d3e0c80caf61 (diff)
esp32: Fix thread stack limit margin, change to new cstack API.
This change moves that complexity out into the stack checker and fixes the bug where stack margin wasn't set correctly by ESP32-C3 threads. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'ports/esp32/main.c')
-rw-r--r--ports/esp32/main.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/ports/esp32/main.c b/ports/esp32/main.c
index ccec6c8cd..ea641e668 100644
--- a/ports/esp32/main.c
+++ b/ports/esp32/main.c
@@ -41,7 +41,7 @@
#include "esp_log.h"
#include "esp_psram.h"
-#include "py/stackctrl.h"
+#include "py/cstack.h"
#include "py/nlr.h"
#include "py/compile.h"
#include "py/runtime.h"
@@ -71,13 +71,6 @@
// MicroPython runs as a task under FreeRTOS
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
-// Set the margin for detecting stack overflow, depending on the CPU architecture.
-#if CONFIG_IDF_TARGET_ESP32C3
-#define MP_TASK_STACK_LIMIT_MARGIN (2048)
-#else
-#define MP_TASK_STACK_LIMIT_MARGIN (1024)
-#endif
-
typedef struct _native_code_node_t {
struct _native_code_node_t *next;
uint32_t data[];
@@ -132,8 +125,7 @@ void mp_task(void *pvParameter) {
soft_reset:
// initialise the stack pointer for the main thread
- mp_stack_set_top((void *)sp);
- mp_stack_set_limit(MICROPY_TASK_STACK_SIZE - MP_TASK_STACK_LIMIT_MARGIN);
+ mp_cstack_init_with_top((void *)sp, MICROPY_TASK_STACK_SIZE);
gc_init(mp_task_heap, mp_task_heap + MICROPY_GC_INITIAL_HEAP_SIZE);
mp_init();
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib));