From b3a65791b16dcc41281649a0a5faac4e8c00c8e3 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 24 Aug 2016 23:13:11 +0300 Subject: [PATCH] zephyr: Enable stack checking and micropython.mem_info(). --- zephyr/main.c | 4 ++++ zephyr/mpconfigport.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/zephyr/main.c b/zephyr/main.c index 65074b157e..445ef98f4d 100644 --- a/zephyr/main.c +++ b/zephyr/main.c @@ -7,6 +7,7 @@ #include "py/runtime.h" #include "py/repl.h" #include "py/gc.h" +#include "py/stackctrl.h" #include "lib/utils/pyexec.h" void do_str(const char *src, mp_parse_input_kind_t input_kind) { @@ -35,6 +36,9 @@ static char heap[16 * 1024]; int real_main(void) { int stack_dummy; stack_top = (char*)&stack_dummy; + mp_stack_set_top(stack_top); + // Should be set to stack size in prj.mdef minus fuzz factor + mp_stack_set_limit(3584); #if MICROPY_ENABLE_GC gc_init(heap, heap + sizeof(heap)); diff --git a/zephyr/mpconfigport.h b/zephyr/mpconfigport.h index cf5884e0e7..f125ab3993 100644 --- a/zephyr/mpconfigport.h +++ b/zephyr/mpconfigport.h @@ -5,6 +5,7 @@ #define MICROPY_COMP_CONST (0) #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0) +#define MICROPY_STACK_CHECK (1) #define MICROPY_ENABLE_GC (1) #define MICROPY_HELPER_REPL (1) #define MICROPY_REPL_AUTO_INDENT (1) @@ -23,6 +24,7 @@ #define MICROPY_PY_COLLECTIONS (0) #define MICROPY_PY_CMATH (0) #define MICROPY_PY_IO (0) +#define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_STRUCT (0) #define MICROPY_PY_SYS_MODULES (0) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)