diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-03-09 16:09:13 +0100 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-03-09 16:09:13 +0100 |
| commit | fcd60915e2751a30c74b2f620a94ffd273dce386 (patch) | |
| tree | 32f2a3cfdcfb7766f368a57d59c7765f0b0c8df7 /atmel-samd/main.c | |
| parent | 0f78eea5d8059c1dbb3924c19cfa682fc615ab6a (diff) | |
atmel-samd: Turn on stack checking so infinite recursion doesn't completely crash.
Diffstat (limited to 'atmel-samd/main.c')
| -rw-r--r-- | atmel-samd/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 5f99292ec..ad124b58a 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -7,6 +7,7 @@ #include "py/runtime.h" #include "py/repl.h" #include "py/gc.h" +#include "py/stackctrl.h" #include "lib/fatfs/ff.h" #include "lib/fatfs/diskio.h" @@ -503,6 +504,9 @@ void samd21_init(void) { nvm_set_config(&config_nvm); } +extern uint32_t _estack; +extern uint32_t _ebss; + int main(void) { // initialise the cpu and peripherals samd21_init(); @@ -513,6 +517,11 @@ int main(void) { // stack between here and where gc_collect is called. stack_top = (char*)&stack_dummy; + // 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_ctrl_init(); + mp_stack_set_limit((char*)&_estack - (char*)&_ebss - 1024); + // Initialise the local flash filesystem after the gc in case we need to // grab memory from it. Create it if needed, mount in on /flash, and set it // as current dir. |
