From 816074339a5633454795399e5be1d1560f5fb4d3 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 26 Sep 2025 00:42:39 +1000 Subject: [PATCH] nrf/main: Replace mp_stack_set calls with mp_cstack_init_with_top. Signed-off-by: Damien George --- ports/nrf/main.c | 7 +------ ports/nrf/mpconfigport.h | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ports/nrf/main.c b/ports/nrf/main.c index 21a71c7c9e..e5d7828a82 100644 --- a/ports/nrf/main.c +++ b/ports/nrf/main.c @@ -36,7 +36,6 @@ #include "py/parse.h" #include "py/obj.h" #include "py/runtime.h" -#include "py/stackctrl.h" #include "py/gc.h" #include "py/compile.h" #include "py/persistentcode.h" @@ -126,11 +125,7 @@ soft_reset: led_state(1, 1); // MICROPY_HW_LED_1 aka MICROPY_HW_LED_RED - mp_stack_set_top(&_ram_end); - - // Stack limit should be less than real stack size, so we have a chance - // to recover from limit hit. (Limit is measured in bytes.) - mp_stack_set_limit((char *)&_ram_end - (char *)&_heap_end - 400); + mp_cstack_init_with_top(&_ram_end, (char *)&_ram_end - (char *)&_heap_end); machine_init(); diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index d361d01cce..4ad0a2d3d0 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -120,6 +120,7 @@ #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_FINALISER (1) #define MICROPY_STACK_CHECK (1) +#define MICROPY_STACK_CHECK_MARGIN (400) #define MICROPY_HELPER_REPL (1) #define MICROPY_REPL_INFO (1) #define MICROPY_REPL_AUTO_INDENT (1)