diff options
| author | robert-hh <robert@hammelrath.com> | 2022-06-05 21:55:30 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-10-06 22:50:56 +1100 |
| commit | 4ef2da176f2ca1e7f3cb02488aba61a018033575 (patch) | |
| tree | ee3d2a22a7ce8cd464c14f6ed5e0dba59a13d39f | |
| parent | 45bf25a0022033474b9fe699267297f882ca9772 (diff) | |
samd/main: Use the common execution mode of boot.py and main.py.
Behaviour is:
- Do not execute main.py if boot.py failed.
- On a forced exit, do a soft reset.
| -rw-r--r-- | ports/samd/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ports/samd/main.c b/ports/samd/main.c index 1f056083a..5aab39e50 100644 --- a/ports/samd/main.c +++ b/ports/samd/main.c @@ -51,8 +51,17 @@ void samd_main(void) { pyexec_frozen_module("_boot.py"); // Execute user scripts. - pyexec_file_if_exists("boot.py"); - pyexec_file_if_exists("main.py"); + int ret = pyexec_file_if_exists("boot.py"); + if (ret & PYEXEC_FORCED_EXIT) { + goto soft_reset_exit; + } + // Do not execute main.py if boot.py failed + 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; + } + } for (;;) { if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { @@ -66,6 +75,7 @@ void samd_main(void) { } } + soft_reset_exit: mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n"); adc_deinit_all(); pin_irq_deinit_all(); |
