diff --git a/bare-arm/main.c b/bare-arm/main.c index bdaded4362..286e41cd4d 100644 --- a/bare-arm/main.c +++ b/bare-arm/main.c @@ -53,7 +53,6 @@ void do_str(const char *src) { } int main(int argc, char **argv) { - qstr_init(); mp_init(); do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\n')"); mp_deinit(); diff --git a/py/runtime.c b/py/runtime.c index a478bb62fc..59e47c7ff7 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -70,8 +70,13 @@ const mp_obj_module_t mp_module___main__ = { }; void mp_init(void) { + qstr_init(); mp_stack_ctrl_init(); +#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF + mp_init_emergency_exception_buf(); +#endif + // call port specific initialization if any #ifdef MICROPY_PORT_INIT_FUNC MICROPY_PORT_INIT_FUNC; diff --git a/qemu-arm/main.c b/qemu-arm/main.c index 91c096289e..7ba818f582 100644 --- a/qemu-arm/main.c +++ b/qemu-arm/main.c @@ -53,7 +53,6 @@ void do_str(const char *src) { } int main(int argc, char **argv) { - qstr_init(); mp_init(); do_str("print('hello world!')"); mp_deinit(); diff --git a/qemu-arm/test_main.c b/qemu-arm/test_main.c index 709bcf2f1b..63f7e3f0c8 100644 --- a/qemu-arm/test_main.c +++ b/qemu-arm/test_main.c @@ -59,7 +59,6 @@ end: int main() { const char a[] = {"sim"}; - qstr_init(); mp_init(); int r = tinytest_main(1, (const char **) a, groups); mp_deinit(); diff --git a/stmhal/main.c b/stmhal/main.c index 183f11b7a0..442ff99347 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -310,9 +310,14 @@ soft_reset: // GC init gc_init(&_heap_start, &_heap_end); -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - mp_init_emergency_exception_buf(); -#endif + + // Micro Python init + mp_init(); + mp_obj_list_init(mp_sys_path, 0); + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash)); + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib)); + mp_obj_list_init(mp_sys_argv, 0); // Change #if 0 to #if 1 if you want REPL on UART_6 (or another uart) // as well as on USB VCP @@ -328,17 +333,7 @@ soft_reset: pyb_stdio_uart = NULL; #endif - // Micro Python init - qstr_init(); - mp_init(); - mp_obj_list_init(mp_sys_path, 0); - mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) - mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash)); - mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib)); - mp_obj_list_init(mp_sys_argv, 0); - readline_init(); - pin_init(); extint_init(); diff --git a/teensy/main.c b/teensy/main.c index a5b2d5b52c..e00c3ff309 100644 --- a/teensy/main.c +++ b/teensy/main.c @@ -267,7 +267,7 @@ soft_reset: // GC init gc_init(&_heap_start, (void*)HEAP_END); - qstr_init(); + // Micro Python init mp_init(); readline_init(); diff --git a/unix-cpy/main.c b/unix-cpy/main.c index 4a04aa4e81..ac142f50ff 100644 --- a/unix-cpy/main.c +++ b/unix-cpy/main.c @@ -87,7 +87,6 @@ void do_file(const char *file) { } int main(int argc, char **argv) { - qstr_init(); mp_init(); if (argc == 2) { diff --git a/unix/main.c b/unix/main.c index 936d7a13a0..9f9f07c255 100644 --- a/unix/main.c +++ b/unix/main.c @@ -278,11 +278,7 @@ int main(int argc, char **argv) { char *heap = malloc(heap_size); gc_init(heap, heap + heap_size); #endif -#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF - mp_init_emergency_exception_buf(); -#endif - qstr_init(); mp_init(); char *home = getenv("HOME");