[python] Python stack: fix limit

This commit is contained in:
Émilie Feral
2019-12-02 12:13:32 +01:00
committed by Léa Saviot
parent d0a65b01c0
commit d1e93a2918

View File

@@ -101,11 +101,15 @@ extern "C" {
void MicroPython::init(void * heapStart, void * heapEnd) {
#if MP_PORT_USE_STACK_SYMBOLS
mp_stack_set_top(&_stack_start);
mp_stack_set_limit(&_stack_start - &_stack_end);
size_t stackLimitInBytes = (char *)&_stack_start - (char *)&_stack_end;
mp_stack_set_limit(stackLimitInBytes);
#else
volatile int stackTop;
mp_stack_set_top((void *)(&stackTop));
mp_stack_set_limit(8192);
/* The stack limit is set to roughly mimic the maximal recursion depth of the
* device - and actually to be slightly less to be sure not to beat the device
* performance. */
mp_stack_set_limit(29152);
#endif
gc_init(heapStart, heapEnd);
mp_init();