Compare commits
1 Commits
jebbatime
...
pyexec-sil
Author | SHA1 | Date |
---|---|---|
Paul Sokolovsky | 791ba7f038 |
|
@ -175,7 +175,7 @@ soft_reset:
|
||||||
|
|
||||||
if (!safeboot) {
|
if (!safeboot) {
|
||||||
// run boot.py
|
// run boot.py
|
||||||
int ret = pyexec_file("boot.py");
|
int ret = pyexec_file("boot.py", false);
|
||||||
if (ret & PYEXEC_FORCED_EXIT) {
|
if (ret & PYEXEC_FORCED_EXIT) {
|
||||||
goto soft_reset_exit;
|
goto soft_reset_exit;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ soft_reset:
|
||||||
} else {
|
} else {
|
||||||
main_py = mp_obj_str_get_str(MP_STATE_PORT(machine_config_main));
|
main_py = mp_obj_str_get_str(MP_STATE_PORT(machine_config_main));
|
||||||
}
|
}
|
||||||
int ret = pyexec_file(main_py);
|
int ret = pyexec_file(main_py, false);
|
||||||
if (ret & PYEXEC_FORCED_EXIT) {
|
if (ret & PYEXEC_FORCED_EXIT) {
|
||||||
goto soft_reset_exit;
|
goto soft_reset_exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,8 @@ STATIC void mp_reset(void) {
|
||||||
dupterm_task_init();
|
dupterm_task_init();
|
||||||
#if MICROPY_MODULE_FROZEN
|
#if MICROPY_MODULE_FROZEN
|
||||||
pyexec_frozen_module("_boot.py");
|
pyexec_frozen_module("_boot.py");
|
||||||
pyexec_file("boot.py");
|
pyexec_file("boot.py", true);
|
||||||
pyexec_file("main.py");
|
pyexec_file("main.py", true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -488,11 +488,17 @@ friendly_repl_reset:
|
||||||
|
|
||||||
#endif // MICROPY_REPL_EVENT_DRIVEN
|
#endif // MICROPY_REPL_EVENT_DRIVEN
|
||||||
|
|
||||||
int pyexec_file(const char *filename) {
|
// This function is mostly intended to execute boot.py/main.py, i.e.
|
||||||
|
// run in unattended mode. It has bool param because many people
|
||||||
|
// find diagnostic message printed on board boot confusing (treat
|
||||||
|
// it as "error"), so ports affected may silence them.
|
||||||
|
int pyexec_file(const char *filename, bool silent) {
|
||||||
mp_lexer_t *lex = mp_lexer_new_from_file(filename);
|
mp_lexer_t *lex = mp_lexer_new_from_file(filename);
|
||||||
|
|
||||||
if (lex == NULL) {
|
if (lex == NULL) {
|
||||||
printf("could not open file '%s' for reading\n", filename);
|
if (!silent) {
|
||||||
|
printf("could not open file '%s' for reading\n", filename);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ extern pyexec_mode_kind_t pyexec_mode_kind;
|
||||||
|
|
||||||
int pyexec_raw_repl(void);
|
int pyexec_raw_repl(void);
|
||||||
int pyexec_friendly_repl(void);
|
int pyexec_friendly_repl(void);
|
||||||
int pyexec_file(const char *filename);
|
int pyexec_file(const char *filename, bool silent);
|
||||||
int pyexec_frozen_module(const char *name);
|
int pyexec_frozen_module(const char *name);
|
||||||
void pyexec_event_repl_init(void);
|
void pyexec_event_repl_init(void);
|
||||||
int pyexec_event_repl_process_char(int c);
|
int pyexec_event_repl_process_char(int c);
|
||||||
|
|
|
@ -537,7 +537,7 @@ soft_reset:
|
||||||
const char *boot_py = "boot.py";
|
const char *boot_py = "boot.py";
|
||||||
FRESULT res = f_stat(boot_py, NULL);
|
FRESULT res = f_stat(boot_py, NULL);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
int ret = pyexec_file(boot_py);
|
int ret = pyexec_file(boot_py, false);
|
||||||
if (ret & PYEXEC_FORCED_EXIT) {
|
if (ret & PYEXEC_FORCED_EXIT) {
|
||||||
goto soft_reset_exit;
|
goto soft_reset_exit;
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ soft_reset:
|
||||||
}
|
}
|
||||||
FRESULT res = f_stat(main_py, NULL);
|
FRESULT res = f_stat(main_py, NULL);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
int ret = pyexec_file(main_py);
|
int ret = pyexec_file(main_py, false);
|
||||||
if (ret & PYEXEC_FORCED_EXIT) {
|
if (ret & PYEXEC_FORCED_EXIT) {
|
||||||
goto soft_reset_exit;
|
goto soft_reset_exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ soft_reset:
|
||||||
#if MICROPY_MODULE_FROZEN
|
#if MICROPY_MODULE_FROZEN
|
||||||
pyexec_frozen_module("boot");
|
pyexec_frozen_module("boot");
|
||||||
#else
|
#else
|
||||||
if (!pyexec_file("/boot.py")) {
|
if (!pyexec_file("/boot.py", false)) {
|
||||||
flash_error(4);
|
flash_error(4);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -324,7 +324,7 @@ soft_reset:
|
||||||
} else {
|
} else {
|
||||||
vstr_add_str(vstr, mp_obj_str_get_str(pyb_config_main));
|
vstr_add_str(vstr, mp_obj_str_get_str(pyb_config_main));
|
||||||
}
|
}
|
||||||
if (!pyexec_file(vstr_null_terminated_str(vstr))) {
|
if (!pyexec_file(vstr_null_terminated_str(vstr), false)) {
|
||||||
flash_error(3);
|
flash_error(3);
|
||||||
}
|
}
|
||||||
vstr_free(vstr);
|
vstr_free(vstr);
|
||||||
|
|
Loading…
Reference in New Issue