diff options
author | Dave Hylands <dhylands@gmail.com> | 2014-10-21 23:04:38 -0700 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-22 19:14:20 +0100 |
commit | 8d62bbd46aa178abc6e029b0ba79d915f7f988c2 (patch) | |
tree | 80b86e266347cccc1d99f9c1c362037a06c7e94b /stmhal/main.c | |
parent | 3e42570538b46d680e796136ff441ae7b8a8fac5 (diff) | |
download | micropython-8d62bbd46aa178abc6e029b0ba79d915f7f988c2.tar.gz micropython-8d62bbd46aa178abc6e029b0ba79d915f7f988c2.zip |
Add pyb.hard_reset, and make sys.exit() or raise SystemExit do a soft reset.
Diffstat (limited to 'stmhal/main.c')
-rw-r--r-- | stmhal/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/stmhal/main.c b/stmhal/main.c index 097b8ca853..0279e70b48 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"); |