File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77#include "py/runtime.h"
88#include "py/repl.h"
99#include "py/gc.h"
10+ #include "py/stackctrl.h"
1011
1112#include "lib/fatfs/ff.h"
1213#include "lib/fatfs/diskio.h"
@@ -503,6 +504,9 @@ void samd21_init(void) {
503504 nvm_set_config (& config_nvm );
504505}
505506
507+ extern uint32_t _estack ;
508+ extern uint32_t _ebss ;
509+
506510int main (void ) {
507511 // initialise the cpu and peripherals
508512 samd21_init ();
@@ -513,6 +517,11 @@ int main(void) {
513517 // stack between here and where gc_collect is called.
514518 stack_top = (char * )& stack_dummy ;
515519
520+ // Stack limit should be less than real stack size, so we have a chance
521+ // to recover from limit hit. (Limit is measured in bytes.)
522+ mp_stack_ctrl_init ();
523+ mp_stack_set_limit ((char * )& _estack - (char * )& _ebss - 1024 );
524+
516525 // Initialise the local flash filesystem after the gc in case we need to
517526 // grab memory from it. Create it if needed, mount in on /flash, and set it
518527 // as current dir.
Original file line number Diff line number Diff line change 100100
101101#define MICROPY_MAKE_POINTER_CALLABLE (p ) ((void*)((mp_uint_t)(p) | 1))
102102
103+ #define MICROPY_STACK_CHECK (1)
104+
103105// This port is intended to be 32-bit, but unfortunately, int32_t for
104106// different targets may be defined in different ways - either as int
105107// or as long. This requires different printf formatting specifiers
You can’t perform that action at this time.
0 commit comments