Skip to content
Snippets Groups Projects
Commit 79cee7a9 authored by rahix's avatar rahix
Browse files

feat(pycardium): Always reload pycardium before going to REPL


Remove the big endless loop from pycardium main and instead use
epic_exec("") to switch to REPL.  This way, any MicroPython state is
reset and also all hardware will be in a clean reinitialized state.

This also means that pycard10.py will now run scripts in a clean
environment that is not tainted by whatever was running before.

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent f2d8b3c8
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,6 @@ int main(void) ...@@ -50,7 +50,6 @@ int main(void)
mp_stack_set_top(&__StackTop); mp_stack_set_top(&__StackTop);
mp_stack_set_limit((mp_int_t)&__StackLimit); mp_stack_set_limit((mp_int_t)&__StackLimit);
while (1) {
gc_init(&__HeapBase + 1024 * 10, &__HeapLimit); gc_init(&__HeapBase + 1024 * 10, &__HeapLimit);
mp_init(); mp_init();
...@@ -61,18 +60,15 @@ int main(void) ...@@ -61,18 +60,15 @@ int main(void)
/* request by badge.team */ /* request by badge.team */
mp_obj_list_init(mp_sys_path, 0); mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_ROM_QSTR(MP_QSTR_)); mp_obj_list_append(mp_sys_path, MP_ROM_QSTR(MP_QSTR_));
mp_obj_list_append( mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib));
mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib) mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps));
);
mp_obj_list_append(
mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps)
);
if (cnt > 0) { if (cnt > 0) {
pyexec_file_if_exists(script_name); pyexec_file_if_exists(script_name);
}
epic_uart_write_str(header, sizeof(header)); /* Drop to REPL by reloading Pycardium */
epic_exec("");
}
for (;;) { for (;;) {
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
...@@ -87,7 +83,8 @@ int main(void) ...@@ -87,7 +83,8 @@ int main(void)
} }
mp_deinit(); mp_deinit();
}
epic_exit(0);
} }
void HardFault_Handler(void) void HardFault_Handler(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment