I wanted to use the micropython as an embedded lib. I managed to build a ESP32 port of MP into a static .a file and linked it to my ESP32 firmware.
But when I flashed it, the board keeps rebooting. I don't have a debugger, so I try to commented out lines of code to see which line caused the rebooting.
In my main function I called the follwoing:
Code: Select all
#define MP_TASK_STACK_SIZE (16 * 1024)
void mp_start()
{
size_t mp_task_heap_size = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
void *mp_task_heap = malloc(mp_task_heap_size);
volatile uint32_t sp = (uint32_t)get_sp();
mp_stack_set_top((void *)sp);
// Initialized stack limit
mp_stack_set_limit(MP_TASK_STACK_SIZE - 1024);
// Initialize heap
gc_init(mp_task_heap, mp_task_heap + mp_task_heap_size);
// Initialize interpreter
mp_init();
}
the printed message before rebooting is like:
Code: Select all
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400ded2e PS : 0x00060330 A0 : 0x800d1072 A1 : 0x3ffbbb70
A2 : 0x3ffbbb90 A3 : 0x3f400148 A4 : 0x3f400324 A5 : 0x0000031e
A6 : 0x3f400148 A7 : 0x3f40036c A8 : 0x800ded2e A9 : 0x3ffbbb50
A10 : 0x00000000 A11 : 0x00000004 A12 : 0x00000000 A13 : 0x0000001f
A14 : 0x00000001 A15 : 0x00000005 SAR : 0x00000004 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
ELF file SHA256: 2f5dd82114682226
Backtrace: 0x400ded2b:0x3ffbbb70 0x400d106f:0x3ffbbb90 0x400d104e:0x3ffbbbc0 0x400d99ca:0x3ffbbbe0 0x4008cd59:0x3ffbbc00
Rebooting...
ets Jun 8 2016 00:22:57