zephyr/main: Execute boot.py and main.py like other ports.

Changes here make the zephyr port act the same as other ports for the
start up and shut down sequence:
- `boot.py` is executed if it exists, and can force a soft reset
- `main.py` is only executed if in friendly REPL and if `boot.py` executed
  successfully; and it can also force a soft reset
- print "MPY: " before "soft reboot" on soft reset

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-06-23 12:52:05 +10:00
parent 16d9e704ae
commit d9b4327c66

View File

@@ -156,7 +156,17 @@ soft_reset:
#endif
#if MICROPY_MODULE_FROZEN || MICROPY_VFS
pyexec_file_if_exists("main.py");
// Execute user scripts.
int ret = pyexec_file_if_exists("boot.py");
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL && ret != 0) {
ret = pyexec_file_if_exists("main.py");
if (ret & PYEXEC_FORCED_EXIT) {
goto soft_reset_exit;
}
}
#endif
for (;;) {
@@ -171,7 +181,11 @@ soft_reset:
}
}
printf("soft reboot\n");
#if MICROPY_MODULE_FROZEN || MICROPY_VFS
soft_reset_exit:
#endif
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
#if MICROPY_PY_BLUETOOTH
mp_bluetooth_deinit();