diff --git a/cc3200/mptask.c b/cc3200/mptask.c index eb673b08c..53910257b 100644 --- a/cc3200/mptask.c +++ b/cc3200/mptask.c @@ -175,7 +175,7 @@ soft_reset: if (!safeboot) { // run boot.py - int ret = pyexec_file("boot.py"); + int ret = pyexec_file("boot.py", false); if (ret & PYEXEC_FORCED_EXIT) { goto soft_reset_exit; } @@ -200,7 +200,7 @@ soft_reset: } else { 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) { goto soft_reset_exit; } diff --git a/esp8266/main.c b/esp8266/main.c index 71dfeb2ac..ce3b83dc3 100644 --- a/esp8266/main.c +++ b/esp8266/main.c @@ -63,8 +63,8 @@ STATIC void mp_reset(void) { dupterm_task_init(); #if MICROPY_MODULE_FROZEN pyexec_frozen_module("_boot.py"); - pyexec_file("boot.py"); - pyexec_file("main.py"); + pyexec_file("boot.py", true); + pyexec_file("main.py", true); #endif } diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 411ee969d..0608c6e12 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -488,11 +488,17 @@ friendly_repl_reset: #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); 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; } diff --git a/lib/utils/pyexec.h b/lib/utils/pyexec.h index e0f62440e..79a80bfd3 100644 --- a/lib/utils/pyexec.h +++ b/lib/utils/pyexec.h @@ -38,7 +38,7 @@ extern pyexec_mode_kind_t pyexec_mode_kind; int pyexec_raw_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); void pyexec_event_repl_init(void); int pyexec_event_repl_process_char(int c); diff --git a/stmhal/main.c b/stmhal/main.c index 30dddaf98..659f5f02f 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -537,7 +537,7 @@ soft_reset: const char *boot_py = "boot.py"; FRESULT res = f_stat(boot_py, NULL); if (res == FR_OK) { - int ret = pyexec_file(boot_py); + int ret = pyexec_file(boot_py, false); if (ret & PYEXEC_FORCED_EXIT) { goto soft_reset_exit; } @@ -598,7 +598,7 @@ soft_reset: } FRESULT res = f_stat(main_py, NULL); if (res == FR_OK) { - int ret = pyexec_file(main_py); + int ret = pyexec_file(main_py, false); if (ret & PYEXEC_FORCED_EXIT) { goto soft_reset_exit; } diff --git a/teensy/main.c b/teensy/main.c index 41e445cb5..f0dc15a7c 100644 --- a/teensy/main.c +++ b/teensy/main.c @@ -304,7 +304,7 @@ soft_reset: #if MICROPY_MODULE_FROZEN pyexec_frozen_module("boot"); #else - if (!pyexec_file("/boot.py")) { + if (!pyexec_file("/boot.py", false)) { flash_error(4); } #endif @@ -324,7 +324,7 @@ soft_reset: } else { 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); } vstr_free(vstr);