atmel-samd: Turn on stack checking so infinite recursion doesn't completely crash.

This commit is contained in:
Scott Shawcroft 2017-03-09 16:09:13 +01:00
parent 0f78eea5d8
commit fcd60915e2
2 changed files with 11 additions and 0 deletions

View File

@ -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.

View File

@ -100,6 +100,8 @@
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
#define MICROPY_STACK_CHECK (1)
// This port is intended to be 32-bit, but unfortunately, int32_t for
// different targets may be defined in different ways - either as int
// or as long. This requires different printf formatting specifiers