summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/main.c7
-rw-r--r--ports/stm32/mpconfigport.h1
2 files changed, 3 insertions, 5 deletions
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 0f904a8ba9..e8395013b9 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -515,11 +515,8 @@ soft_reset:
mp_thread_init();
#endif
- // Stack limit should be less than real stack size, so we have a chance
- // to recover from limit hit. (Limit is measured in bytes.)
- // Note: stack control relies on main thread being initialised above
- mp_stack_set_top(&_estack);
- mp_stack_set_limit((char *)&_estack - (char *)&_sstack - 1024);
+ // Stack limit init.
+ mp_cstack_init_with_top(&_estack, (char *)&_estack - (char *)&_sstack);
// GC init
gc_init(MICROPY_HEAP_START, MICROPY_HEAP_END);
diff --git a/ports/stm32/mpconfigport.h b/ports/stm32/mpconfigport.h
index da86fa6416..d1d6fe249b 100644
--- a/ports/stm32/mpconfigport.h
+++ b/ports/stm32/mpconfigport.h
@@ -43,6 +43,7 @@
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
#endif
#endif
+#define MICROPY_STACK_CHECK_MARGIN (1024)
#define MICROPY_ALLOC_PATH_MAX (128)
// optimisations