File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 7
7
#include "py/runtime.h"
8
8
#include "py/repl.h"
9
9
#include "py/gc.h"
10
+ #include "py/stackctrl.h"
10
11
11
12
#include "lib/fatfs/ff.h"
12
13
#include "lib/fatfs/diskio.h"
@@ -503,6 +504,9 @@ void samd21_init(void) {
503
504
nvm_set_config (& config_nvm );
504
505
}
505
506
507
+ extern uint32_t _estack ;
508
+ extern uint32_t _ebss ;
509
+
506
510
int main (void ) {
507
511
// initialise the cpu and peripherals
508
512
samd21_init ();
@@ -513,6 +517,11 @@ int main(void) {
513
517
// stack between here and where gc_collect is called.
514
518
stack_top = (char * )& stack_dummy ;
515
519
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
+
516
525
// Initialise the local flash filesystem after the gc in case we need to
517
526
// grab memory from it. Create it if needed, mount in on /flash, and set it
518
527
// as current dir.
Original file line number Diff line number Diff line change 100
100
101
101
#define MICROPY_MAKE_POINTER_CALLABLE (p ) ((void*)((mp_uint_t)(p) | 1))
102
102
103
+ #define MICROPY_STACK_CHECK (1)
104
+
103
105
// This port is intended to be 32-bit, but unfortunately, int32_t for
104
106
// different targets may be defined in different ways - either as int
105
107
// or as long. This requires different printf formatting specifiers
You can’t perform that action at this time.
0 commit comments