diff --git a/core/SConscript.firmware b/core/SConscript.firmware index 5ef659e6d..67edd8220 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -282,6 +282,7 @@ SOURCE_MICROPYTHON = [ SOURCE_MICROPYTHON_SPEED = [ 'vendor/micropython/py/gc.c', + 'vendor/micropython/py/pystack.c', 'vendor/micropython/py/vm.c', ] diff --git a/core/embed/firmware/main.c b/core/embed/firmware/main.c index f0448e947..d29e155f0 100644 --- a/core/embed/firmware/main.c +++ b/core/embed/firmware/main.c @@ -97,6 +97,11 @@ int main(void) { mp_stack_set_top(&_estack); mp_stack_set_limit((char *)&_estack - (char *)&_heap_end - 1024); +#if MICROPY_ENABLE_PYSTACK + static mp_obj_t pystack[1024]; + mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]); +#endif + // GC init printf("CORE: Starting GC\n"); gc_init(&_heap_start, &_heap_end); diff --git a/core/embed/firmware/mpconfigport.h b/core/embed/firmware/mpconfigport.h index d92d39353..4c84ce1e7 100644 --- a/core/embed/firmware/mpconfigport.h +++ b/core/embed/firmware/mpconfigport.h @@ -39,6 +39,7 @@ // memory allocation policies #define MICROPY_ALLOC_PATH_MAX (128) +#define MICROPY_ENABLE_PYSTACK (1) // emitters #define MICROPY_PERSISTENT_CODE_LOAD (0) diff --git a/core/embed/unix/main.c b/core/embed/unix/main.c index d1b6f46dc..3b3b1c72d 100644 --- a/core/embed/unix/main.c +++ b/core/embed/unix/main.c @@ -468,6 +468,11 @@ MP_NOINLINE int main_(int argc, char **argv) { gc_init(heap, heap + heap_size); #endif +#if MICROPY_ENABLE_PYSTACK + static mp_obj_t pystack[1024]; + mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]); +#endif + mp_init(); char *home = getenv("HOME"); diff --git a/core/embed/unix/mpconfigport.h b/core/embed/unix/mpconfigport.h index d6bbe6798..26e90ae25 100644 --- a/core/embed/unix/mpconfigport.h +++ b/core/embed/unix/mpconfigport.h @@ -44,6 +44,7 @@ #define MICROPY_ALLOC_PATH_MAX (PATH_MAX) #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) #define MICROPY_MEM_STATS (1) +#define MICROPY_ENABLE_PYSTACK (1) // emitters #define MICROPY_PERSISTENT_CODE_LOAD (0)