From 8d62bbd46aa178abc6e029b0ba79d915f7f988c2 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Tue, 21 Oct 2014 23:04:38 -0700 Subject: Add pyb.hard_reset, and make sys.exit() or raise SystemExit do a soft reset. --- stmhal/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'stmhal/main.c') diff --git a/stmhal/main.c b/stmhal/main.c index 097b8ca85..0279e70b4 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -458,7 +458,11 @@ soft_reset: const char *boot_py = "boot.py"; FRESULT res = f_stat(boot_py, NULL); if (res == FR_OK) { - if (!pyexec_file(boot_py)) { + int ret = pyexec_file(boot_py); + if (ret & PYEXEC_FORCED_EXIT) { + goto soft_reset_exit; + } + if (!ret) { flash_error(4); } } @@ -517,7 +521,11 @@ soft_reset: } FRESULT res = f_stat(main_py, NULL); if (res == FR_OK) { - if (!pyexec_file(main_py)) { + int ret = pyexec_file(main_py); + if (ret & PYEXEC_FORCED_EXIT) { + goto soft_reset_exit; + } + if (!ret) { flash_error(3); } } @@ -537,6 +545,8 @@ soft_reset: } } +soft_reset_exit: + // soft reset printf("PYB: sync filesystems\n"); -- cgit v1.2.3