cc3200: Remove duplicated checks for boot.py and main.py existency.

This commit is contained in:
Daniel Campora 2015-05-24 18:05:02 +02:00
parent 90d7c4ef3d
commit 95f19b4542
1 changed files with 15 additions and 23 deletions

View File

@ -105,7 +105,6 @@ void TASK_Micropython (void *pvParameters) {
uint32_t sp = gc_helper_get_sp(); uint32_t sp = gc_helper_get_sp();
gc_collect_init (sp); gc_collect_init (sp);
bool safeboot = false; bool safeboot = false;
FRESULT res;
mptask_pre_init(); mptask_pre_init();
@ -184,18 +183,14 @@ soft_reset:
MP_STATE_PORT(pyb_config_main) = MP_OBJ_NULL; MP_STATE_PORT(pyb_config_main) = MP_OBJ_NULL;
if (!safeboot) { if (!safeboot) {
// run boot.py, if it exists // run boot.py
const char *boot_py = "boot.py"; int ret = pyexec_file("boot.py");
res = f_stat(boot_py, NULL); if (ret & PYEXEC_FORCED_EXIT) {
if (res == FR_OK) { goto soft_reset_exit;
int ret = pyexec_file(boot_py); }
if (ret & PYEXEC_FORCED_EXIT) { if (!ret) {
goto soft_reset_exit; // flash the system led
} mperror_signal_error();
if (!ret) {
// flash the system led
mperror_signal_error();
}
} }
} }
@ -214,16 +209,13 @@ soft_reset:
} else { } else {
main_py = mp_obj_str_get_str(MP_STATE_PORT(pyb_config_main)); main_py = mp_obj_str_get_str(MP_STATE_PORT(pyb_config_main));
} }
res = f_stat(main_py, NULL); int ret = pyexec_file(main_py);
if (res == FR_OK) { if (ret & PYEXEC_FORCED_EXIT) {
int ret = pyexec_file(main_py); goto soft_reset_exit;
if (ret & PYEXEC_FORCED_EXIT) { }
goto soft_reset_exit; if (!ret) {
} // flash the system led
if (!ret) { mperror_signal_error();
// flash the system led
mperror_signal_error();
}
} }
} }
} }